Browse Source

210926 my tests

yukyo0821 3 năm trước cách đây
mục cha
commit
3fc4aa215a

BIN
__pycache__/genhhhjson.cpython-39.pyc


BIN
__pycache__/genjson.cpython-39.pyc


+ 25 - 0
blank.html

@@ -0,0 +1,25 @@
+<!DOCTYPE html>
+<html lang="en">
+
+<head>
+  <meta name="description" content="Webpage description goes here" />
+  <meta charset="utf-8">
+  <title>Change_me</title>
+  <meta name="viewport" content="width=device-width, initial-scale=1">
+  <meta name="author" content="">
+  <link rel="stylesheet" href="css/style.css">
+  <script src="http://code.jquery.com/jquery-latest.min.js"></script>
+  <script src="https://cdn.jsdelivr.net/npm/axios/dist/axios.min.js"></script>
+</head>
+
+<body>
+  
+<div class="container">
+  
+</div>
+
+<script>
+</script>
+
+</body>
+</html>

BIN
genjson/__pycache__/genhhhjson.cpython-39.pyc


BIN
genjson/__pycache__/genjson.cpython-39.pyc


+ 312 - 0
genjson/genhhhjson.py

@@ -0,0 +1,312 @@
+
+
+from typing import Optional
+from dataset.util import ResultIter
+from fastapi import FastAPI
+from fastapi.middleware.cors import CORSMiddleware
+
+from pytrends.request import TrendReq
+from datetime import tzinfo
+import datetime
+import mysql.connector
+from mysql.connector import Error
+import dataset
+import json
+import re
+from pytube import extract
+
+from opencc import OpenCC
+
+app = FastAPI()
+cc = OpenCC('s2t')
+
+origins = [
+    "*"
+]
+app.add_middleware(
+    CORSMiddleware,
+    allow_origins=origins,
+    allow_credentials=True,
+    allow_methods=["*"],
+    allow_headers=["*"],
+)
+
+
+@app.get("/")
+def read_root():
+    return {"Hello": "World"}
+
+
+@app.get("/test")
+def test():
+    db = dataset.connect(
+        'mysql://hhh7796hhh:lYmWsu^ujcA1@hhh-v57.cmab1ctkglka.ap-northeast-2.rds.amazonaws.com:3306/xoops?charset=utf8', {'pool_recycle': 3600})
+
+    jData = json.load(open('data.json', encoding='utf8'))
+    aa = ""
+    cc = db.connections
+    cursor = db.query("select * from site_setup;")
+    for c in cursor:
+        aa = c['id']
+    return {aa}
+
+
+@app.get("/movexoopstostage")
+def movexoopstostage(designerid: str = "0", caseid: str = "0"):
+    db = dataset.connect(
+        'mysql://hhh7796hhh:lYmWsu^ujcA1@hhh-v57.cmab1ctkglka.ap-northeast-2.rds.amazonaws.com:3306/xoops?charset=utf8', {'pool_recycle': 3600})
+
+    cursor = db.query(
+        "replace INTO stage._hdesigner SELECT * FROM xoops._hdesigner WHERE hdesigner_id IN ('" + designerid+"');")
+    cursor = db.query(
+        "replace INTO stage._hcase SELECT * FROM xoops._hcase WHERE hcase_id IN ('"+caseid.replace(',', "','")+"');")
+    cursor = db.query(
+        "replace INTO stage._hcase_img SELECT * FROM xoops._hcase_img WHERE hcase_id IN ('"+caseid.replace(',', "','")+"');")
+    return {"success"}
+
+
+@app.get("/genjson")
+def genjson(filename: str = "index.json"):
+
+    jData = json.load(open('data.json', encoding='utf8'))
+
+    db = dataset.connect(
+        'mysql://hhh7796hhh:lYmWsu^ujcA1@hhh-v57.cmab1ctkglka.ap-northeast-2.rds.amazonaws.com:3306/xoops?charset=utf8')
+    db.begin()
+    cursor = db.query(
+        "SELECT * FROM _had where (now() between start_time and end_time or ( start_time is null and end_time is null) or ( start_time = '0000-00-00 00:00:00' and end_time = '0000-00-00 00:00:00')) and onoff='1' and adtype like '首八大%' ")
+
+    for x in jData:
+
+        # 頂部輪播區-新刊頭
+        if x['id'] == 0:
+            cursor = db.query("""SELECT adlogo lo,adlogo_mobile mlo, adhref lk, adlogo_mobile_webp lomwebp FROM _had
+                        WHERE adtype LIKE '新刊頭%'
+                        AND onoff='1'
+                        AND(NOW() BETWEEN start_time AND end_time OR(start_time='0000-00-00 00:00:00' and end_time='0000-00-00 00:00:00') or (start_time is null and end_time is NULL))
+                        ORDER BY cast(SUBSTR(adtype,4) AS DECIMAL)""")
+
+            x["data"] = []
+            for c in cursor:
+                a = {'imgUrl': c['mlo'], 'link': str(
+                    c['lk']), 'DimgUrl': c['lo'], 'webp': str(c['lomwebp'])}
+                x["data"].append(a)
+            # print(x["data"])
+            cursor.close()
+
+        # 主要輪播區-首八大
+        if x['id'] == 1:
+            cursor = db.query("""SELECT adlogo lo,adlogo_mobile mlo, adhref lk, adlogo_mobile_webp lomwebp FROM _had
+                        WHERE adtype LIKE '首八大%'
+                        AND onoff='1'
+                        AND(NOW() BETWEEN start_time AND end_time OR(start_time='0000-00-00 00:00:00' and end_time='0000-00-00 00:00:00') or (start_time is null and end_time is NULL))
+                        ORDER BY cast(SUBSTR(adtype,4) AS DECIMAL)""")
+
+            x["data"] = []
+            for c in cursor:
+                a = {'imgUrl': c['mlo'], 'link': str(
+                    c['lk']), 'DimgUrl': c['lo'], 'webp': str(c['lomwebp'])}
+                x["data"].append(a)
+            # print(x["data"])
+            cursor.close()
+
+        #tab區塊-最夯設計, 影音實錄, 專欄文章
+        if x['id'] == 2:
+            x["data"] = []
+            cursor = db.query("""SELECT caption TT ,cover IMG, CONCAT('https://www.hhh.com.tw/cases/detail/',hcase_id,'/') LK
+                            from _hcase
+                            left join _hdesigner ON _hcase.hdesigner_id=_hdesigner.hdesigner_id
+                            WHERE
+                            _hcase.onoff='1' AND _hdesigner.onoff='1'
+                            AND(NOW() > sdate)
+                            ORDER BY hcase_id DESC
+                            LIMIT 3""")
+            a = {'tab': '最夯設計', 'data': []}
+            for c in cursor:
+                ad = {'imgUrl': c['IMG'], 'link': c['LK'],
+                      'description': c['TT']}
+                a['data'].append(ad)
+            x["data"].append(a)
+            cursor.close()
+
+            cursor = db.query("""SELECT title TT,iframe IMG , CONCAT('https://www.hhh.com.tw/video-post.php?id=',hvideo_id) LK
+                            from _hvideo
+                            ORDER BY hvideo_id DESC
+                            LIMIT 3""")
+            a = {'tab': '影音實錄', 'data': []}
+            for c in cursor:
+                tid = extract.video_id(c['IMG'])
+                timg = "https://img.youtube.com/vi/" + tid+"/hqdefault.jpg"
+                ad = {'imgUrl': timg, 'link': c['LK'],
+                      'description': c['TT']}
+                a['data'].append(ad)
+            x["data"].append(a)
+            cursor.close()
+
+            cursor = db.query("""SELECT ctitle TT,clogo IMG, CONCAT('https://www.hhh.com.tw/column/detail/',hcolumn_id,'/') LK
+                            from _hcolumn
+                            WHERE onoff='1'
+                            AND NOW() > sdate
+                            ORDER BY hcolumn_id DESC
+                            LIMIT 3""")
+            a = {'tab': '專欄文章', 'data': []}
+            for c in cursor:
+                ad = {'imgUrl': c['IMG'], 'link': c['LK'],
+                      'description': c['TT']}
+                a['data'].append(ad)
+            x["data"].append(a)
+            cursor.close()
+            # print(x["data"])
+
+        # 主題企劃區
+        if x['id'] == 3:
+            cursor = db.query("""SELECT CONCAT('https://www.hhh.com.tw/',theme_type,'/',mapping_id,'/detail/') lk, ifnull(_hcase.caption,_hcolumn.ctitle) tt, ifnull(_hcase.cover,_hcolumn.clogo) lo
+                        FROM homepage_set
+                        left join _hcase ON _hcase.hcase_id=homepage_set.mapping_id AND theme_type='case'
+                        left join _hcolumn ON _hcolumn.hcolumn_id=homepage_set.mapping_id AND theme_type='column'
+                        WHERE outer_set=1
+                        AND homepage_set.onoff='Y'
+                        AND(NOW() BETWEEN homepage_set.start_time AND homepage_set.end_time OR(homepage_set.start_time='0000-00-00 00:00:00' and homepage_set.end_time='0000-00-00 00:00:00') or (homepage_set.start_time is null and homepage_set.end_time is NULL))
+                        ORDER BY inner_sort""")
+
+            x["data"] = []
+            for c in cursor:
+                a = {'imgUrl': c['lo'], 'link': str(c['lk'])}
+                x["data"].append(a)
+            cursor.close()
+            # print(x["data"])
+
+        # 編輯精選
+        if x['id'] == 4:
+            cursor = db.query("""SELECT hcolumn_id, ctitle, clogo
+                                FROM homepage_set
+                                LEFT JOIN _hcolumn ON mapping_id = hcolumn_id
+                                WHERE outer_set=8
+                                AND homepage_set.onoff='Y'
+                                AND(NOW() BETWEEN homepage_set.start_time AND homepage_set.end_time OR(homepage_set.start_time='0000-00-00 00:00:00' and homepage_set.end_time='0000-00-00 00:00:00') or (homepage_set.start_time is null and homepage_set.end_time is NULL))
+                                ORDER BY inner_sort""")
+
+            x["data"] = []
+            for c in cursor:
+                a = {'imgUrl': c['clogo'], 'link': "https://www.hhh.com.tw/columns/detail/" + str(
+                    c['hcolumn_id']) + "/", 'description': c['ctitle']}
+                x["data"].append(a)
+            cursor.close()
+            # print(x["data"])
+
+        # 來選好物區
+        if x['id'] == 6:
+            
+            db = dataset.connect(
+                    'mysql://hhh7796hhh:lYmWsu^ujcA1@hhh-v57.cmab1ctkglka.ap-northeast-2.rds.amazonaws.com:3306/xoops?charset=utf8')
+                  
+            cursor = db.query(
+                "SELECT max_row from outer_site_set WHERE title='來選好貨'")
+            
+            maxrow = 1
+            for c in cursor:
+                maxrow = c['max_row']
+
+            db = dataset.connect(
+                    'mysql://hhh7796hhh:lYmWsu^ujcA1@hhh-v57.cmab1ctkglka.ap-northeast-2.rds.amazonaws.com:3306/xoops?charset=utf8')
+
+            cursor = db.query("""SELECT id, cover, name
+                                FROM _hproduct
+                                where onoff ='1'
+                                ORDER BY id desc
+                                LIMIT """ + str(maxrow))
+
+            x["data"] = []
+            for fk in cursor:
+                a = {'imgUrl': fk['cover'], 'link': "https://www.hhh.com.tw/product-post.php?id=" + str(
+                    fk['id']) + "/", 'description': fk['name']}
+                x["data"].append(a)
+            cursor.close()
+            # print(x["data"])
+
+        # 本週推薦
+        if x['id'] == 7:
+            cursor = db.query(
+                "SELECT max_row from outer_site_set WHERE title='本週推薦'")
+
+            maxrow = 1
+            for c in cursor:
+                maxrow = c['max_row']
+
+            db = dataset.connect(
+                    'mysql://hhh7796hhh:lYmWsu^ujcA1@hhh-v57.cmab1ctkglka.ap-northeast-2.rds.amazonaws.com:3306/xoops?charset=utf8')
+
+            cursor = db.query("""SELECT homepage_set.inner_sort, homepage_set.outer_set, _hcase_img.name as J, _hcase_img.name, _hcase.caption, _hcase.hcase_id, _hcase.hdesigner_id, _hdesigner.name, theme_type 
+                            FROM homepage_set
+                            left join _hcase ON _hcase.hcase_id=homepage_set.mapping_id
+                            LEFT JOIN _hcase_img ON _hcase.hcase_id=_hcase_img.hcase_id
+                            LEFT JOIN _hdesigner ON _hcase.hdesigner_id=_hdesigner.hdesigner_id
+                            WHERE homepage_set.onoff='Y'
+                            AND _hcase.onoff='1'
+                            AND is_cover='1'
+                            AND outer_set = (SELECT oss_id from outer_site_set WHERE title='粉絲推薦')
+                            AND(NOW() BETWEEN homepage_set.start_time AND homepage_set.end_time OR(homepage_set.start_time='0000-00-00 00:00:00' and homepage_set.end_time='0000-00-00 00:00:00') or (homepage_set.start_time is null and homepage_set.end_time is NULL))
+                            ORDER BY inner_sort
+                            LIMIT """ + str(maxrow))
+
+            x["data"] = []
+            for fk in cursor:
+                a = {'imgUrl': fk['J'], 'link': "https://www.hhh.com.tw/cases/detail/" + str(
+                    fk['hcase_id']) + "/", 'description': fk['caption'], "video": "false"}
+                x["data"].append(a)
+            cursor.close()
+            # print(x["data"])
+
+        # 粉絲推薦
+        if x['id'] == 8:
+            
+            db = dataset.connect(
+                    'mysql://hhh7796hhh:lYmWsu^ujcA1@hhh-v57.cmab1ctkglka.ap-northeast-2.rds.amazonaws.com:3306/xoops?charset=utf8')
+
+            cursor = db.query(
+                "SELECT max_row from outer_site_set WHERE title='粉絲推薦'")
+
+            maxrow = 1
+            for c in cursor:
+                maxrow = c['max_row']
+
+            db = dataset.connect(
+                    'mysql://hhh7796hhh:lYmWsu^ujcA1@hhh-v57.cmab1ctkglka.ap-northeast-2.rds.amazonaws.com:3306/xoops?charset=utf8')
+
+            cursor = db.query("""SELECT homepage_set.inner_sort, homepage_set.outer_set, _hcase_img.name as J, _hcase_img.name, _hcase.caption, _hcase.hcase_id, _hcase.hdesigner_id, _hdesigner.name, theme_type 
+                            FROM homepage_set
+                            left join _hcase ON _hcase.hcase_id=homepage_set.mapping_id
+                            LEFT JOIN _hcase_img ON _hcase.hcase_id=_hcase_img.hcase_id
+                            LEFT JOIN _hdesigner ON _hcase.hdesigner_id=_hdesigner.hdesigner_id
+                            WHERE homepage_set.onoff='Y'
+                            AND _hcase.onoff='1'
+                            AND is_cover='1'
+                            AND outer_set = (SELECT oss_id from outer_site_set WHERE title='粉絲推薦')
+                            AND(NOW() BETWEEN homepage_set.start_time AND homepage_set.end_time OR(homepage_set.start_time='0000-00-00 00:00:00' and homepage_set.end_time='0000-00-00 00:00:00') or (homepage_set.start_time is null and homepage_set.end_time is NULL))
+                            ORDER BY inner_sort
+                            LIMIT """ + str(maxrow))
+
+            x["data"] = []
+            for fk in cursor:
+                a = {'imgUrl': fk['J'], 'link': "https://www.hhh.com.tw/cases/detail/" + str(
+                    fk['hcase_id']) + "/", 'description': fk['caption'], "video": "false"}
+                x["data"].append(a)
+            cursor.close()
+            # print(x["data"])
+
+        if x['id'] == 9:
+            cursor = db.query(
+                "SELECT id, (case when youtube_title = '' OR youtube_title IS NULL then (SELECT title FROM _hvideo ORDER BY hvideo_id DESC LIMIT 1) ELSE youtube_title END) T, (case when youtube_id = '' OR youtube_id IS NULL then (SELECT iframe FROM _hvideo ORDER BY hvideo_id DESC LIMIT 1) ELSE youtube_id end) Y FROM site_setup")
+
+            for c in cursor:
+                x['title'] = c['T']
+                x['yt'] = extract.video_id(c['Y'])
+                # print(id)
+            cursor.close()
+            
+    # print(jData)
+    db.close()
+    with open(filename, 'w', encoding='utf-8') as f:
+        json.dump(jData, f, ensure_ascii=False, indent=4)
+
+    return jData

+ 309 - 0
genjson/genjson.py

@@ -0,0 +1,309 @@
+
+import os
+from typing import Optional
+from dataset.util import ResultIter
+from fastapi import FastAPI
+from fastapi.middleware.cors import CORSMiddleware
+
+from pytrends.request import TrendReq
+from datetime import tzinfo
+import datetime
+import mysql.connector
+from mysql.connector import Error
+
+import json
+from pytube import extract
+
+app = FastAPI()
+
+origins = [
+    "*"
+]
+app.add_middleware(
+    CORSMiddleware,
+    allow_origins=origins,
+    allow_credentials=True,
+    allow_methods=["*"],
+    allow_headers=["*"],
+)
+
+hhhHomePath = '../hhh-home-mb'
+
+
+def ExecuteQuery(isql):
+    connection = mysql.connector.connect(
+        host='hhh-v57.cmab1ctkglka.ap-northeast-2.rds.amazonaws.com',
+        database='xoops',
+        user='hhh7796hhh',
+        password='lYmWsu^ujcA1'
+    )
+    cursor = connection.cursor(dictionary=True)
+    cursor.execute(isql)
+    if cursor.rowcount == -1:
+        return cursor.fetchall()
+    else:
+        connection.commit()
+        return cursor.rowcount
+
+
+def ExecuteCmd(isql):
+    connection = mysql.connector.connect(
+        host='hhh-v57.cmab1ctkglka.ap-northeast-2.rds.amazonaws.com',
+        database='xoops',
+        user='hhh7796hhh',
+        password='lYmWsu^ujcA1'
+    )
+    cursor = connection.cursor(dictionary=True)
+    cursor.execute(isql)
+    print(cursor.rowcount)
+    connection.commit()
+    return None
+
+
+@app.get("/")
+def read_root():
+    return {"Hello": "World"}
+
+
+@app.get("/movexoopstostage")
+def movexoopstostage(designerid: str = "0", caseid: str = "0"):
+
+    ExecuteQuery(
+        "replace INTO stage._hdesigner SELECT * FROM xoops._hdesigner WHERE hdesigner_id IN ('" + designerid+"');")
+    ExecuteQuery(
+        "replace INTO stage._hcase SELECT * FROM xoops._hcase WHERE hcase_id IN ('"+caseid.replace(',', "','")+"');")
+    ExecuteQuery(
+        "replace INTO stage._hcase_img SELECT * FROM xoops._hcase_img WHERE hcase_id IN ('"+caseid.replace(',', "','")+"');")
+
+    return {"success"}
+
+
+@app.get("/genjson")
+def genjson(filename: str = "realtime.json"):
+
+    jData = json.load(open(hhhHomePath+'/json/data.json', encoding='utf8'))
+
+    records = ExecuteQuery("SELECT * FROM _had where (now() between start_time and end_time or ( start_time is null and end_time is null) or ( start_time = '0000-00-00 00:00:00' and end_time = '0000-00-00 00:00:00')) and onoff='1' and adtype like '首八大%' ")
+
+    for x in jData:
+
+        # 頂部輪播區-新刊頭
+        if x['id'] == 0:
+            records = ExecuteQuery("""SELECT adlogo lo,adlogo_mobile mlo, adhref lk, adlogo_mobile_webp lomwebp FROM _had
+                        WHERE adtype LIKE '新刊頭%'
+                        AND onoff='1'
+                        AND(NOW() BETWEEN start_time AND end_time OR(start_time='0000-00-00 00:00:00' and end_time='0000-00-00 00:00:00') or (start_time is null and end_time is NULL))
+                        ORDER BY cast(SUBSTR(adtype,4) AS DECIMAL)""")
+
+            x["data"] = []
+            for c in records:
+                a = {'imgUrl': c['mlo'], 'link': str(
+                    c['lk']), 'DimgUrl': c['lo'], 'webp': str(c['lomwebp'])}
+                x["data"].append(a)
+            # print(x["data"])
+
+        # 主要輪播區-首八大
+        if x['id'] == 1:
+            records = ExecuteQuery("""SELECT adlogo lo,adlogo_mobile mlo, adhref lk, adlogo_mobile_webp lomwebp FROM _had
+                        WHERE adtype LIKE '首八大%'
+                        AND onoff='1'
+                        AND(NOW() BETWEEN start_time AND end_time OR(start_time='0000-00-00 00:00:00' and end_time='0000-00-00 00:00:00') or (start_time is null and end_time is NULL))
+                        ORDER BY cast(SUBSTR(adtype,4) AS DECIMAL)""")
+
+            x["data"] = []
+            for c in records:
+                a = {'imgUrl': c['mlo'], 'link': str(
+                    c['lk']), 'DimgUrl': c['lo'], 'webp': str(c['lomwebp'])}
+                x["data"].append(a)
+            # print(x["data"])
+
+        #tab區塊-最夯設計, 影音實錄, 專欄文章
+        if x['id'] == 2:
+            x["data"] = []
+            records = ExecuteQuery("""SELECT caption TT ,cover IMG, CONCAT('https://www.hhh.com.tw/cases/detail/',hcase_id,'/') LK, short_desc txt
+                            from _hcase
+                            left join _hdesigner ON _hcase.hdesigner_id=_hdesigner.hdesigner_id
+                            WHERE
+                            _hcase.onoff='1' AND _hdesigner.onoff='1'
+                            AND(NOW() > sdate)
+                            ORDER BY hcase_id DESC
+                            LIMIT 3""")
+            a = {'tab': '最夯設計', 'data': []}
+            for c in records:
+                ad = {'imgUrl': c['IMG'], 'link': c['LK'],
+                      'description': c['TT'], 'txt': c['txt']}
+                a['data'].append(ad)
+            x["data"].append(a)
+
+            records = ExecuteQuery("""SELECT title TT,iframe IMG , CONCAT('https://www.hhh.com.tw/video-post.php?id=',hvideo_id) LK , name
+                            from _hvideo
+                            ORDER BY hvideo_id DESC
+                            LIMIT 3""")
+            a = {'tab': '影音實錄', 'data': []}
+            for c in records:
+                tid = extract.video_id(c['IMG'])
+                timg = "https://img.youtube.com/vi/" + tid+"/hqdefault.jpg"
+                ad = {'imgUrl': timg, 'link': c['LK'],
+                      'description': c['name'], 'txt': c['TT']}
+                a['data'].append(ad)
+            x["data"].append(a)
+
+            records = ExecuteQuery("""SELECT ctitle TT,clogo IMG, CONCAT('https://www.hhh.com.tw/column/detail/',hcolumn_id,'/') LK, cdesc
+                            from _hcolumn
+                            WHERE onoff='1'
+                            AND NOW() > sdate
+                            ORDER BY hcolumn_id DESC
+                            LIMIT 3""")
+            a = {'tab': '專欄文章', 'data': []}
+            for c in records:
+                ad = {'imgUrl': c['IMG'], 'link': c['LK'],
+                      'description': c['TT'], 'txt': c['cdesc']}
+                a['data'].append(ad)
+            x["data"].append(a)
+            # print(x["data"])
+
+        # 主題企劃區
+        if x['id'] == 3:
+            records = ExecuteQuery("""SELECT logo lo, CONCAT('https://www.hhh.com.tw/topic/detail/',htopic_id,'/') lk, `desc`, title FROM _htopic
+WHERE onoff = '1'
+ORDER BY htopic_id DESC limit 3""")
+
+            x["data"] = []
+            for c in records:
+                a = {'imgUrl': c['lo'], 'link': str(
+                    c['lk']), 'video': 'false', 'description': c['desc'], 'title': c['title']}
+                x["data"].append(a)
+            # print(x["data"])
+
+        # 編輯精選
+        if x['id'] == 4:
+            records = ExecuteQuery("""SELECT hcolumn_id, ctitle, clogo,cdesc
+                                FROM homepage_set
+                                LEFT JOIN _hcolumn ON mapping_id = hcolumn_id
+                                WHERE outer_set=8
+                                AND homepage_set.onoff='Y'
+                                AND(NOW() BETWEEN homepage_set.start_time AND homepage_set.end_time OR(homepage_set.start_time='0000-00-00 00:00:00' and homepage_set.end_time='0000-00-00 00:00:00') or (homepage_set.start_time is null and homepage_set.end_time is NULL))
+                                ORDER BY inner_sort""")
+
+            x["data"] = []
+            for c in records:
+                a = {'imgUrl': c['clogo'], 'link': "https://www.hhh.com.tw/columns/detail/" + str(
+                    c['hcolumn_id']) + "/", 'description': c['ctitle'], 'video': 'false', 'txt': c['cdesc']}
+                x["data"].append(a)
+            # print(x["data"])
+
+        # 來選好物區
+        if x['id'] == 6:
+
+            records = ExecuteQuery(
+                "SELECT max_row from outer_site_set WHERE title='來選好貨'")
+
+            maxrow = 1
+            for c in records:
+                maxrow = c['max_row']
+
+            records = ExecuteQuery("""SELECT id, cover, name
+                                FROM _hproduct
+                                where onoff ='1'
+                                ORDER BY id desc
+                                LIMIT """ + str(maxrow))
+
+            x["data"] = []
+            for fk in records:
+                a = {'imgUrl': fk['cover'], 'link': "https://www.hhh.com.tw/product-post.php?id=" + str(
+                    fk['id']) + "/", 'description': fk['name'], 'video': 'false'}
+                x["data"].append(a)
+            # print(x["data"])
+
+        # 本週推薦
+        if x['id'] == 7:
+            records = ExecuteQuery(
+                "SELECT max_row from outer_site_set WHERE title='本週推薦'")
+
+            maxrow = 1
+            for c in records:
+                maxrow = c['max_row']
+
+            records = ExecuteQuery("""SELECT homepage_set.inner_sort, homepage_set.outer_set, _hcase_img.name as J, _hcase_img.name, _hcase.caption, _hcase.hcase_id, _hcase.hdesigner_id, _hdesigner.name, theme_type, short_desc 
+                            FROM homepage_set
+                            left join _hcase ON _hcase.hcase_id=homepage_set.mapping_id
+                            LEFT JOIN _hcase_img ON _hcase.hcase_id=_hcase_img.hcase_id
+                            LEFT JOIN _hdesigner ON _hcase.hdesigner_id=_hdesigner.hdesigner_id
+                            WHERE homepage_set.onoff='Y'
+                            AND _hcase.onoff='1'
+                            AND is_cover='1'
+                            AND outer_set = (SELECT oss_id from outer_site_set WHERE title='本週推薦')
+                            AND(NOW() BETWEEN homepage_set.start_time AND homepage_set.end_time OR(homepage_set.start_time='0000-00-00 00:00:00' and homepage_set.end_time='0000-00-00 00:00:00') or (homepage_set.start_time is null and homepage_set.end_time is NULL))
+                            ORDER BY inner_sort
+                            LIMIT """ + str(maxrow))
+
+            x["data"] = []
+            for fk in records:
+                a = {'imgUrl': fk['J'], 'link': "https://www.hhh.com.tw/cases/detail/" + str(
+                    fk['hcase_id']) + "/", 'description': fk['caption'], "video": "false", 'txt': fk['short_desc']}
+                x["data"].append(a)
+            # print(x["data"])
+
+        # 粉絲推薦
+        if x['id'] == 8:
+
+            records = ExecuteQuery(
+                "SELECT max_row from outer_site_set WHERE title='粉絲推薦'")
+
+            maxrow = 1
+            for c in records:
+                maxrow = c['max_row']
+
+            records = ExecuteQuery("""SELECT homepage_set.inner_sort, homepage_set.outer_set, _hcase_img.name as J, _hcase_img.name, _hcase.caption, _hcase.hcase_id, _hcase.hdesigner_id, _hdesigner.name, theme_type,short_desc 
+                            FROM homepage_set
+                            left join _hcase ON _hcase.hcase_id=homepage_set.mapping_id
+                            LEFT JOIN _hcase_img ON _hcase.hcase_id=_hcase_img.hcase_id
+                            LEFT JOIN _hdesigner ON _hcase.hdesigner_id=_hdesigner.hdesigner_id
+                            WHERE homepage_set.onoff='Y'
+                            AND _hcase.onoff='1'
+                            AND is_cover='1'
+                            AND outer_set = (SELECT oss_id from outer_site_set WHERE title='粉絲推薦')
+                            AND(NOW() BETWEEN homepage_set.start_time AND homepage_set.end_time OR(homepage_set.start_time='0000-00-00 00:00:00' and homepage_set.end_time='0000-00-00 00:00:00') or (homepage_set.start_time is null and homepage_set.end_time is NULL))
+                            ORDER BY inner_sort
+                            LIMIT """ + str(maxrow))
+
+            x["data"] = []
+            for fk in records:
+                a = {'imgUrl': fk['J'], 'link': "https://www.hhh.com.tw/cases/detail/" + str(
+                    fk['hcase_id']) + "/", 'description': fk['caption'], "video": "false",'txt':fk['short_desc']}
+                x["data"].append(a)
+            # print(x["data"])
+
+        if x['id'] == 9:
+            records = ExecuteQuery(
+                "SELECT id, (case when youtube_title = '' OR youtube_title IS NULL then (SELECT title FROM _hvideo ORDER BY hvideo_id DESC LIMIT 1) ELSE youtube_title END) T, (case when youtube_id = '' OR youtube_id IS NULL then (SELECT iframe FROM _hvideo ORDER BY hvideo_id DESC LIMIT 1) ELSE youtube_id end) Y FROM site_setup")
+
+            for c in records:
+                x['title'] = ""
+                if isinstance(c['T'], bytearray):
+                    x['title'] = str(c['T'].decode('utf8'))
+                else:
+                    x['title'] = str(c['T'])
+                x['yt'] = extract.video_id(str(c['Y']))
+                # print(id)
+
+        if x['id'] == 10:
+            records = ExecuteQuery(
+                "SELECT all_search_tag ast FROM site_setup")
+
+            x["data"] = []
+            for c in records:
+                x["data"] = c['ast'].split(',')
+                # print(id)
+
+    # print(jData)
+    if not os.path.exists(hhhHomePath):
+        os.mkdir(hhhHomePath)
+    with open(hhhHomePath+'/json/' + filename, 'w', encoding='utf-8') as f:
+        json.dump(jData, f, ensure_ascii=False, indent=4)
+
+    return jData
+
+
+""" if __name__ == "__main__":
+    uvicorn.run(app, host="0.0.0.0", port=8000) """

+ 435 - 0
genjson/index.json

@@ -0,0 +1,435 @@
+[
+    {
+        "_comment": "頂部輪播區",
+        "id": 0,
+        "block": "topCarousel",
+        "data": [
+            {
+                "imgUrl": "https://images.hhh.com.tw/uploads/_had/adlogo_15664_1619582521.jpg",
+                "link": "https://hhh.com.tw/designer-index.php?designer_id=23",
+                "DimgUrl": "https://images.hhh.com.tw/uploads/_had/adlogo_15664_1619582509.jpg",
+                "webp": "https://images.hhh.com.tw/uploads/_had/adlogo_15664_1619582537.webp"
+            },
+            {
+                "imgUrl": "https://images.hhh.com.tw/uploads/_had/adlogo_15672_1605260703.jpg",
+                "link": "https://hhh.com.tw/designer-index.php?designer_id=28",
+                "DimgUrl": "https://images.hhh.com.tw/uploads/_had/adlogo_15672_1605260690.jpg",
+                "webp": "https://images.hhh.com.tw/uploads/_had/adlogo_15672_1605260747.webp"
+            },
+            {
+                "imgUrl": "https://images.hhh.com.tw/uploads/_had/adlogo_15662_1607045625.jpg",
+                "link": "https://hhh.com.tw/designer-index.php?designer_id=447",
+                "DimgUrl": "https://images.hhh.com.tw/uploads/_had/adlogo_15662_1607045611.jpg",
+                "webp": "https://images.hhh.com.tw/uploads/_had/adlogo_15662_1607045687.webp"
+            },
+            {
+                "imgUrl": "https://images.hhh.com.tw/uploads/_had/adlogo_15673_1603096869.jpg",
+                "link": "https://hhh.com.tw/designer-index.php?designer_id=31",
+                "DimgUrl": "https://images.hhh.com.tw/uploads/_had/adlogo_15673_1603096869.jpg",
+                "webp": ""
+            },
+            {
+                "imgUrl": "https://images.hhh.com.tw/uploads/_had/adlogo_16076_1625209654.jpg",
+                "link": "https://hhh.com.tw/designers/cases/586/1-page/new-sort/",
+                "DimgUrl": "https://images.hhh.com.tw/uploads/_had/adlogo_16076_1625209580.jpg",
+                "webp": "https://images.hhh.com.tw/uploads/_had/adlogo_16076_1625209663.webp"
+            },
+            {
+                "imgUrl": "https://images.hhh.com.tw/uploads/_had/adlogo_15666_1627961097.jpg",
+                "link": "https://hhh.com.tw/designer-index.php?designer_id=32",
+                "DimgUrl": "https://images.hhh.com.tw/uploads/_had/adlogo_15666_1627961071.jpg",
+                "webp": "https://images.hhh.com.tw/uploads/_had/adlogo_15666_1627961107.webp"
+            },
+            {
+                "imgUrl": "https://images.hhh.com.tw/uploads/_had/adlogo_16002_1617866880.jpg",
+                "link": "https://hhh.com.tw/brand-index.php?brand_id=202",
+                "DimgUrl": "https://images.hhh.com.tw/uploads/_had/adlogo_16002_1617866862.jpg",
+                "webp": "https://images.hhh.com.tw/uploads/_had/adlogo_16002_1617866888.webp"
+            },
+            {
+                "imgUrl": "https://images.hhh.com.tw/uploads/_had/adlogo_16051_1623138395.png",
+                "link": "https://hhh.com.tw/designers/cases/33/1-page/new-sort/",
+                "DimgUrl": "https://images.hhh.com.tw/uploads/_had/adlogo_16051_1623138372.png",
+                "webp": "https://images.hhh.com.tw/uploads/_had/adlogo_16051_1623141226.png"
+            },
+            {
+                "imgUrl": "https://images.hhh.com.tw/uploads/_had/adlogo_16108_1628669736.jpg",
+                "link": "https://hhh.com.tw/designers/cases/452/1-page/new-sort/",
+                "DimgUrl": "https://images.hhh.com.tw/uploads/_had/adlogo_16108_1628669721.jpg",
+                "webp": "https://images.hhh.com.tw/uploads/_had/adlogo_16108_1628669767.webp"
+            },
+            {
+                "imgUrl": "https://images.hhh.com.tw/uploads/_had/adlogo_16115_1629356235.png",
+                "link": "https://hhh.com.tw/designers/cases/438/1-page/new-sort/",
+                "DimgUrl": "https://images.hhh.com.tw/uploads/_had/adlogo_16115_1629356225.png",
+                "webp": "https://images.hhh.com.tw/uploads/_had/adlogo_16115_1629356246.webp"
+            },
+            {
+                "imgUrl": "https://images.hhh.com.tw/uploads/_had/adlogo_16138_1631259916.jpg",
+                "link": "https://hhh.com.tw/designers/cases/182/1-page/new-sort/",
+                "DimgUrl": "https://images.hhh.com.tw/uploads/_had/adlogo_16138_1631259909.jpg",
+                "webp": "https://images.hhh.com.tw/uploads/_had/adlogo_16138_1631259938.webp"
+            },
+            {
+                "imgUrl": "https://images.hhh.com.tw/uploads/_had/adlogo_16139_1631597917.jpg",
+                "link": "https://hhh.com.tw/columns/detail/6072/",
+                "DimgUrl": "https://images.hhh.com.tw/uploads/_had/adlogo_16139_1631597907.jpg",
+                "webp": "https://images.hhh.com.tw/uploads/_had/adlogo_16139_1631597927.webp"
+            },
+            {
+                "imgUrl": "https://images.hhh.com.tw/uploads/_had/adlogo_16107_1628644159.jpg",
+                "link": "https://hhh.com.tw/deco/",
+                "DimgUrl": "https://images.hhh.com.tw/uploads/_had/adlogo_16107_1628644143.jpg",
+                "webp": "https://images.hhh.com.tw/uploads/_had/adlogo_16107_1628644166.webp"
+            }
+        ]
+    },
+    {
+        "_comment": "主要輪播區",
+        "id": 1,
+        "block": "sec02",
+        "data": [
+            {
+                "imgUrl": "https://images.hhh.com.tw/uploads/_had/adlogo_15660_1604643433.jpg",
+                "link": "https://hhh.com.tw/designer-index.php?designer_id=28",
+                "DimgUrl": "https://images.hhh.com.tw/uploads/_had/adlogo_15660_1604643425.jpg",
+                "webp": ""
+            },
+            {
+                "imgUrl": "https://images.hhh.com.tw/uploads/_had/adlogo_16057_1631764389.jpg",
+                "link": "https://hhh.com.tw/columns/detail/4290/",
+                "DimgUrl": "https://images.hhh.com.tw/uploads/_had/adlogo_16057_1631764374.jpg",
+                "webp": "https://images.hhh.com.tw/uploads/_had/adlogo_16057_1631764401.webp"
+            },
+            {
+                "imgUrl": "https://images.hhh.com.tw/uploads/_had/adlogo_16093_1629944189.jpg",
+                "link": "https://v.hhh.com.tw/",
+                "DimgUrl": "https://images.hhh.com.tw/uploads/_had/adlogo_16093_1629944183.jpg",
+                "webp": "https://images.hhh.com.tw/uploads/_had/adlogo_16093_1629944200.webp"
+            },
+            {
+                "imgUrl": "https://images.hhh.com.tw/uploads/_had/adlogo_16082_1627804898.jpg",
+                "link": "https://hhh.com.tw/topic/detail/402/",
+                "DimgUrl": "https://images.hhh.com.tw/uploads/_had/adlogo_16082_1627804906.jpg",
+                "webp": "https://images.hhh.com.tw/uploads/_had/adlogo_16082_1627804929.webp"
+            },
+            {
+                "imgUrl": "https://images.hhh.com.tw/uploads/_had/adlogo_16142_1631782259.jpg",
+                "link": "https://event.hhh.com.tw/2021-Top-Brands/page.php?id=182",
+                "DimgUrl": "https://images.hhh.com.tw/uploads/_had/adlogo_16142_1631782224.jpg",
+                "webp": "https://images.hhh.com.tw/uploads/_had/adlogo_16142_1631782273.webp"
+            },
+            {
+                "imgUrl": "https://images.hhh.com.tw/uploads/_had/adlogo_16143_1631782091.jpg",
+                "link": "https://event.hhh.com.tw/topglory/designer_54.html",
+                "DimgUrl": "https://images.hhh.com.tw/uploads/_had/adlogo_16143_1631782085.jpg",
+                "webp": "https://images.hhh.com.tw/uploads/_had/adlogo_16143_1631782161.webp"
+            },
+            {
+                "imgUrl": "https://images.hhh.com.tw/uploads/_had/adlogo_16140_1631782123.jpg",
+                "link": "https://event.hhh.com.tw/topglory/designer_382.html",
+                "DimgUrl": "https://images.hhh.com.tw/uploads/_had/adlogo_16140_1631782117.jpg",
+                "webp": "https://images.hhh.com.tw/uploads/_had/adlogo_16140_1631782136.webp"
+            },
+            {
+                "imgUrl": "https://images.hhh.com.tw/uploads/_had/adlogo_16141_1631782111.jpg",
+                "link": "https://hhh.com.tw/designers/cases/441/1-page/new-sort/",
+                "DimgUrl": "https://images.hhh.com.tw/uploads/_had/adlogo_16141_1631782101.jpg",
+                "webp": "https://images.hhh.com.tw/uploads/_had/adlogo_16141_1631782147.webp"
+            },
+            {
+                "imgUrl": "https://images.hhh.com.tw/uploads/_had/adlogo_16144_1631782077.jpg",
+                "link": "https://event.hhh.com.tw/2021-Most-Favorite-Designers/case.php?id=131",
+                "DimgUrl": "https://images.hhh.com.tw/uploads/_had/adlogo_16144_1631782071.jpg",
+                "webp": "https://images.hhh.com.tw/uploads/_had/adlogo_16144_1631782178.webp"
+            },
+            {
+                "imgUrl": "https://images.hhh.com.tw/uploads/_had/adlogo_16145_1631782064.jpg",
+                "link": "https://event.hhh.com.tw/2021-Most-Favorite-Designers/case.php?id=688",
+                "DimgUrl": "https://images.hhh.com.tw/uploads/_had/adlogo_16145_1631782040.jpg",
+                "webp": "https://images.hhh.com.tw/uploads/_had/adlogo_16145_1631782190.webp"
+            },
+            {
+                "imgUrl": "https://images.hhh.com.tw/uploads/_had/adlogo_16099_1627623476.jpg",
+                "link": "https://hhh.com.tw/deco/",
+                "DimgUrl": "https://images.hhh.com.tw/uploads/_had/adlogo_16099_1627623458.jpg",
+                "webp": "https://images.hhh.com.tw/uploads/_had/adlogo_16099_1627623493.webp"
+            },
+            {
+                "imgUrl": "https://images.hhh.com.tw/uploads/_had/adlogo_15781_1601366572.jpg",
+                "link": "https://hhh.com.tw/softouch",
+                "DimgUrl": "https://images.hhh.com.tw/uploads/_had/adlogo_15781_1601366572.jpg",
+                "webp": ""
+            }
+        ]
+    },
+    {
+        "_comment": "tab區塊-最夯設計, 影音實錄, 專欄文章",
+        "id": 2,
+        "block": "sec03",
+        "data": [
+            {
+                "tab": "最夯設計",
+                "data": [
+                    {
+                        "imgUrl": "https://m.hhh.com.tw/upload/_hcase_img/name_13759_20210917173552.jpg",
+                        "link": "https://www.hhh.com.tw/cases/detail/13759/",
+                        "description": "文居│現代美式風│95坪"
+                    },
+                    {
+                        "imgUrl": "https://m.hhh.com.tw/upload/_hcase_img/name_13754_20210917152545.jpg",
+                        "link": "https://www.hhh.com.tw/cases/detail/13754/",
+                        "description": "詼-鵲|現代禪風|32坪"
+                    },
+                    {
+                        "imgUrl": "https://m.hhh.com.tw/upload/_hcase_img/name_13753_20210917145902.jpg",
+                        "link": "https://www.hhh.com.tw/cases/detail/13753/",
+                        "description": "率性況味 定格靜境|工業風|28坪"
+                    }
+                ]
+            },
+            {
+                "tab": "影音實錄",
+                "data": [
+                    {
+                        "imgUrl": "https://img.youtube.com/vi/bN2cRRkke_c/hqdefault.jpg",
+                        "link": "https://www.hhh.com.tw/video-post.php?id=4184",
+                        "description": "全視屏居家辦公新體驗  沉浸感影音收視再進化"
+                    },
+                    {
+                        "imgUrl": "https://img.youtube.com/vi/iW65jWwAX_s/hqdefault.jpg",
+                        "link": "https://www.hhh.com.tw/video-post.php?id=4183",
+                        "description": "雅致英式 奢華中的平靜氣度"
+                    },
+                    {
+                        "imgUrl": "https://img.youtube.com/vi/me4KutyUoT4/hqdefault.jpg",
+                        "link": "https://www.hhh.com.tw/video-post.php?id=4182",
+                        "description": "居家改造大公開 我的完整 因為有你|LG x Sunny 王陽明"
+                    }
+                ]
+            },
+            {
+                "tab": "專欄文章",
+                "data": [
+                    {
+                        "imgUrl": "https://images.hhh.com.tw/uploads/_hcolumn_orig/point-index04_474.jpg",
+                        "link": "https://www.hhh.com.tw/column/detail/6083/",
+                        "description": "【風水特輯】門對門解法?鏤空樓梯是禁忌?最實用的風水避雷指南!"
+                    },
+                    {
+                        "imgUrl": "https://images.hhh.com.tw/uploads/_hcolumn_orig/point-index02_283.jpg",
+                        "link": "https://www.hhh.com.tw/column/detail/6081/",
+                        "description": "化身高雅貴族 走進電影中的歐風居家!"
+                    },
+                    {
+                        "imgUrl": "https://images.hhh.com.tw/uploads/_hcolumn_orig/point02_282_01.jpg",
+                        "link": "https://www.hhh.com.tw/column/detail/6080/",
+                        "description": "【好宅開箱分享】重整格局,讓陽光走進家!超舒適北歐療癒宅開箱記"
+                    }
+                ]
+            }
+        ]
+    },
+    {
+        "_comment": "主題企劃區",
+        "id": 3,
+        "block": "sec06",
+        "data": [
+            {
+                "imgUrl": "https://images.hhh.com.tw/uploads/_hcase/designer546_81_07.jpg",
+                "link": "https://www.hhh.com.tw/case/13320/detail/"
+            },
+            {
+                "imgUrl": "https://images.hhh.com.tw/uploads/_hcase/designer737_03_01.jpg",
+                "link": "https://www.hhh.com.tw/case/12997/detail/"
+            },
+            {
+                "imgUrl": "https://images.hhh.com.tw/uploads/_hcase/name_12422_20200601145042.jpg",
+                "link": "https://www.hhh.com.tw/case/12422/detail/"
+            },
+            {
+                "imgUrl": "https://images.hhh.com.tw/uploads/_hcolumn_orig/point-index02_241.jpg",
+                "link": "https://www.hhh.com.tw/column/5926/detail/"
+            },
+            {
+                "imgUrl": "https://cloud.hhh.com.tw/upload/_hcolumn/clogo_5763_20210528143431.jpg",
+                "link": "https://www.hhh.com.tw/column/5763/detail/"
+            },
+            {
+                "imgUrl": "https://images.hhh.com.tw/uploads/_hcolumn_orig/point-index01_312.jpg",
+                "link": "https://www.hhh.com.tw/column/5650/detail/"
+            }
+        ]
+    },
+    {
+        "_comment": "編輯精選",
+        "id": 4,
+        "block": "sec07",
+        "data": [
+            {
+                "imgUrl": "https://images.hhh.com.tw/uploads/_hcolumn_orig/point-index01_356.jpg",
+                "link": "https://www.hhh.com.tw/columns/detail/6072/",
+                "description": "2022得利絕美年度色「晴空藍Bright Skies」!為空間注入清新能量,完美晴空就在身旁"
+            },
+            {
+                "imgUrl": "https://images.hhh.com.tw/uploads/_hcolumn_orig/point-index05_284.jpg",
+                "link": "https://www.hhh.com.tw/columns/detail/6076/",
+                "description": "揮別單調!超吸睛衛浴配件單品色彩學"
+            },
+            {
+                "imgUrl": "https://images.hhh.com.tw/uploads/_hcolumn_orig/point-index05_283.jpg",
+                "link": "https://www.hhh.com.tw/columns/detail/6064/",
+                "description": "懶人居家必備智能神器!下班好累不想動,就交給Google Nest 智慧音箱"
+            }
+        ]
+    },
+    {
+        "_comment": "活動頁banners區",
+        "id": 5,
+        "block": "sec08",
+        "data": [
+            {
+                "imgUrl": "https://images.hhh.com.tw/uploads/_had/adlogo_15356_1588832058.jpg",
+                "link": "https://event.hhh.com.tw/2021-Most-Favorite-Designers/?utm_source=INDEX_BANNER&adid=15356"
+            },
+            {
+                "imgUrl": "https://images.hhh.com.tw/uploads/_had/adlogo_15927_1627805018.jpg",
+                "link": "https://hhh.com.tw/topic/detail/402/"
+            },
+            {
+                "imgUrl": "https://images.hhh.com.tw/uploads/_had/adlogo_16106_1628489482.jpg",
+                "link": "https://c.hhh.com.tw/?utm_source=homepage&utm_medium=banner&utm_campaign=0809"
+            }
+        ]
+    },
+    {
+        "_comment": "來選好物區",
+        "id": 6,
+        "block": "sec09",
+        "data": [
+            {
+                "imgUrl": "https://cloud.hhh.com.tw/upload/_hproduct_img/name_2384_20210803162337.png",
+                "link": "https://www.hhh.com.tw/product-post.php?id=2384/",
+                "description": "Sunline 特殊型塑鋁百葉窗"
+            },
+            {
+                "imgUrl": "https://cloud.hhh.com.tw/upload/_hproduct_img/name_2383_20210816182839.png",
+                "link": "https://www.hhh.com.tw/product-post.php?id=2383/",
+                "description": "Sunline 折疊門"
+            },
+            {
+                "imgUrl": "https://cloud.hhh.com.tw/upload/_hproduct_img/name_2382_20210803161842.png",
+                "link": "https://www.hhh.com.tw/product-post.php?id=2382/",
+                "description": "Sunline 推拉門"
+            },
+            {
+                "imgUrl": "https://cloud.hhh.com.tw/upload/_hproduct_img/name_2381_20210527160349.png",
+                "link": "https://www.hhh.com.tw/product-post.php?id=2381/",
+                "description": "MIT鐵桌腳"
+            },
+            {
+                "imgUrl": "https://cloud.hhh.com.tw/upload/_hproduct_img/name_2380_20210527160130.png",
+                "link": "https://www.hhh.com.tw/product-post.php?id=2380/",
+                "description": "實木長凳"
+            },
+            {
+                "imgUrl": "https://cloud.hhh.com.tw/upload/_hproduct_img/name_2379_20210527155756.png",
+                "link": "https://www.hhh.com.tw/product-post.php?id=2379/",
+                "description": "實木小家具"
+            }
+        ]
+    },
+    {
+        "_comment": "本週推薦",
+        "id": 7,
+        "block": "sec10",
+        "data": [
+            {
+                "imgUrl": "https://images.hhh.com.tw/uploads/_hcase/name_12458_20200616152204.jpg",
+                "link": "https://www.hhh.com.tw/cases/detail/12458/",
+                "description": "簡約沐光宅 暖色調營造家的恬靜溫度",
+                "video": "false"
+            },
+            {
+                "imgUrl": "https://images.hhh.com.tw/uploads/_hcase/name_11965_20191231153835.jpg",
+                "link": "https://www.hhh.com.tw/cases/detail/11965/",
+                "description": "連結城市風華 坐擁浪漫夜景(上)",
+                "video": "false"
+            },
+            {
+                "imgUrl": "https://images.hhh.com.tw/uploads/_hcase/designer519_26_02.jpg",
+                "link": "https://www.hhh.com.tw/cases/detail/13088/",
+                "description": "整合鄉村元素 營造日常的暖馨溫度|30坪|3+1 房、2廳、2衛",
+                "video": "false"
+            },
+            {
+                "imgUrl": "https://cloud.hhh.com.tw/upload/_hcase_img/name_13319_20210528165925.jpg",
+                "link": "https://www.hhh.com.tw/cases/detail/13319/",
+                "description": "現代日式混搭佐日光 構畫敞朗質感好生活",
+                "video": "false"
+            },
+            {
+                "imgUrl": "https://m.hhh.com.tw/upload/_hcase_img/name_13728_20210913165321.jpg",
+                "link": "https://www.hhh.com.tw/cases/detail/13728/",
+                "description": "微光島嶼。Dusky Island│現代風│50坪",
+                "video": "false"
+            },
+            {
+                "imgUrl": "https://m.hhh.com.tw/upload/_hcase_img/name_13737_20210914183731.jpg",
+                "link": "https://www.hhh.com.tw/cases/detail/13737/",
+                "description": "譜出音符律動的宅邸 回家就像歌劇院|現代風|26坪",
+                "video": "false"
+            }
+        ]
+    },
+    {
+        "_comment": "粉絲推薦",
+        "id": 8,
+        "block": "sec11",
+        "data": [
+            {
+                "imgUrl": "https://images.hhh.com.tw/uploads/_hcase/name_12458_20200616152204.jpg",
+                "link": "https://www.hhh.com.tw/cases/detail/12458/",
+                "description": "簡約沐光宅 暖色調營造家的恬靜溫度",
+                "video": "false"
+            },
+            {
+                "imgUrl": "https://images.hhh.com.tw/uploads/_hcase/name_11965_20191231153835.jpg",
+                "link": "https://www.hhh.com.tw/cases/detail/11965/",
+                "description": "連結城市風華 坐擁浪漫夜景(上)",
+                "video": "false"
+            },
+            {
+                "imgUrl": "https://images.hhh.com.tw/uploads/_hcase/designer519_26_02.jpg",
+                "link": "https://www.hhh.com.tw/cases/detail/13088/",
+                "description": "整合鄉村元素 營造日常的暖馨溫度|30坪|3+1 房、2廳、2衛",
+                "video": "false"
+            },
+            {
+                "imgUrl": "https://cloud.hhh.com.tw/upload/_hcase_img/name_13319_20210528165925.jpg",
+                "link": "https://www.hhh.com.tw/cases/detail/13319/",
+                "description": "現代日式混搭佐日光 構畫敞朗質感好生活",
+                "video": "false"
+            },
+            {
+                "imgUrl": "https://m.hhh.com.tw/upload/_hcase_img/name_13728_20210913165321.jpg",
+                "link": "https://www.hhh.com.tw/cases/detail/13728/",
+                "description": "微光島嶼。Dusky Island│現代風│50坪",
+                "video": "false"
+            },
+            {
+                "imgUrl": "https://m.hhh.com.tw/upload/_hcase_img/name_13737_20210914183731.jpg",
+                "link": "https://www.hhh.com.tw/cases/detail/13737/",
+                "description": "譜出音符律動的宅邸 回家就像歌劇院|現代風|26坪",
+                "video": "false"
+            }
+        ]
+    },
+    {
+        "_comment": "video最新影音區",
+        "id": 9,
+        "block": "video",
+        "title": "全視屏居家辦公新體驗  沉浸感影音收視再進化",
+        "yt": "bN2cRRkke_c"
+    }
+]

+ 9 - 0
genjson/requirements.txt

@@ -0,0 +1,9 @@
+dataset==1.5.0
+pytrends==4.7.3
+pytube==11.0.1
+telegram==0.0.1
+redis==3.5.3
+opencc_python_reimplemented==0.1.6
+fastapi==0.68.1
+mysql_connector_repackaged==0.3.1
+opencc==1.1.2

+ 288 - 0
genjson/test.py

@@ -0,0 +1,288 @@
+
+import os
+from typing import Optional
+from dataset.util import ResultIter
+from fastapi import FastAPI
+from fastapi.middleware.cors import CORSMiddleware
+
+from pytrends.request import TrendReq
+from datetime import tzinfo
+import datetime
+import mysql.connector
+from mysql.connector import Error
+
+import json
+from pytube import extract
+
+app = FastAPI()
+
+origins = [
+    "*"
+]
+app.add_middleware(
+    CORSMiddleware,
+    allow_origins=origins,
+    allow_credentials=True,
+    allow_methods=["*"],
+    allow_headers=["*"],
+)
+
+hhhHomePath = '../hhh-home-mb'
+
+
+def ExecuteQuery(isql):
+    connection = mysql.connector.connect(
+        host='hhh-v57.cmab1ctkglka.ap-northeast-2.rds.amazonaws.com',
+        database='xoops',
+        user='hhh7796hhh',
+        password='lYmWsu^ujcA1'
+    )
+    cursor = connection.cursor(dictionary=True)
+    cursor.execute(isql)
+    if cursor.rowcount == -1:
+        return cursor.fetchall()
+    else:
+        connection.commit()
+        return cursor.rowcount
+
+
+def ExecuteCmd(isql):
+    connection = mysql.connector.connect(
+        host='hhh-v57.cmab1ctkglka.ap-northeast-2.rds.amazonaws.com',
+        database='xoops',
+        user='hhh7796hhh',
+        password='lYmWsu^ujcA1'
+    )
+    cursor = connection.cursor(dictionary=True)
+    cursor.execute(isql)
+    print(cursor.rowcount)
+    connection.commit()
+    return None
+
+
+jData = json.load(open(hhhHomePath+'/json/data.json', encoding='utf8'))
+
+records = ExecuteQuery("SELECT * FROM _had where (now() between start_time and end_time or ( start_time is null and end_time is null) or ( start_time = '0000-00-00 00:00:00' and end_time = '0000-00-00 00:00:00')) and onoff='1' and adtype like '首八大%' ")
+
+for x in jData:
+
+    # 頂部輪播區-新刊頭
+    if x['id'] == 0:
+        records = ExecuteQuery("""SELECT adlogo lo,adlogo_mobile mlo, adhref lk, adlogo_mobile_webp lomwebp FROM _had
+                    WHERE adtype LIKE '新刊頭%'
+                    AND onoff='1'
+                    AND(NOW() BETWEEN start_time AND end_time OR(start_time='0000-00-00 00:00:00' and end_time='0000-00-00 00:00:00') or (start_time is null and end_time is NULL))
+                    ORDER BY cast(SUBSTR(adtype,4) AS DECIMAL)""")
+
+        x["data"] = []
+        for c in records:
+            a = {'imgUrl': c['mlo'], 'link': str(
+                c['lk']), 'DimgUrl': c['lo'], 'webp': str(c['lomwebp'])}
+            x["data"].append(a)
+        # print(x["data"])
+
+    # 主要輪播區-首八大
+    if x['id'] == 1:
+        records = ExecuteQuery("""SELECT adlogo lo,adlogo_mobile mlo, adhref lk, adlogo_mobile_webp lomwebp FROM _had
+                    WHERE adtype LIKE '首八大%'
+                    AND onoff='1'
+                    AND(NOW() BETWEEN start_time AND end_time OR(start_time='0000-00-00 00:00:00' and end_time='0000-00-00 00:00:00') or (start_time is null and end_time is NULL))
+                    ORDER BY cast(SUBSTR(adtype,4) AS DECIMAL)""")
+
+        x["data"] = []
+        for c in records:
+            a = {'imgUrl': c['mlo'], 'link': str(
+                c['lk']), 'DimgUrl': c['lo'], 'webp': str(c['lomwebp'])}
+            x["data"].append(a)
+        # print(x["data"])
+
+    #tab區塊-最夯設計, 影音實錄, 專欄文章
+    if x['id'] == 2:
+        x["data"] = []
+        records = ExecuteQuery("""SELECT caption TT ,cover IMG, CONCAT('https://www.hhh.com.tw/cases/detail/',hcase_id,'/') LK, short_desc txt
+                        from _hcase
+                        left join _hdesigner ON _hcase.hdesigner_id=_hdesigner.hdesigner_id
+                        WHERE
+                        _hcase.onoff='1' AND _hdesigner.onoff='1'
+                        AND(NOW() > sdate)
+                        ORDER BY hcase_id DESC
+                        LIMIT 3""")
+        a = {'tab': '最夯設計', 'data': []}
+        for c in records:
+            ad = {'imgUrl': c['IMG'], 'link': c['LK'],
+                    'description': c['TT'], 'txt': c['txt']}
+            a['data'].append(ad)
+        x["data"].append(a)
+
+        records = ExecuteQuery("""SELECT title TT,iframe IMG , CONCAT('https://www.hhh.com.tw/video-post.php?id=',hvideo_id) LK , name
+                        from _hvideo
+                        ORDER BY hvideo_id DESC
+                        LIMIT 3""")
+        a = {'tab': '影音實錄', 'data': []}
+        for c in records:
+            tid = extract.video_id(c['IMG'])
+            timg = "https://img.youtube.com/vi/" + tid+"/hqdefault.jpg"
+            ad = {'imgUrl': timg, 'link': c['LK'],
+                    'description': c['name'], 'txt': c['TT']}
+            a['data'].append(ad)
+        x["data"].append(a)
+
+        records = ExecuteQuery("""SELECT ctitle TT,clogo IMG, CONCAT('https://www.hhh.com.tw/column/detail/',hcolumn_id,'/') LK, cdesc
+                        from _hcolumn
+                        WHERE onoff='1'
+                        AND NOW() > sdate
+                        ORDER BY hcolumn_id DESC
+                        LIMIT 3""")
+        a = {'tab': '專欄文章', 'data': []}
+        for c in records:
+            ad = {'imgUrl': c['IMG'], 'link': c['LK'],
+                    'description': c['TT'], 'txt': c['cdesc']}
+            a['data'].append(ad)
+        x["data"].append(a)
+        # print(x["data"])
+
+    # 主題企劃區
+    if x['id'] == 3:
+        records = ExecuteQuery("""SELECT logo lo, CONCAT('https://www.hhh.com.tw/topic/detail/',htopic_id,'/') lk, `desc`, title FROM _htopic
+WHERE onoff = '1'
+ORDER BY htopic_id DESC limit 3""")
+
+        x["data"] = []
+        for c in records:
+            a = {'imgUrl': c['lo'], 'link': str(
+                c['lk']), 'video': 'false', 'description': c['desc'], 'title': c['title']}
+            x["data"].append(a)
+        # print(x["data"])
+
+    # 編輯精選
+    if x['id'] == 4:
+        records = ExecuteQuery("""SELECT hcolumn_id, ctitle, clogo,cdesc
+                            FROM homepage_set
+                            LEFT JOIN _hcolumn ON mapping_id = hcolumn_id
+                            WHERE outer_set=8
+                            AND homepage_set.onoff='Y'
+                            AND(NOW() BETWEEN homepage_set.start_time AND homepage_set.end_time OR(homepage_set.start_time='0000-00-00 00:00:00' and homepage_set.end_time='0000-00-00 00:00:00') or (homepage_set.start_time is null and homepage_set.end_time is NULL))
+                            ORDER BY inner_sort""")
+
+        x["data"] = []
+        for c in records:
+            a = {'imgUrl': c['clogo'], 'link': "https://www.hhh.com.tw/columns/detail/" + str(
+                c['hcolumn_id']) + "/", 'description': c['ctitle'], 'video': 'false', 'txt': c['cdesc']}
+            x["data"].append(a)
+        # print(x["data"])
+
+    # 來選好物區
+    if x['id'] == 6:
+
+        records = ExecuteQuery(
+            "SELECT max_row from outer_site_set WHERE title='來選好貨'")
+
+        maxrow = 1
+        for c in records:
+            maxrow = c['max_row']
+
+        records = ExecuteQuery("""SELECT id, cover, name
+                            FROM _hproduct
+                            where onoff ='1'
+                            ORDER BY id desc
+                            LIMIT """ + str(maxrow))
+
+        x["data"] = []
+        for fk in records:
+            a = {'imgUrl': fk['cover'], 'link': "https://www.hhh.com.tw/product-post.php?id=" + str(
+                fk['id']) + "/", 'description': fk['name'], 'video': 'false'}
+            x["data"].append(a)
+        # print(x["data"])
+
+    # 本週推薦
+    if x['id'] == 7:
+        records = ExecuteQuery(
+            "SELECT max_row from outer_site_set WHERE title='本週推薦'")
+
+        maxrow = 1
+        for c in records:
+            maxrow = c['max_row']
+
+        records = ExecuteQuery("""SELECT homepage_set.inner_sort, homepage_set.outer_set, _hcase_img.name as J, _hcase_img.name, _hcase.caption, _hcase.hcase_id, _hcase.hdesigner_id, _hdesigner.name, theme_type, short_desc 
+                        FROM homepage_set
+                        left join _hcase ON _hcase.hcase_id=homepage_set.mapping_id
+                        LEFT JOIN _hcase_img ON _hcase.hcase_id=_hcase_img.hcase_id
+                        LEFT JOIN _hdesigner ON _hcase.hdesigner_id=_hdesigner.hdesigner_id
+                        WHERE homepage_set.onoff='Y'
+                        AND _hcase.onoff='1'
+                        AND is_cover='1'
+                        AND outer_set = (SELECT oss_id from outer_site_set WHERE title='本週推薦')
+                        AND(NOW() BETWEEN homepage_set.start_time AND homepage_set.end_time OR(homepage_set.start_time='0000-00-00 00:00:00' and homepage_set.end_time='0000-00-00 00:00:00') or (homepage_set.start_time is null and homepage_set.end_time is NULL))
+                        ORDER BY inner_sort
+                        LIMIT """ + str(maxrow))
+
+        x["data"] = []
+        for fk in records:
+            a = {'imgUrl': fk['J'], 'link': "https://www.hhh.com.tw/cases/detail/" + str(
+                fk['hcase_id']) + "/", 'description': fk['caption'], "video": "false", 'txt': fk['short_desc']}
+            x["data"].append(a)
+        # print(x["data"])
+
+    # 粉絲推薦
+    if x['id'] == 8:
+
+        records = ExecuteQuery(
+            "SELECT max_row from outer_site_set WHERE title='粉絲推薦'")
+
+        maxrow = 1
+        for c in records:
+            maxrow = c['max_row']
+
+        records = ExecuteQuery("""SELECT homepage_set.inner_sort, homepage_set.outer_set, _hcase_img.name as J, _hcase_img.name, _hcase.caption, _hcase.hcase_id, _hcase.hdesigner_id, _hdesigner.name, theme_type,short_desc 
+                        FROM homepage_set
+                        left join _hcase ON _hcase.hcase_id=homepage_set.mapping_id
+                        LEFT JOIN _hcase_img ON _hcase.hcase_id=_hcase_img.hcase_id
+                        LEFT JOIN _hdesigner ON _hcase.hdesigner_id=_hdesigner.hdesigner_id
+                        WHERE homepage_set.onoff='Y'
+                        AND _hcase.onoff='1'
+                        AND is_cover='1'
+                        AND outer_set = (SELECT oss_id from outer_site_set WHERE title='粉絲推薦')
+                        AND(NOW() BETWEEN homepage_set.start_time AND homepage_set.end_time OR(homepage_set.start_time='0000-00-00 00:00:00' and homepage_set.end_time='0000-00-00 00:00:00') or (homepage_set.start_time is null and homepage_set.end_time is NULL))
+                        ORDER BY inner_sort
+                        LIMIT """ + str(maxrow))
+
+        x["data"] = []
+        for fk in records:
+            a = {'imgUrl': fk['J'], 'link': "https://www.hhh.com.tw/cases/detail/" + str(
+                fk['hcase_id']) + "/", 'description': fk['caption'], "video": "false",'txt':fk['short_desc']}
+            x["data"].append(a)
+        # print(x["data"])
+
+    if x['id'] == 9:
+        records = ExecuteQuery(
+            "SELECT id, (case when youtube_title = '' OR youtube_title IS NULL then (SELECT title FROM _hvideo ORDER BY hvideo_id DESC LIMIT 1) ELSE youtube_title END) T, (case when youtube_id = '' OR youtube_id IS NULL then (SELECT iframe FROM _hvideo ORDER BY hvideo_id DESC LIMIT 1) ELSE youtube_id end) Y FROM site_setup")
+
+        for c in records:
+            x['title'] = ""
+            if isinstance(c['T'], bytearray):
+                x['title'] = str(c['T'].decode('utf8'))
+            else:
+                x['title'] = str(c['T'])
+            x['yt'] = extract.video_id(str(c['Y']))
+            # print(id)
+
+    if x['id'] == 10:
+        records = ExecuteQuery(
+            "SELECT all_search_tag ast FROM site_setup")
+
+        x["data"] = []
+        for c in records:
+            x["data"] = c['ast'].split(',')
+            # print(id)
+
+# print(jData)
+""" if not os.path.exists(hhhHomePath):
+    os.mkdir(hhhHomePath)
+with open(hhhHomePath+'/json/' + filename, 'w', encoding='utf-8') as f:
+    json.dump(jData, f, ensure_ascii=False, indent=4) """
+
+print(jData)
+
+
+""" if __name__ == "__main__":
+    uvicorn.run(app, host="0.0.0.0", port=8000) """

+ 0 - 0
genjson/tmp.py


+ 356 - 0
hhh-home-mb/json/data.json

@@ -0,0 +1,356 @@
+[
+    {
+        "_comment": "頂部輪播區",
+        "id": 0,
+        "block": "topCarousel",
+        "data": [
+            {
+                "imgUrl": "https://images.hhh.com.tw/uploads/_had/adlogo_15662_1607045683.webp",
+                "webp": "https://images.hhh.com.tw/uploads/_had/adlogo_15662_1607045683.webp",
+                "link": "https://hhh.com.tw/designers/cases/447/1-page/new-sort/"
+            },
+            {
+                "imgUrl": "https://images.hhh.com.tw/uploads/_had/adlogo_15673_1603855335.webp",
+                "webp": "https://images.hhh.com.tw/uploads/_had/adlogo_15673_1603855335.webp",
+                "link": "https://hhh.com.tw/designers/cases/31/1-page/new-sort/"
+            },
+            {
+                "imgUrl": "https://images.hhh.com.tw/uploads/_had/adlogo_16107_1628644163.webp",
+                "webp": "https://images.hhh.com.tw/uploads/_had/adlogo_16107_1628644163.webp",
+                "link": "https://hhh.com.tw/deco/"
+            },
+            {
+                "imgUrl": "https://images.hhh.com.tw/uploads/_had/adlogo_16051_1623141203.png",
+                "webp":  "https://images.hhh.com.tw/uploads/_had/adlogo_16051_1623141203.png",
+                "link": "https://hhh.com.tw/designers/cases/33/1-page/new-sort/"
+            },
+            {
+                "imgUrl": "https://images.hhh.com.tw/uploads/_had/adlogo_16115_1629356240.webp",
+                "webp":  "https://images.hhh.com.tw/uploads/_had/adlogo_16115_1629356240.webp",
+                "link": "https://hhh.com.tw/designers/cases/438/1-page/new-sort/"
+            },
+            {
+                "imgUrl": "https://images.hhh.com.tw/uploads/_had/adlogo_16115_1629356240.webp",
+                "webp":  "https://images.hhh.com.tw/uploads/_had/adlogo_16115_1629356240.webp",
+                "link": "https://hhh.com.tw/designers/cases/438/1-page/new-sort/"
+            }
+        ]
+    }, 
+    {
+        "_comment": "主要輪播區",
+        "id": 1,
+        "block": "sec02",
+        "data": [
+            {
+                "imgUrl": "https://images.hhh.com.tw/uploads/_had/adlogo_16057_1629084955.jpg",
+                "webp": "https://images.hhh.com.tw/uploads/_had/adlogo_16057_1629084955.jpg",
+                "link": "https://hhh.com.tw/columns/detail/2963/"
+            },
+            {
+                "imgUrl": "https://images.hhh.com.tw/uploads/_had/adlogo_15660_1604643433.jpg",
+                "webp": "https://images.hhh.com.tw/uploads/_had/adlogo_15660_1604643433.jpg",
+                "link": "https://hhh.com.tw/designers/cases/28/1-page/new-sort/"
+            },
+            {
+                "imgUrl": "https://images.hhh.com.tw/uploads/_had/adlogo_16110_1628768668.jpg",
+                "webp": "https://images.hhh.com.tw/uploads/_had/adlogo_16110_1628768668.jpg",
+                "link": "https://event.hhh.com.tw/topglory/designer_523.html"
+            },
+            {
+                "imgUrl": "https://images.hhh.com.tw/uploads/_had/adlogo_15781_1601366572.jpg",
+                "webp": "https://images.hhh.com.tw/uploads/_had/adlogo_15781_1601366572.jpg",
+                "link": "https://hhh.com.tw/softouch"
+            },
+            {
+                "imgUrl": "https://images.hhh.com.tw/uploads/_had/adlogo_16093_1627115824.jpg",
+                "webp": "https://images.hhh.com.tw/uploads/_had/adlogo_16093_1627115824.jpg",
+                "link": "https://v.hhh.com.tw/"
+            },
+            {
+                "imgUrl": "https://images.hhh.com.tw/uploads/_had/adlogo_16105_1628489359.jpg",
+                "webp": "https://images.hhh.com.tw/uploads/_had/adlogo_16105_1628489359.jpg",
+                "link": "https://c.hhh.com.tw/?utm_source=homepage&utm_medium=banner&utm_campaign=0809"
+            }
+        ]
+    },
+    {
+        "_comment": "tab區塊-最夯設計, 影音實錄, 專欄文章,(txt為部分內容段落)",
+        "id": 2,
+        "block": "sec03",
+        "data": [
+            {
+                "tab":"最夯設計",
+                "data": [
+                    {
+                        "imgUrl": "https://m.hhh.com.tw/upload/_hcase_img_orig/name_13732_20210914132752.jpg",
+                        "link": "https://m.hhh.com.tw/cases/detail/13680/",
+                        "description": "北歐風小確幸|48坪|透天",
+                        "txt": "從事餐飲業的年輕屋主剛迎來嬌嫩生命,希望能給予孩子簡約、乾淨、明亮的舒適空間,也希望在有限的小坪數空間中擁有2房2廳的格局。"
+                    },
+                    {
+                        "imgUrl": "https://m.hhh.com.tw/upload/_hcase_img_orig/name_13731_20210914105623.jpg",
+                        "link": "https://m.hhh.com.tw/cases/detail/13680/",
+                        "description": "北歐風小確幸|48坪|透天",
+                        "txt": "從事餐飲業的年輕屋主剛迎來嬌嫩生命,希望能給予孩子簡約、乾淨、明亮的舒適空間,也希望在有限的小坪數空間中擁有2房2廳的格局。"
+                    },
+                    {
+                        "imgUrl": "https://m.hhh.com.tw/upload/_hcase_img_orig/name_13730_20210914101340.jpg",
+                        "link": "https://m.hhh.com.tw/cases/detail/13680/",
+                        "description": "北歐風小確幸|48坪|透天",
+                        "txt": "從事餐飲業的年輕屋主剛迎來嬌嫩生命,希望能給予孩子簡約、乾淨、明亮的舒適空間,也希望在有限的小坪數空間中擁有2房2廳的格局。"
+                    }
+                ] 
+            },
+            {
+                "tab":"影音實錄",
+                "data": [
+                    {
+                        "imgUrl": "https://img.youtube.com/vi/LLPdsC718LY/hqdefault.jpg",
+                        "link": "https://m.hhh.com.tw/video-post.php?id=4159",
+                        "description": "把渡假飯店搬回家 八里左岸美景盡收眼底!",
+                        "txt": "從事餐飲業的年輕屋主剛迎來嬌嫩生命,希望能給予孩子簡約、乾淨、明亮的舒適空間,也希望在有限的小坪數空間中擁有2房2廳的格局。"
+                    },
+                    {
+                        "imgUrl": "https://img.youtube.com/vi/bRfzayE3OH0/hqdefault.jpg",
+                        "link": "https://m.hhh.com.tw/video-post.php?id=4160",
+                        "description": "為女友改造!美式低奢風現代宅【Softouch Home】",
+                        "txt": "從事餐飲業的年輕屋主剛迎來嬌嫩生命,希望能給予孩子簡約、乾淨、明亮的舒適空間,也希望在有限的小坪數空間中擁有2房2廳的格局。"
+                    },
+                    {
+                        "imgUrl": "https://img.youtube.com/vi/KBcBa0-qKBU/hqdefault.jpg",
+                        "link": "https://m.hhh.com.tw/video-post.php?id=3892",
+                        "description": "挑戰1萬5!雜亂工作室升級工業風臥房【Softouch Home】",
+                        "txt": "從事餐飲業的年輕屋主剛迎來嬌嫩生命,希望能給予孩子簡約、乾淨、明亮的舒適空間,也希望在有限的小坪數空間中擁有2房2廳的格局。"
+                    }
+                ] 
+            },
+            {
+                "tab":"專欄文章",
+                "data": [
+                    {
+                        "imgUrl": "https://images.hhh.com.tw/uploads/_hcolumn_orig/point01_349_05.jpg",
+                        "link": "https://m.hhh.com.tw/columns/detail/6007/",
+                        "description": "「咖啡輪船」今日開航!星巴克特色門市再+1",
+                        "txt": "從事餐飲業的年輕屋主剛迎來嬌嫩生命,希望能給予孩子簡約、乾淨、明亮的舒適空間,也希望在有限的小坪數空間中擁有2房2廳的格局。"
+                    },
+                    {
+                        "imgUrl": "https://images.hhh.com.tw/uploads/_hcolumn_orig/point04_449_11.jpg",
+                        "link": "https://m.hhh.com.tw/columns/detail/6006/",
+                        "description": "穿堂煞、樑壓床了怎麼辦?用設計破解20個常見室內風水迷思",
+                        "txt": "從事餐飲業的年輕屋主剛迎來嬌嫩生命,希望能給予孩子簡約、乾淨、明亮的舒適空間,也希望在有限的小坪數空間中擁有2房2廳的格局。"
+                    },
+                    {
+                        "imgUrl": "https://images.hhh.com.tw/uploads/_hcolumn_orig/point-index02_263.jpg",
+                        "link": "https://m.hhh.com.tw/columns/detail/6005/",
+                        "description": "【好宅專輯】112萬搞定!三代同堂現代風收納機能宅",
+                        "txt": "從事餐飲業的年輕屋主剛迎來嬌嫩生命,希望能給予孩子簡約、乾淨、明亮的舒適空間,也希望在有限的小坪數空間中擁有2房2廳的格局。"
+                    }
+                ] 
+            }
+        ]
+    },
+    {
+        "_comment": "主題企劃區,(title為主題標題,description為部分內容段落)",
+        "id": 3,
+        "block": "sec06",
+        "data": [
+            {
+                "imgUrl": "https://images.hhh.com.tw/uploads/_hcase_orig/designer546_81_07.jpg",
+                "link": "https://m.hhh.com.tw/cases/detail/13320/",
+                "description": "透過聰明巧思,小坪數房子也能溫馨又好用!除了而熟能詳的「樓中樓」設計,究竟設計師們還能運用那些手法讓小宅擁有豪邸的生活品質呢?一起從配色、家具挑選、風格等不同角度著手,讓你家也有魔術大視覺!(圖片提供/知域設計×一己空間制作)",
+                "title": "解壓縮小宅!享受豪宅級空間感",
+                "video": "false"
+            },
+            {
+                "imgUrl": "https://images.hhh.com.tw/uploads/_hcase_orig/designer737_03_01.jpg",
+                "link": "https://m.hhh.com.tw/cases/detail/12997/",
+                "description": "15坪美式小豪宅 靜享一人舒心療癒好時光",
+                "title": "解壓縮小宅!享受豪宅級空間感",
+                "video": "false"
+            },
+            {
+                "imgUrl": "https://images.hhh.com.tw/uploads/_hcase_orig/name_12422_20200601145042.jpg",
+                "link": "https://m.hhh.com.tw/cases/detail/12422/",
+                "description": "15坪美式小豪宅 靜享一人舒心療癒好時光",
+                "title": "解壓縮小宅!享受豪宅級空間感",
+                "video": "false"
+            },
+            {
+                "imgUrl": "https://images.hhh.com.tw/uploads/_hcolumn_orig/point-index02_241.jpg",
+                "link": "https://m.hhh.com.tw/columns/detail/5926/",
+                "description": "15坪美式小豪宅 靜享一人舒心療癒好時光",
+                "title": "解壓縮小宅!享受豪宅級空間感",
+                "video": "false"
+            }
+        ]
+    },
+    {
+        "_comment": "編輯精選,(txt為部分內容段落)",
+        "id": 4,
+        "block": "sec07",
+        "data": [
+            {
+                "imgUrl": "https://images.hhh.com.tw/uploads/_hcolumn_orig/point-index05_249.jpg",
+                "link": "https://m.hhh.com.tw/columns/detail/5649/",
+                "description": "就要給你好看!三星8K量子電視首用Mini LED技術,顏值功能再進化",
+                "txt": "從事餐飲業的年輕屋主剛迎來嬌嫩生命,希望能給予孩子簡約、乾淨、明亮的舒適空間,也希望在有限的小坪數空間中擁有2房2廳的格局。",
+                "video": "false"
+            },
+            {
+                "imgUrl": "https://images.hhh.com.tw/uploads/_hcolumn_orig/point05_244_01.jpg",
+                "link": "https://m.hhh.com.tw/columns/detail/5626/",
+                "description": "沒有設計師也能擁有個性小宅?裝潢套餐讓你講究不將就",
+                "txt": "從事餐飲業的年輕屋主剛迎來嬌嫩生命,希望能給予孩子簡約、乾淨、明亮的舒適空間,也希望在有限的小坪數空間中擁有2房2廳的格局。",
+                "video": "false"
+            },
+            {
+                "imgUrl": "https://cloud.hhh.com.tw/upload/_hcolumn/clogo_5345_20210127183205.jpg",
+                "link": "https://m.hhh.com.tw/columns/detail/5345/",
+                "description": "告別舊日陰霾 用寢具為居家生活注入安穩力量",
+                "txt": "從事餐飲業的年輕屋主剛迎來嬌嫩生命,希望能給予孩子簡約、乾淨、明亮的舒適空間,也希望在有限的小坪數空間中擁有2房2廳的格局。",
+                "video": "false"
+            }
+        ]
+    },
+    {
+        "_comment": "活動頁banners區",
+        "id": 5,
+        "block": "sec08",
+        "data": [
+            {
+                "imgUrl": "https://images.hhh.com.tw/uploads/_had/adlogo_15356_1588832058.jpg",
+                "link": "https://event.hhh.com.tw/2021-Most-Favorite-Designers/?utm_source=INDEX_BANNER&adid=15356"
+            },
+            {
+                "imgUrl": "https://images.hhh.com.tw/uploads/_had/adlogo_15927_1627805018.jpg",
+                "link": "https://hhh.com.tw/topic/detail/402/"
+            },
+            {
+                "imgUrl": "https://images.hhh.com.tw/uploads/_had/adlogo_16106_1628489482.jpg",
+                "link": "https://c.hhh.com.tw/?utm_source=homepage&utm_medium=banner&utm_campaign=0809"
+            }
+        ]
+    },
+    {
+        "_comment": "來選好物區",
+        "id": 6,
+        "block": "sec09",
+        "data": [
+            {
+                "imgUrl": "https://cloud.hhh.com.tw/upload/_hproduct_img/name_2273_20201014114713.png",
+                "link": "https://hhh.com.tw/product-post.php?id=2273",
+                "description": "LEAF 320i 空氣清淨機",
+                "video": "false"
+            },
+            {
+                "imgUrl": "https://cloud.hhh.com.tw/upload/_hproduct_img/name_2272_20201014114308.png",
+                "link": "https://hhh.com.tw/product-post.php?id=2272",
+                "description": "LEAF 120 空氣清淨機",
+                "video": "false"
+            },
+            {
+                "imgUrl": "https://cloud.hhh.com.tw/upload/_hproduct_img/name_2271_20201014113209.png ",
+                "link": "https://hhh.com.tw/product-post.php?id=2271",
+                "description": "MP-C20U 小空間空氣清淨機",
+                "video": "false"
+            }
+        ]
+    },
+    {
+        "_comment": "本週推薦,(txt為部分內容段落)",
+        "id": 7,
+        "block": "sec10",
+        "data": [
+            {
+                "imgUrl": "https://images.hhh.com.tw/uploads/_hcase_orig/designer355_14_02.jpg",
+                "link": "https://m.hhh.com.tw/cases/detail/13369/",
+                "description": "被落羽松環繞 都市裡的日式步調",
+                "txt": "轉動鑰匙打開家的期待 雙設計師詮釋景觀新豪奢│現代風│46坪",
+                "video": "false"
+            },
+            {
+                "imgUrl": "https://cloud.hhh.com.tw/upload/_hcase_img_orig/name_12994_20210202192001.jpg",
+                "link": "https://m.hhh.com.tw/cases/detail/12994/",
+                "description": "奔跑吧親子宅 我家比公園好玩",
+                "txt": "轉動鑰匙打開家的期待 雙設計師詮釋景觀新豪奢│現代風│46坪",
+                "video": "true"
+            },
+            {
+                "imgUrl": "https://cloud.hhh.com.tw/upload/_hcase_img_orig/name_13584_20210816172801.jpg",
+                "link": "https://m.hhh.com.tw/cases/detail/13584/",
+                "description": "又見單寧!歲月沉澱後的退休生活",
+                "txt": "轉動鑰匙打開家的期待 雙設計師詮釋景觀新豪奢│現代風│46坪",
+                "video": "false"
+            },
+            {
+                "imgUrl": "https://images.hhh.com.tw/uploads/_hcase_orig/designer432_42_03.jpg",
+                "link": "https://m.hhh.com.tw/cases/detail/12999/",
+                "description": "混搭風│極簡無印",
+                "txt": "轉動鑰匙打開家的期待 雙設計師詮釋景觀新豪奢│現代風│46坪",
+                "video": "false"
+            },
+            {
+                "imgUrl": "https://images.hhh.com.tw/uploads/_hcolumn_orig/point02_134_01.jpg",
+                "link": "https://m.hhh.com.tw/columns/detail/5436/",
+                "description": "憂慮「醛」消失!拭除疲憊的馨暖和風",
+                "txt": "轉動鑰匙打開家的期待 雙設計師詮釋景觀新豪奢│現代風│46坪",
+                "video": "false"
+            }
+        ]
+    },
+    {
+        "_comment": "粉絲推薦,(txt為部分內容段落)",
+        "id": 8,
+        "block": "sec11",
+        "data": [
+            {
+                "imgUrl": "https://images.hhh.com.tw/uploads/_hcase_orig/designer738_04_03.jpg",
+                "link": "https://m.hhh.com.tw/cases/detail/13071/",
+                "description": "木質系灰藍曲調|英式混搭寓所|小坪數",
+                "txt": "轉動鑰匙打開家的期待 雙設計師詮釋景觀新豪奢│現代風│46坪",
+                "video": "false"
+            },
+            {
+                "imgUrl": "https://images.hhh.com.tw/uploads/_hcase_orig/name_11746_20191015155016.jpg",
+                "link": "https://m.hhh.com.tw/cases/detail/11746/",
+                "description": "跳脫傳統設計 斜角開創通透大空間",
+                "txt": "轉動鑰匙打開家的期待 雙設計師詮釋景觀新豪奢│現代風│46坪",
+                "video": "false"
+            },
+            {
+                "imgUrl": "https://cloud.hhh.com.tw/upload/_hcase_img_orig/name_13125_20210319112543.jpg",
+                "link": "https://m.hhh.com.tw/cases/detail/13125/",
+                "description": "馨暖木韻蔓延 藝術家的舒心逸境|現代風|3房、2廳、2衛|25坪",
+                "txt": "轉動鑰匙打開家的期待 雙設計師詮釋景觀新豪奢│現代風│46坪",
+                "video": "true"
+            },
+            {
+                "imgUrl": "https://images.hhh.com.tw/uploads/_hcase_orig/name_12523_20200717134716.jpg",
+                "link": "https://m.hhh.com.tw/cases/detail/12523/",
+                "description": "變形與組合──複合式的空間設計(中)",
+                "txt": "轉動鑰匙打開家的期待 雙設計師詮釋景觀新豪奢│現代風│46坪",
+                "video": "false"
+            },
+            {
+                "imgUrl": "https://cloud.hhh.com.tw/upload/_hcase_img_orig/name_12835_20201204092123.jpg",
+                "link": "https://m.hhh.com.tw/cases/detail/12835/",
+                "description": "風華英倫、意境品味",
+                "txt": "轉動鑰匙打開家的期待 雙設計師詮釋景觀新豪奢│現代風│46坪",
+                "video": "false"
+            }
+        ]
+    },
+    {
+        "_comment": "video最新影音區",
+        "id": 9,
+        "block": "video",
+        "title": "不是寵物是家人 毛小孩專屬智能宅",
+        "yt": "IIV2ZvIojc4"
+    },
+    {
+        "_comment": "熱搜關鍵字",
+        "id": 10,
+        "block": "trending",
+        "data": ["小坪數", "收納", "軟裝佈置", "幸福經紀人", "承炫設計", "風水", "北歐風", "周石設計"]
+    }
+]

+ 435 - 0
hhh-home-mb/json/realtime.json

@@ -0,0 +1,435 @@
+[
+    {
+        "_comment": "頂部輪播區",
+        "id": 0,
+        "block": "topCarousel",
+        "data": [
+            {
+                "imgUrl": "https://images.hhh.com.tw/uploads/_had/adlogo_15664_1619582521.jpg",
+                "link": "https://hhh.com.tw/designer-index.php?designer_id=23",
+                "DimgUrl": "https://images.hhh.com.tw/uploads/_had/adlogo_15664_1619582509.jpg",
+                "webp": "https://images.hhh.com.tw/uploads/_had/adlogo_15664_1619582537.webp"
+            },
+            {
+                "imgUrl": "https://images.hhh.com.tw/uploads/_had/adlogo_15672_1605260703.jpg",
+                "link": "https://hhh.com.tw/designer-index.php?designer_id=28",
+                "DimgUrl": "https://images.hhh.com.tw/uploads/_had/adlogo_15672_1605260690.jpg",
+                "webp": "https://images.hhh.com.tw/uploads/_had/adlogo_15672_1605260747.webp"
+            },
+            {
+                "imgUrl": "https://images.hhh.com.tw/uploads/_had/adlogo_15662_1607045625.jpg",
+                "link": "https://hhh.com.tw/designer-index.php?designer_id=447",
+                "DimgUrl": "https://images.hhh.com.tw/uploads/_had/adlogo_15662_1607045611.jpg",
+                "webp": "https://images.hhh.com.tw/uploads/_had/adlogo_15662_1607045687.webp"
+            },
+            {
+                "imgUrl": "https://images.hhh.com.tw/uploads/_had/adlogo_15673_1603096869.jpg",
+                "link": "https://hhh.com.tw/designer-index.php?designer_id=31",
+                "DimgUrl": "https://images.hhh.com.tw/uploads/_had/adlogo_15673_1603096869.jpg",
+                "webp": ""
+            },
+            {
+                "imgUrl": "https://images.hhh.com.tw/uploads/_had/adlogo_16076_1625209654.jpg",
+                "link": "https://hhh.com.tw/designers/cases/586/1-page/new-sort/",
+                "DimgUrl": "https://images.hhh.com.tw/uploads/_had/adlogo_16076_1625209580.jpg",
+                "webp": "https://images.hhh.com.tw/uploads/_had/adlogo_16076_1625209663.webp"
+            },
+            {
+                "imgUrl": "https://images.hhh.com.tw/uploads/_had/adlogo_15666_1627961097.jpg",
+                "link": "https://hhh.com.tw/designer-index.php?designer_id=32",
+                "DimgUrl": "https://images.hhh.com.tw/uploads/_had/adlogo_15666_1627961071.jpg",
+                "webp": "https://images.hhh.com.tw/uploads/_had/adlogo_15666_1627961107.webp"
+            },
+            {
+                "imgUrl": "https://images.hhh.com.tw/uploads/_had/adlogo_16002_1617866880.jpg",
+                "link": "https://hhh.com.tw/brand-index.php?brand_id=202",
+                "DimgUrl": "https://images.hhh.com.tw/uploads/_had/adlogo_16002_1617866862.jpg",
+                "webp": "https://images.hhh.com.tw/uploads/_had/adlogo_16002_1617866888.webp"
+            },
+            {
+                "imgUrl": "https://images.hhh.com.tw/uploads/_had/adlogo_16051_1623138395.png",
+                "link": "https://hhh.com.tw/designers/cases/33/1-page/new-sort/",
+                "DimgUrl": "https://images.hhh.com.tw/uploads/_had/adlogo_16051_1623138372.png",
+                "webp": "https://images.hhh.com.tw/uploads/_had/adlogo_16051_1623141226.png"
+            },
+            {
+                "imgUrl": "https://images.hhh.com.tw/uploads/_had/adlogo_16108_1628669736.jpg",
+                "link": "https://hhh.com.tw/designers/cases/452/1-page/new-sort/",
+                "DimgUrl": "https://images.hhh.com.tw/uploads/_had/adlogo_16108_1628669721.jpg",
+                "webp": "https://images.hhh.com.tw/uploads/_had/adlogo_16108_1628669767.webp"
+            },
+            {
+                "imgUrl": "https://images.hhh.com.tw/uploads/_had/adlogo_16115_1629356235.png",
+                "link": "https://hhh.com.tw/designers/cases/438/1-page/new-sort/",
+                "DimgUrl": "https://images.hhh.com.tw/uploads/_had/adlogo_16115_1629356225.png",
+                "webp": "https://images.hhh.com.tw/uploads/_had/adlogo_16115_1629356246.webp"
+            },
+            {
+                "imgUrl": "https://images.hhh.com.tw/uploads/_had/adlogo_16138_1631259916.jpg",
+                "link": "https://hhh.com.tw/designers/cases/182/1-page/new-sort/",
+                "DimgUrl": "https://images.hhh.com.tw/uploads/_had/adlogo_16138_1631259909.jpg",
+                "webp": "https://images.hhh.com.tw/uploads/_had/adlogo_16138_1631259938.webp"
+            },
+            {
+                "imgUrl": "https://images.hhh.com.tw/uploads/_had/adlogo_16139_1631597917.jpg",
+                "link": "https://hhh.com.tw/columns/detail/6072/",
+                "DimgUrl": "https://images.hhh.com.tw/uploads/_had/adlogo_16139_1631597907.jpg",
+                "webp": "https://images.hhh.com.tw/uploads/_had/adlogo_16139_1631597927.webp"
+            },
+            {
+                "imgUrl": "https://images.hhh.com.tw/uploads/_had/adlogo_16107_1628644159.jpg",
+                "link": "https://hhh.com.tw/deco/",
+                "DimgUrl": "https://images.hhh.com.tw/uploads/_had/adlogo_16107_1628644143.jpg",
+                "webp": "https://images.hhh.com.tw/uploads/_had/adlogo_16107_1628644166.webp"
+            }
+        ]
+    },
+    {
+        "_comment": "主要輪播區",
+        "id": 1,
+        "block": "sec02",
+        "data": [
+            {
+                "imgUrl": "https://images.hhh.com.tw/uploads/_had/adlogo_15660_1604643433.jpg",
+                "link": "https://hhh.com.tw/designer-index.php?designer_id=28",
+                "DimgUrl": "https://images.hhh.com.tw/uploads/_had/adlogo_15660_1604643425.jpg",
+                "webp": ""
+            },
+            {
+                "imgUrl": "https://images.hhh.com.tw/uploads/_had/adlogo_16057_1631764389.jpg",
+                "link": "https://hhh.com.tw/columns/detail/4290/",
+                "DimgUrl": "https://images.hhh.com.tw/uploads/_had/adlogo_16057_1631764374.jpg",
+                "webp": "https://images.hhh.com.tw/uploads/_had/adlogo_16057_1631764401.webp"
+            },
+            {
+                "imgUrl": "https://images.hhh.com.tw/uploads/_had/adlogo_16093_1629944189.jpg",
+                "link": "https://v.hhh.com.tw/",
+                "DimgUrl": "https://images.hhh.com.tw/uploads/_had/adlogo_16093_1629944183.jpg",
+                "webp": "https://images.hhh.com.tw/uploads/_had/adlogo_16093_1629944200.webp"
+            },
+            {
+                "imgUrl": "https://images.hhh.com.tw/uploads/_had/adlogo_16082_1627804898.jpg",
+                "link": "https://hhh.com.tw/topic/detail/402/",
+                "DimgUrl": "https://images.hhh.com.tw/uploads/_had/adlogo_16082_1627804906.jpg",
+                "webp": "https://images.hhh.com.tw/uploads/_had/adlogo_16082_1627804929.webp"
+            },
+            {
+                "imgUrl": "https://images.hhh.com.tw/uploads/_had/adlogo_16142_1631782259.jpg",
+                "link": "https://event.hhh.com.tw/2021-Top-Brands/page.php?id=182",
+                "DimgUrl": "https://images.hhh.com.tw/uploads/_had/adlogo_16142_1631782224.jpg",
+                "webp": "https://images.hhh.com.tw/uploads/_had/adlogo_16142_1631782273.webp"
+            },
+            {
+                "imgUrl": "https://images.hhh.com.tw/uploads/_had/adlogo_16143_1631782091.jpg",
+                "link": "https://event.hhh.com.tw/topglory/designer_54.html",
+                "DimgUrl": "https://images.hhh.com.tw/uploads/_had/adlogo_16143_1631782085.jpg",
+                "webp": "https://images.hhh.com.tw/uploads/_had/adlogo_16143_1631782161.webp"
+            },
+            {
+                "imgUrl": "https://images.hhh.com.tw/uploads/_had/adlogo_16140_1631782123.jpg",
+                "link": "https://event.hhh.com.tw/topglory/designer_382.html",
+                "DimgUrl": "https://images.hhh.com.tw/uploads/_had/adlogo_16140_1631782117.jpg",
+                "webp": "https://images.hhh.com.tw/uploads/_had/adlogo_16140_1631782136.webp"
+            },
+            {
+                "imgUrl": "https://images.hhh.com.tw/uploads/_had/adlogo_16141_1631782111.jpg",
+                "link": "https://hhh.com.tw/designers/cases/441/1-page/new-sort/",
+                "DimgUrl": "https://images.hhh.com.tw/uploads/_had/adlogo_16141_1631782101.jpg",
+                "webp": "https://images.hhh.com.tw/uploads/_had/adlogo_16141_1631782147.webp"
+            },
+            {
+                "imgUrl": "https://images.hhh.com.tw/uploads/_had/adlogo_16144_1631782077.jpg",
+                "link": "https://event.hhh.com.tw/2021-Most-Favorite-Designers/case.php?id=131",
+                "DimgUrl": "https://images.hhh.com.tw/uploads/_had/adlogo_16144_1631782071.jpg",
+                "webp": "https://images.hhh.com.tw/uploads/_had/adlogo_16144_1631782178.webp"
+            },
+            {
+                "imgUrl": "https://images.hhh.com.tw/uploads/_had/adlogo_16145_1631782064.jpg",
+                "link": "https://event.hhh.com.tw/2021-Most-Favorite-Designers/case.php?id=688",
+                "DimgUrl": "https://images.hhh.com.tw/uploads/_had/adlogo_16145_1631782040.jpg",
+                "webp": "https://images.hhh.com.tw/uploads/_had/adlogo_16145_1631782190.webp"
+            },
+            {
+                "imgUrl": "https://images.hhh.com.tw/uploads/_had/adlogo_16099_1627623476.jpg",
+                "link": "https://hhh.com.tw/deco/",
+                "DimgUrl": "https://images.hhh.com.tw/uploads/_had/adlogo_16099_1627623458.jpg",
+                "webp": "https://images.hhh.com.tw/uploads/_had/adlogo_16099_1627623493.webp"
+            },
+            {
+                "imgUrl": "https://images.hhh.com.tw/uploads/_had/adlogo_15781_1601366572.jpg",
+                "link": "https://hhh.com.tw/softouch",
+                "DimgUrl": "https://images.hhh.com.tw/uploads/_had/adlogo_15781_1601366572.jpg",
+                "webp": ""
+            }
+        ]
+    },
+    {
+        "_comment": "tab區塊-最夯設計, 影音實錄, 專欄文章",
+        "id": 2,
+        "block": "sec03",
+        "data": [
+            {
+                "tab": "最夯設計",
+                "data": [
+                    {
+                        "imgUrl": "https://m.hhh.com.tw/upload/_hcase_img/name_13759_20210917173552.jpg",
+                        "link": "https://www.hhh.com.tw/cases/detail/13759/",
+                        "description": "文居│現代美式風│95坪"
+                    },
+                    {
+                        "imgUrl": "https://m.hhh.com.tw/upload/_hcase_img/name_13754_20210917152545.jpg",
+                        "link": "https://www.hhh.com.tw/cases/detail/13754/",
+                        "description": "詼-鵲|現代禪風|32坪"
+                    },
+                    {
+                        "imgUrl": "https://m.hhh.com.tw/upload/_hcase_img/name_13753_20210917145902.jpg",
+                        "link": "https://www.hhh.com.tw/cases/detail/13753/",
+                        "description": "率性況味 定格靜境|工業風|28坪"
+                    }
+                ]
+            },
+            {
+                "tab": "影音實錄",
+                "data": [
+                    {
+                        "imgUrl": "https://img.youtube.com/vi/bN2cRRkke_c/hqdefault.jpg",
+                        "link": "https://www.hhh.com.tw/video-post.php?id=4184",
+                        "description": "全視屏居家辦公新體驗  沉浸感影音收視再進化"
+                    },
+                    {
+                        "imgUrl": "https://img.youtube.com/vi/iW65jWwAX_s/hqdefault.jpg",
+                        "link": "https://www.hhh.com.tw/video-post.php?id=4183",
+                        "description": "雅致英式 奢華中的平靜氣度"
+                    },
+                    {
+                        "imgUrl": "https://img.youtube.com/vi/me4KutyUoT4/hqdefault.jpg",
+                        "link": "https://www.hhh.com.tw/video-post.php?id=4182",
+                        "description": "居家改造大公開 我的完整 因為有你|LG x Sunny 王陽明"
+                    }
+                ]
+            },
+            {
+                "tab": "專欄文章",
+                "data": [
+                    {
+                        "imgUrl": "https://images.hhh.com.tw/uploads/_hcolumn_orig/point-index04_474.jpg",
+                        "link": "https://www.hhh.com.tw/column/detail/6083/",
+                        "description": "【風水特輯】門對門解法?鏤空樓梯是禁忌?最實用的風水避雷指南!"
+                    },
+                    {
+                        "imgUrl": "https://images.hhh.com.tw/uploads/_hcolumn_orig/point-index02_283.jpg",
+                        "link": "https://www.hhh.com.tw/column/detail/6081/",
+                        "description": "化身高雅貴族 走進電影中的歐風居家!"
+                    },
+                    {
+                        "imgUrl": "https://images.hhh.com.tw/uploads/_hcolumn_orig/point02_282_01.jpg",
+                        "link": "https://www.hhh.com.tw/column/detail/6080/",
+                        "description": "【好宅開箱分享】重整格局,讓陽光走進家!超舒適北歐療癒宅開箱記"
+                    }
+                ]
+            }
+        ]
+    },
+    {
+        "_comment": "主題企劃區",
+        "id": 3,
+        "block": "sec06",
+        "data": [
+            {
+                "imgUrl": "https://images.hhh.com.tw/uploads/_hcase/designer546_81_07.jpg",
+                "link": "https://www.hhh.com.tw/case/13320/detail/"
+            },
+            {
+                "imgUrl": "https://images.hhh.com.tw/uploads/_hcase/designer737_03_01.jpg",
+                "link": "https://www.hhh.com.tw/case/12997/detail/"
+            },
+            {
+                "imgUrl": "https://images.hhh.com.tw/uploads/_hcase/name_12422_20200601145042.jpg",
+                "link": "https://www.hhh.com.tw/case/12422/detail/"
+            },
+            {
+                "imgUrl": "https://images.hhh.com.tw/uploads/_hcolumn_orig/point-index02_241.jpg",
+                "link": "https://www.hhh.com.tw/column/5926/detail/"
+            },
+            {
+                "imgUrl": "https://cloud.hhh.com.tw/upload/_hcolumn/clogo_5763_20210528143431.jpg",
+                "link": "https://www.hhh.com.tw/column/5763/detail/"
+            },
+            {
+                "imgUrl": "https://images.hhh.com.tw/uploads/_hcolumn_orig/point-index01_312.jpg",
+                "link": "https://www.hhh.com.tw/column/5650/detail/"
+            }
+        ]
+    },
+    {
+        "_comment": "編輯精選",
+        "id": 4,
+        "block": "sec07",
+        "data": [
+            {
+                "imgUrl": "https://images.hhh.com.tw/uploads/_hcolumn_orig/point-index01_356.jpg",
+                "link": "https://www.hhh.com.tw/columns/detail/6072/",
+                "description": "2022得利絕美年度色「晴空藍Bright Skies」!為空間注入清新能量,完美晴空就在身旁"
+            },
+            {
+                "imgUrl": "https://images.hhh.com.tw/uploads/_hcolumn_orig/point-index05_284.jpg",
+                "link": "https://www.hhh.com.tw/columns/detail/6076/",
+                "description": "揮別單調!超吸睛衛浴配件單品色彩學"
+            },
+            {
+                "imgUrl": "https://images.hhh.com.tw/uploads/_hcolumn_orig/point-index05_283.jpg",
+                "link": "https://www.hhh.com.tw/columns/detail/6064/",
+                "description": "懶人居家必備智能神器!下班好累不想動,就交給Google Nest 智慧音箱"
+            }
+        ]
+    },
+    {
+        "_comment": "活動頁banners區",
+        "id": 5,
+        "block": "sec08",
+        "data": [
+            {
+                "imgUrl": "https://images.hhh.com.tw/uploads/_had/adlogo_15356_1588832058.jpg",
+                "link": "https://event.hhh.com.tw/2021-Most-Favorite-Designers/?utm_source=INDEX_BANNER&adid=15356"
+            },
+            {
+                "imgUrl": "https://images.hhh.com.tw/uploads/_had/adlogo_15927_1627805018.jpg",
+                "link": "https://hhh.com.tw/topic/detail/402/"
+            },
+            {
+                "imgUrl": "https://images.hhh.com.tw/uploads/_had/adlogo_16106_1628489482.jpg",
+                "link": "https://c.hhh.com.tw/?utm_source=homepage&utm_medium=banner&utm_campaign=0809"
+            }
+        ]
+    },
+    {
+        "_comment": "來選好物區",
+        "id": 6,
+        "block": "sec09",
+        "data": [
+            {
+                "imgUrl": "https://cloud.hhh.com.tw/upload/_hproduct_img/name_2384_20210803162337.png",
+                "link": "https://www.hhh.com.tw/product-post.php?id=2384/",
+                "description": "Sunline 特殊型塑鋁百葉窗"
+            },
+            {
+                "imgUrl": "https://cloud.hhh.com.tw/upload/_hproduct_img/name_2383_20210816182839.png",
+                "link": "https://www.hhh.com.tw/product-post.php?id=2383/",
+                "description": "Sunline 折疊門"
+            },
+            {
+                "imgUrl": "https://cloud.hhh.com.tw/upload/_hproduct_img/name_2382_20210803161842.png",
+                "link": "https://www.hhh.com.tw/product-post.php?id=2382/",
+                "description": "Sunline 推拉門"
+            },
+            {
+                "imgUrl": "https://cloud.hhh.com.tw/upload/_hproduct_img/name_2381_20210527160349.png",
+                "link": "https://www.hhh.com.tw/product-post.php?id=2381/",
+                "description": "MIT鐵桌腳"
+            },
+            {
+                "imgUrl": "https://cloud.hhh.com.tw/upload/_hproduct_img/name_2380_20210527160130.png",
+                "link": "https://www.hhh.com.tw/product-post.php?id=2380/",
+                "description": "實木長凳"
+            },
+            {
+                "imgUrl": "https://cloud.hhh.com.tw/upload/_hproduct_img/name_2379_20210527155756.png",
+                "link": "https://www.hhh.com.tw/product-post.php?id=2379/",
+                "description": "實木小家具"
+            }
+        ]
+    },
+    {
+        "_comment": "本週推薦",
+        "id": 7,
+        "block": "sec10",
+        "data": [
+            {
+                "imgUrl": "https://images.hhh.com.tw/uploads/_hcase/name_12458_20200616152204.jpg",
+                "link": "https://www.hhh.com.tw/cases/detail/12458/",
+                "description": "簡約沐光宅 暖色調營造家的恬靜溫度",
+                "video": "false"
+            },
+            {
+                "imgUrl": "https://images.hhh.com.tw/uploads/_hcase/name_11965_20191231153835.jpg",
+                "link": "https://www.hhh.com.tw/cases/detail/11965/",
+                "description": "連結城市風華 坐擁浪漫夜景(上)",
+                "video": "false"
+            },
+            {
+                "imgUrl": "https://images.hhh.com.tw/uploads/_hcase/designer519_26_02.jpg",
+                "link": "https://www.hhh.com.tw/cases/detail/13088/",
+                "description": "整合鄉村元素 營造日常的暖馨溫度|30坪|3+1 房、2廳、2衛",
+                "video": "false"
+            },
+            {
+                "imgUrl": "https://cloud.hhh.com.tw/upload/_hcase_img/name_13319_20210528165925.jpg",
+                "link": "https://www.hhh.com.tw/cases/detail/13319/",
+                "description": "現代日式混搭佐日光 構畫敞朗質感好生活",
+                "video": "false"
+            },
+            {
+                "imgUrl": "https://m.hhh.com.tw/upload/_hcase_img/name_13728_20210913165321.jpg",
+                "link": "https://www.hhh.com.tw/cases/detail/13728/",
+                "description": "微光島嶼。Dusky Island│現代風│50坪",
+                "video": "false"
+            },
+            {
+                "imgUrl": "https://m.hhh.com.tw/upload/_hcase_img/name_13737_20210914183731.jpg",
+                "link": "https://www.hhh.com.tw/cases/detail/13737/",
+                "description": "譜出音符律動的宅邸 回家就像歌劇院|現代風|26坪",
+                "video": "false"
+            }
+        ]
+    },
+    {
+        "_comment": "粉絲推薦",
+        "id": 8,
+        "block": "sec11",
+        "data": [
+            {
+                "imgUrl": "https://images.hhh.com.tw/uploads/_hcase/name_12458_20200616152204.jpg",
+                "link": "https://www.hhh.com.tw/cases/detail/12458/",
+                "description": "簡約沐光宅 暖色調營造家的恬靜溫度",
+                "video": "false"
+            },
+            {
+                "imgUrl": "https://images.hhh.com.tw/uploads/_hcase/name_11965_20191231153835.jpg",
+                "link": "https://www.hhh.com.tw/cases/detail/11965/",
+                "description": "連結城市風華 坐擁浪漫夜景(上)",
+                "video": "false"
+            },
+            {
+                "imgUrl": "https://images.hhh.com.tw/uploads/_hcase/designer519_26_02.jpg",
+                "link": "https://www.hhh.com.tw/cases/detail/13088/",
+                "description": "整合鄉村元素 營造日常的暖馨溫度|30坪|3+1 房、2廳、2衛",
+                "video": "false"
+            },
+            {
+                "imgUrl": "https://cloud.hhh.com.tw/upload/_hcase_img/name_13319_20210528165925.jpg",
+                "link": "https://www.hhh.com.tw/cases/detail/13319/",
+                "description": "現代日式混搭佐日光 構畫敞朗質感好生活",
+                "video": "false"
+            },
+            {
+                "imgUrl": "https://m.hhh.com.tw/upload/_hcase_img/name_13728_20210913165321.jpg",
+                "link": "https://www.hhh.com.tw/cases/detail/13728/",
+                "description": "微光島嶼。Dusky Island│現代風│50坪",
+                "video": "false"
+            },
+            {
+                "imgUrl": "https://m.hhh.com.tw/upload/_hcase_img/name_13737_20210914183731.jpg",
+                "link": "https://www.hhh.com.tw/cases/detail/13737/",
+                "description": "譜出音符律動的宅邸 回家就像歌劇院|現代風|26坪",
+                "video": "false"
+            }
+        ]
+    },
+    {
+        "_comment": "video最新影音區",
+        "id": 9,
+        "block": "video",
+        "title": "全視屏居家辦公新體驗  沉浸感影音收視再進化",
+        "yt": "bN2cRRkke_c"
+    }
+]

BIN
mcapi/__pycache__/fastapi_yo.cpython-39.pyc


+ 20 - 22
mcapi/fastapi_yo.py

@@ -1,5 +1,5 @@
 
-from YoConfig import YoConfig
+import YoConfig
 from typing import Optional
 from fastapi import FastAPI
 from fastapi.middleware.cors import CORSMiddleware
@@ -16,7 +16,7 @@ app = FastAPI()
 cc = OpenCC('s2t')
 
 origins = [
-    "http://localhost:8081",
+    "*"
 ]
 app.add_middleware(
     CORSMiddleware,
@@ -32,7 +32,6 @@ connection = mysql.connector.connect(
     user=YoConfig['db']['choozmo_new']['MYSQL_USER'],
     password=YoConfig['db']['choozmo_new']['MYSQL_PASSWORD']
 )
-
 cursor = connection.cursor(buffered=True)
 
 @app.get("/")
@@ -46,10 +45,13 @@ def read_item(item_id: int, q: Optional[str] = None):
 
 
 @app.get("/ts_top")
-def get_ts_tops(tc: Optional[int] = 3):
+def get_ts_tops(td: Optional[str] = str(datetime.date.today()), tc: Optional[int] = 3):
     if not connection.is_connected():
         connection.connect()
-    sql = '(SELECT * FROM trending_searches ORDER BY ts_date DESC LIMIT 20) ORDER BY ts_rank LIMIT ' + str(tc)
+        cursor = connection.cursor(buffered=True)
+    sql = "(SELECT * FROM trending_searches " + ((" where ts_date between '" + td + "' and '" + td + \
+        "'+ INTERVAL 1 day ") if td != str(datetime.date.today()) else "") + \
+        " ORDER BY ts_date DESC LIMIT 20) ORDER BY ts_date LIMIT " + str(tc)
     cursor.execute(sql)
     records = cursor.fetchall()
     return records
@@ -58,11 +60,9 @@ def get_ts_tops(tc: Optional[int] = 3):
 @app.get("/related_queries/{Keyword}")
 def get_related_queries(Keyword: str, u: Optional[str] = '', fd: Optional[str] = '2020-01-01', td: Optional[str] = str(datetime.date.today())):
     save_userKw(Keyword, u)
-    if not connection.is_connected():
-        connection.connect()
-    sql = 'select * from related_queries where rq_kword = \''+ Keyword +'\' '
+    sql = 'select * from related_queries where rq_kword = \'' + Keyword + '\' '
     cursor.execute(sql)
-    #print(str(cursor.rowcount))
+    # print(str(cursor.rowcount))
     if not cursor.rowcount > 0:
         pytrends = TrendReq(hl='zh-TW', tz=1200, geo='TW')
         kw_list = []
@@ -93,19 +93,18 @@ def get_related_queries(Keyword: str, u: Optional[str] = '', fd: Optional[str] =
     else:
         records = cursor.fetchall()
         return records
-    sql = 'select * from related_queries where rq_kword = \''+ Keyword +'\' '
+    sql = 'select * from related_queries where rq_kword = \'' + Keyword + '\' '
     cursor.execute(sql)
     records = cursor.fetchall()
     return records
 
+
 @app.get("/related_topics/{Keyword}")
 def get_related_topics(Keyword: str, u: Optional[str] = '', fd: Optional[str] = '2020-01-01', td: Optional[str] = str(datetime.date.today())):
     save_userKw(Keyword, u)
-    if not connection.is_connected():
-        connection.connect()
-    sql = 'select * from related_topics where rt_kword = \''+ Keyword +'\' '
+    sql = 'select * from related_topics where rt_kword = \'' + Keyword + '\' '
     cursor.execute(sql)
-    #print(str(cursor.rowcount))
+    # print(str(cursor.rowcount))
     if not cursor.rowcount > 0:
         pytrends = TrendReq(hl='zh-TW', tz=1200, geo='TW')
         kw_list = []
@@ -135,15 +134,18 @@ def get_related_topics(Keyword: str, u: Optional[str] = '', fd: Optional[str] =
     else:
         records = cursor.fetchall()
         return records
-    sql = 'select * from related_topics where rt_kword = \''+ Keyword +'\' '
+    sql = 'select * from related_topics where rt_kword = \'' + Keyword + '\' '
     cursor.execute(sql)
     records = cursor.fetchall()
     return records
 
+
 def save_userKw(Keyword: str, Username: str = ''):
     if not connection.is_connected():
         connection.connect()
-    sql = 'insert into user_searches(us_username,us_search_word) select \''+ Keyword +'\',\''+ Username +'\' '
+        cursor = connection.cursor(buffered=True)
+    sql = 'insert into user_searches(us_username,us_search_word) select \'' + \
+        Keyword + '\',\'' + Username + '\' '
     cursor.execute(sql)
     return
 
@@ -151,13 +153,11 @@ def save_userKw(Keyword: str, Username: str = ''):
 @app.get("/related_queries1/{Keyword}")
 def get_related_queries(Keyword: str, u: Optional[str] = '', fd: Optional[str] = '2020-01-01', td: Optional[str] = str(datetime.date.today())):
     save_userKw(Keyword, u)
-    if not connection.is_connected():
-        connection.connect()
     pytrends = TrendReq(hl='zh-TW', tz=1200, geo='TW')
     kw_list = []
     kw_list.append(Keyword)
     pytrends.build_payload(kw_list, cat=0, timeframe=fd +
-                            ' '+td, geo='TW', gprop='')
+                           ' '+td, geo='TW', gprop='')
     KWORD = kw_list[0]
     rqdata = pytrends.related_queries()
 
@@ -171,13 +171,11 @@ def get_related_queries(Keyword: str, u: Optional[str] = '', fd: Optional[str] =
 @app.get("/related_topics1/{Keyword}")
 def get_related_topics(Keyword: str, u: Optional[str] = '', fd: Optional[str] = '2020-01-01', td: Optional[str] = str(datetime.date.today())):
     save_userKw(Keyword, u)
-    if not connection.is_connected():
-        connection.connect()
     pytrends = TrendReq(hl='zh-TW', tz=1200, geo='TW')
     kw_list = []
     kw_list.append(Keyword)
     pytrends.build_payload(kw_list, cat=0, timeframe=fd +
-                            ' '+td, geo='TW', gprop='')
+                           ' '+td, geo='TW', gprop='')
     KWORD = kw_list[0]
     rtdata = pytrends.related_topics()
 

+ 3 - 3
tgBot/MyTelegramBot.py

@@ -15,7 +15,7 @@ logging.basicConfig(format='%(asctime)s - %(name)s - %(levelname)s - %(message)s
 """ def start(update, context):
     context.bot.send_message(chat_id=update.effective_chat.id, text="I'm a bot, please talk to me!") """
 
-r = redis.Redis(host=YoConfig['db']['choozmo_redis']['REDIS_HOST'], port=YoConfig['db']['choozmo_redis']['REDIS_PORT'], db=0)
+r = redis.Redis(host=YoConfig['db']['choozmo_redis']['REDIS_HOST'], port=YoConfig['db']['choozmo_redis']['REDIS_PORT'], password=YoConfig['db']['choozmo_redis']['REDIS_PASSWORD'], db=1)
 
 def start(update, bot):
     a, b = randint(1, 100), randint(1, 100)
@@ -74,8 +74,8 @@ updater.job_queue.run_once(callback_minute, 3)
 
 def hhh_space_monitor(context: telegram.ext.CallbackContext):
     context.bot.send_message(chat_id='-1001177266889', 
-                             text='this is space monitor. space_hhhapi: \n' + str(r.get('space_hhhapi')))    
-updater.job_queue.run_daily(hhh_space_monitor, datetime.time(00, 00, 00))
+                             text='this is space monitor. space_hhhapi: \n' + str(r.get('space_hhhapi').decode('utf-8')))    
+updater.job_queue.run_daily(hhh_space_monitor, datetime.time(1, 00, 00))
 updater.job_queue.run_once(hhh_space_monitor, 3)
 
 updater.start_polling()

+ 1 - 1
tgBot/config.json

@@ -23,7 +23,7 @@
         },
         "choozmo_redis": {
             "REDIS_HOST": "db.ptt.cx",
-            "REDIS_PASSWORD": "",
+            "REDIS_PASSWORD": "choozmo9",
             "REDIS_PORT": 6379
         }
     }