feat: 增加调试信息,输出获取 token 和视频信息的参数及结果
This commit is contained in:
parent
6804164034
commit
402307d36a
@ -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({
|
||||
|
Loading…
x
Reference in New Issue
Block a user