|
@@ -135,22 +135,23 @@ class Dy_KS:
|
|
|
headers = {
|
|
|
'Content-Type': 'application/json'
|
|
|
}
|
|
|
- time.sleep(random.uniform(10, 50))
|
|
|
- response = requests.request("POST", url, headers=headers, data=payload, timeout=30)
|
|
|
- response = response.json()
|
|
|
- code = response["code"]
|
|
|
- if code == 0:
|
|
|
- data = response["data"]["data"]
|
|
|
- content_type = data['content_type']
|
|
|
- if content_type == 'note':
|
|
|
- return "note", "note"
|
|
|
- video_url = data["video_url_list"][0]["video_url"]
|
|
|
- original_title = data["title"]
|
|
|
- return video_url, original_title, video_id
|
|
|
- elif code == 27006:
|
|
|
- if "作品不存在" in response['msg'] or "内容不存在" in response['msg'] or "私密作品" in response[
|
|
|
- 'msg'] or "该作品仅允许关注者查看" in response['msg']:
|
|
|
- return "作品不存在", None, None
|
|
|
+ max_retries = 3
|
|
|
+ retries = 0
|
|
|
+ while retries < max_retries:
|
|
|
+ response = requests.request("POST", url, headers=headers, data=payload, timeout=30)
|
|
|
+ response = response.json()
|
|
|
+ code = response["code"]
|
|
|
+ if code == 0:
|
|
|
+ data = response["data"]["data"]
|
|
|
+ content_type = data['content_type']
|
|
|
+ if content_type == 'note':
|
|
|
+ return "note", "note"
|
|
|
+ video_url = data["video_url_list"][0]["video_url"]
|
|
|
+ original_title = data["title"]
|
|
|
+ return video_url, original_title, video_id
|
|
|
+ else:
|
|
|
+ retries += 1
|
|
|
+ logger.warning(f"[+] 好看视频 {url} 请求返回 code 为 10000,正在进行第 {retries} 次重试...")
|
|
|
except Exception as e:
|
|
|
logger.error(f"[+] 好看视频{url}获取视频信息失败,失败信息{e}")
|
|
|
return None, None, None
|