|
@@ -207,20 +207,29 @@ def xigua_search(keyword):
|
|
|
)
|
|
|
if result_list:
|
|
|
for item in result_list:
|
|
|
- url = item.xpath("@href")[0]
|
|
|
- duration_str = str(item.xpath("./span/text()")[0])
|
|
|
- duration = int(duration_str.split(":")[0]) * 60 + int(duration_str.split(":")[1])
|
|
|
- title = item.xpath("@title")[0]
|
|
|
- real_title = bytes(str(title), "latin1").decode()
|
|
|
- if sensitive_flag(sensitive_words, real_title) and duration <= 300:
|
|
|
- try:
|
|
|
- res = XiGuaFunctions().get_video_info(url[1:])
|
|
|
- if res:
|
|
|
- return [res]
|
|
|
- else:
|
|
|
- continue
|
|
|
- except Exception as e:
|
|
|
- print(e)
|
|
|
+ try:
|
|
|
+ url = item.xpath("@href")[0]
|
|
|
+ duration_str = str(item.xpath("./span/text()")[0])
|
|
|
+ duration_obj = duration_str.split(":")
|
|
|
+ if len(duration_obj) == 3:
|
|
|
+ duration = 100000
|
|
|
+ elif len(duration_obj) == 2:
|
|
|
+ duration = int(duration_str.split(":")[0]) * 60 + int(duration_str.split(":")[1])
|
|
|
+ else:
|
|
|
+ duration = 10000
|
|
|
+ title = item.xpath("@title")[0]
|
|
|
+ real_title = bytes(str(title), "latin1").decode()
|
|
|
+ if sensitive_flag(sensitive_words, real_title) and duration <= 300:
|
|
|
+ try:
|
|
|
+ res = XiGuaFunctions().get_video_info(url[1:])
|
|
|
+ if res:
|
|
|
+ return [res]
|
|
|
+ else:
|
|
|
+ continue
|
|
|
+ except Exception as e:
|
|
|
+ print(e)
|
|
|
+ except Exception as e:
|
|
|
+ print(e)
|
|
|
return []
|
|
|
else:
|
|
|
return []
|