|
@@ -24,22 +24,24 @@ def wx_search(keys, sensitive_words):
|
|
|
'Content-Type': 'application/json'
|
|
|
}
|
|
|
response = requests.request("POST", url, headers=headers, data=payload).json()
|
|
|
+ print(response)
|
|
|
if response['msg'] == '未知错误':
|
|
|
return []
|
|
|
else:
|
|
|
L = []
|
|
|
if response['data']:
|
|
|
video_list = response['data']['data']
|
|
|
- for video in video_list:
|
|
|
- try:
|
|
|
- video_info = video['items'][0]
|
|
|
- title = video_info['title']
|
|
|
- duration_str = video_info['duration']
|
|
|
- dr = int(duration_str.split(":")[0].strip()) + int(duration_str.split(":")[1].strip())
|
|
|
- if sensitive_flag(sensitive_words, title) and dr <= 300:
|
|
|
- L.append(video_info)
|
|
|
- else:
|
|
|
- continue
|
|
|
- except:
|
|
|
- pass
|
|
|
+ if video_list:
|
|
|
+ for video in video_list:
|
|
|
+ try:
|
|
|
+ video_info = video['items'][0]
|
|
|
+ title = video_info['title']
|
|
|
+ duration_str = video_info['duration']
|
|
|
+ dr = int(duration_str.split(":")[0].strip()) + int(duration_str.split(":")[1].strip())
|
|
|
+ if sensitive_flag(sensitive_words, title) and dr <= 300:
|
|
|
+ L.append(video_info)
|
|
|
+ else:
|
|
|
+ continue
|
|
|
+ except:
|
|
|
+ pass
|
|
|
return L
|