From 402307d36a103d1d40dc9dfc553028e52b7c60b1 Mon Sep 17 00:00:00 2001 From: Franklin-F Date: Thu, 22 May 2025 23:32:25 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=A2=9E=E5=8A=A0=E8=B0=83=E8=AF=95?= =?UTF-8?q?=E4=BF=A1=E6=81=AF=EF=BC=8C=E8=BE=93=E5=87=BA=E8=8E=B7=E5=8F=96?= =?UTF-8?q?=20token=20=E5=92=8C=E8=A7=86=E9=A2=91=E4=BF=A1=E6=81=AF?= =?UTF-8?q?=E7=9A=84=E5=8F=82=E6=95=B0=E5=8F=8A=E7=BB=93=E6=9E=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- flask_app.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/flask_app.py b/flask_app.py index d54f43e..774614d 100644 --- a/flask_app.py +++ b/flask_app.py @@ -118,8 +118,10 @@ def gettoken(proxy, r=2): 'traffic_segment': traffic_segment, 'visitor_id': uuid_with_dash, } + print(f"[gettoken] 参数: {data}") try: proxy_str = db.get_proxy(proxy) + print(f"[gettoken] 使用代理: {proxy_str}") url = 'https://graphql.api.dailymotion.com/oauth/token' response = requests.post(url, headers=headers, data=data, proxies={"http": proxy_str, "https": proxy_str}) token = response.json()['access_token'] @@ -127,6 +129,9 @@ def gettoken(proxy, r=2): copy_headers['authorization'] = "Bearer " + token copy_headers['x-dm-visit-id'] = str(int(time.time() * 1000)) copy_headers['x-dm-visitor-id'] = uuid_no_dash + print( + f"[gettoken] 成功获取 访问 ID: {copy_headers['x-dm-visit-id']}, 访客 ID: {copy_headers['x-dm-visitor-id']}" + ) with _cache_lock: _headers_cache = copy_headers return copy_headers @@ -165,6 +170,7 @@ def get_videoInfo(x_id, proxy_name,headers, r=3): try: v_info = jsondata['data']['video']['channel']['stats'] except Exception: + print(f"[get_videoInfo] 失败: {jsondata}") if r > 0: return get_videoInfo(x_id=x_id, r=r - 1) else: @@ -173,6 +179,7 @@ def get_videoInfo(x_id, proxy_name,headers, r=3): "fans": '-', "videos": '-', } + print(f"[get_videoInfo] 成功: {v_info}") return { "view": v_info['views']['total'], "fans": v_info['followers']['total'], @@ -192,6 +199,7 @@ def submit(): results = {} v_xid = data['v_xid'] rn = data['rn'] + print(f"收到请求: {v_xid}, {rn}") headers = gettoken(rn) results = get_videoInfo(v_xid, rn, headers) return jsonify({