ソースを参照

'oak_2024_07_26_02_38'

oak 5 ヶ月 前
コミット
201aa1e0b4

+ 85 - 0
genjson/gen_json_videos_list_data.py

@@ -0,0 +1,85 @@
+
+####################################use for all ,not use in crontab
+
+import os
+from typing import Optional
+from dataset.util import ResultIter
+from datetime import tzinfo
+import datetime
+import mysql.connector
+from mysql.connector import Error
+import dataset
+import json
+from pytube import extract
+import requests
+import json 
+
+hhhMBPath = '../hhh-home-mb'
+hhhPCPath = '../hhh-home-pc'
+
+#connstr = 'mysql://hhh7796hhh:lYmWsu^ujcA1@hhh-v57.cmab1ctkglka.ap-northeast-2.rds.amazonaws.com:3306/xoops?charset=utf8mb4'
+#2022/12/13 change
+connstr = 'mysql://hhh7796hhh:lYmWsu^ujcA1@ec2-3-35-26-49.ap-northeast-2.compute.amazonaws.com:3306/xoops?charset=utf8mb4'
+
+""" db = dataset.connect(
+    'mysql://hhh7796hhh:lYmWsu^ujcA1@hhh-v57.cmab1ctkglka.ap-northeast-2.rds.amazonaws.com:3306/xoops?charset=utf8mb4') """
+#        charset='utf8',
+#        collation='utf8_unicode_ci'
+
+#2022/12/13 change
+connobj = {
+    'host': 'ec2-3-35-26-49.ap-northeast-2.compute.amazonaws.com',
+    'database': 'xoops',
+   'user': 'hhh7796hhh',
+   'password': 'lYmWsu^ujcA1',
+    'use_unicode': True   
+    #'charset': 'utf8',
+    #'collation': 'utf8_unicode_ci'
+
+}
+
+ #connobj = {
+    # 'host': 'hhh-v57.cmab1ctkglka.ap-northeast-2.rds.amazonaws.com',
+     #'database': 'xoops',
+     #'user': 'hhh7796hhh',
+     #'password': 'lYmWsu^ujcA1',
+     #'use_unicode': True
+    ##'charset': 'utf8',
+     ##'collation': 'utf8_unicode_ci'
+ #}
+
+# def ExecuteQuery(isql):
+#     with mysql.connector.connect(**connobj) as connection :
+#         with connection.cursor(dictionary=True) as cursor:
+#     # connection.set_charset_collation('utf8','utf8_general_ci')
+#             #cursor = connection.cursor(dictionary=True)
+#             cursor.execute(isql)
+#             return cursor.fetchall()
+
+# records = ExecuteQuery("SELECT hcolumn_id FROM _hcolumn where onoff=1")
+# list_use = []
+# for i in records:
+#     list_use.append(i['hcolumn_id'])
+# #print(list_use)
+# for j in list_use:
+while True:
+    try:
+        a=requests.get('https://m3.hhh.com.tw:18673/video_search?page=1&page_size=18&order_by=new')
+        break
+    except:
+        print('bad:',j)
+        time.sleep(5)
+
+d=a.json()
+print(d)
+with open('../videos/lists/json/videos_lists_data.json','w+',encoding="utf-8") as f:
+    json.dump(d, f)
+
+cmd="""curl -X POST "https://api.cloudflare.com/client/v4/zones/8cb58022ad5743cfd9f088d5e3a261eb/purge_cache" -H "X-Auth-Email: web.dept.hhh@gmail.com"  -H "X-Auth-Key:63e51d9a1638d66afcbfc3320aabec52304de" -H "Content-Type: application/json" --data '{"files":["https://hhh.com.tw/hhh-test/json/videos_lists_data.json"]}'"""
+print(cmd)
+os.system(cmd)
+    #if str(j)=='5':
+    #    break
+
+
+

ファイルの差分が大きいため隠しています
+ 0 - 0
json/designers_lists_data.json


+ 1 - 1
videos/lists/index.html

@@ -563,7 +563,7 @@
   <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.1/dist/js/bootstrap.min.js"
     integrity="sha384-skAcpIdS7UcVUC05LJ9Dxay8AXcDYfBJqt1CJ85S/CFujBsIzCIv+l9liuYLaMQ/"
     crossorigin="anonymous"></script>
-  <script src="./js/main.js"></script>
+  <script src="./js/main.js?a=2"></script>
 </body>
 
 </html>

+ 2 - 2
videos/lists/js/main.js

@@ -135,8 +135,8 @@ async function videoSearch(type = "") {
 
   if (isFirstLoad) {
     // 第一次載入使用本地 JSON 文件
-    // url = './json/designers_lists_data.json';
-    url = `https://m3.hhh.com.tw:18673/video_search?page=${page}&page_size=${pageSize}&order_by=new`;
+     url = './json/videos_lists_data.json';
+  //  url = `https://m3.hhh.com.tw:18673/video_search?page=${page}&page_size=${pageSize}&order_by=new`;
   } else {
     // 後續使用 API (預設排序為 recommend)
     url = `https://m3.hhh.com.tw:18673/video_search?page=${page}&page_size=${pageSize}`;

ファイルの差分が大きいため隠しています
+ 0 - 0
videos/lists/json/videos_lists_data.json


この差分においてかなりの量のファイルが変更されているため、一部のファイルを表示していません