|
@@ -1,6 +1,7 @@
|
|
|
# -*- coding: utf-8 -*-
|
|
|
# @Author: wangkun
|
|
|
# @Time: 2022/11/3
|
|
|
+import difflib
|
|
|
import os
|
|
|
import shutil
|
|
|
import sys
|
|
@@ -189,6 +190,16 @@ class ZMYXRecommend:
|
|
|
except Exception as e:
|
|
|
Common.logger(log_type).error('get_video_url异常:{}\n', e)
|
|
|
|
|
|
+ @classmethod
|
|
|
+ def title_like(cls, log_type, title):
|
|
|
+ sheet = Feishu.get_values_batch(log_type, 'zmyx', '19c772')
|
|
|
+ for i in range(1, len(sheet)):
|
|
|
+ video_title = sheet[i][7]
|
|
|
+ if difflib.SequenceMatcher(None, title, video_title).quick_ratio() >= 0.8:
|
|
|
+ return True
|
|
|
+ else:
|
|
|
+ return False
|
|
|
+
|
|
|
@classmethod
|
|
|
def get_zmyx_recommend(cls, log_type, driver: WebDriver, env):
|
|
|
try:
|
|
@@ -197,10 +208,6 @@ class ZMYXRecommend:
|
|
|
webview = driver.contexts
|
|
|
driver.switch_to.context(webview[1])
|
|
|
|
|
|
- # time.sleep(5)
|
|
|
- # Common.logger(log_type).info('切换到"综合"列表\n')
|
|
|
- # cls.search_element(log_type, driver, '//*[@class="index--navbar-list"]/*[1]').click()
|
|
|
-
|
|
|
time.sleep(1)
|
|
|
while True:
|
|
|
cls.i += 1
|
|
@@ -218,11 +225,6 @@ class ZMYXRecommend:
|
|
|
log_type, driver, '//wx-view[@class="uls"]/*['+str(cls.i)+']//span/*[2]').get_attribute('innerHTML')
|
|
|
cover_url = cls.search_element(
|
|
|
log_type, driver, '//wx-view[@class="uls"]/*['+str(cls.i)+']//wx-image').get_attribute('src')
|
|
|
- # except JavascriptException:
|
|
|
- # play_btn = 0
|
|
|
- # video_title = 0
|
|
|
- # play_cnt = 0
|
|
|
- # cover_url = 0
|
|
|
|
|
|
Common.logger(log_type).info('第{}条视频:{}', cls.i, video_title)
|
|
|
|
|
@@ -230,6 +232,8 @@ class ZMYXRecommend:
|
|
|
Common.logger(log_type).info('无效视频\n')
|
|
|
elif video_title in [x for y in Feishu.get_values_batch(log_type, 'zmyx', '19c772') for x in y]:
|
|
|
Common.logger(log_type).info('视频已下载\n')
|
|
|
+ elif cls.title_like(log_type, video_title) is True:
|
|
|
+ Common.logger(log_type).info('标题相似度>=80%:{}\n', video_title)
|
|
|
elif any(word if word in video_title else False for word in cls.filter_words(log_type)) is True:
|
|
|
Common.logger(log_type).info('视频已中过滤词\n')
|
|
|
else:
|
|
@@ -321,6 +325,7 @@ class ZMYXRecommend:
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
- ZMYXRecommend.start_wechat('recommend', 'dev')
|
|
|
+ # ZMYXRecommend.start_wechat('recommend', 'dev')
|
|
|
+ ZMYXRecommend.title_like('recommend', '今天是9月3日!又有大事发生!')
|
|
|
|
|
|
pass
|