wangkun 2 år sedan
förälder
incheckning
288381ef24
2 ändrade filer med 20 tillägg och 18 borttagningar
  1. 8 7
      main/follow_list.py
  2. 12 11
      main/recommend_list.py

+ 8 - 7
main/follow_list.py

@@ -471,10 +471,10 @@ class Follow:
                     elif any(word if word in kuaishou_title else False for word in cls.sensitive_words()) is True:
                         Common.logger(log_type).info("视频已中敏感词:{}\n".format(kuaishou_title))
                     # 从 云文档 去重:https://w42nne6hzg.feishu.cn/sheets/shtcnp4SaJt37q6OOOrYzPMjQkg?sheet=3cd128
-                    elif video_id in [j for m in Feishu.get_values_batch(log_type, "kuaishou", "3cd128") for j in m]:
+                    elif str(video_id) in [j for m in Feishu.get_values_batch(log_type, "kuaishou", "3cd128") for j in m]:
                         Common.logger(log_type).info("该视频已下载:{}\n", video_title)
                     # 从 云文档 去重:https://w42nne6hzg.feishu.cn/sheets/shtcnp4SaJt37q6OOOrYzPMjQkg?sheet=wW5cyb
-                    elif video_id in [j for n in Feishu.get_values_batch(log_type, "kuaishou", "wW5cyb") for j in n]:
+                    elif str(video_id) in [j for n in Feishu.get_values_batch(log_type, "kuaishou", "wW5cyb") for j in n]:
                         Common.logger(log_type).info("该视频已在feeds中:{}\n", video_title)
                     else:
                         Feishu.insert_columns("follow", "kuaishou", "wW5cyb", "ROWS", 1, 2)
@@ -483,7 +483,7 @@ class Follow:
                         # 工作表中写入数据
                         values = [[time.strftime("%Y/%m/%d %H:%M:%S", time.localtime(int(get_feeds_time))),
                                    "用户主页",
-                                   video_id,
+                                   str(video_id),
                                    video_title,
                                    video_play_cnt,
                                    video_comment_cnt,
@@ -500,7 +500,7 @@ class Follow:
                                    video_url]]
                         # 等待 1s,防止操作云文档太频繁,导致报错
                         time.sleep(1)
-                        Feishu.update_values("follow", "kuaishou", "wW5cyb", "A2:P2", values)
+                        Feishu.update_values("follow", "kuaishou", "wW5cyb", "A2:T2", values)
                         Common.logger("follow").info("添加视频至follow_feeds成功:{}\n", video_title)
                         cls.get_video_count.append(video_id)
 
@@ -577,7 +577,7 @@ class Follow:
                 #     Common.logger(log_type).info("不满足下载规则:{},删除成功\n", download_video_title)
                 #     return
                 # 从已下载视频表中去重
-                elif download_video_id in [j for m in Feishu.get_values_batch(
+                elif str(download_video_id) in [j for m in Feishu.get_values_batch(
                         log_type, "kuaishou", "3cd128") for j in m]:
                     # 删除行或列,可选 ROWS、COLUMNS
                     Feishu.dimension_range(log_type, "kuaishou", "wW5cyb", "ROWS", i + 1, i + 1)
@@ -648,7 +648,8 @@ class Follow:
                     Common.logger(log_type).info("视频:{},下载/上传成功\n", download_video_title)
                     return
         except Exception as e:
-            Common.logger(log_type).error("download_publish异常:{}\n", e)
+            Feishu.dimension_range(log_type, "kuaishou", "wW5cyb", "ROWS", 2, 2)
+            Common.logger(log_type).error("download_publish异常,删除成功:{}\n", e)
 
     # 执行下载/上传
     @classmethod
@@ -670,4 +671,4 @@ if __name__ == "__main__":
     # Follow.get_videos_from_person("follow", "2413743952")
     # Follow.get_follow_users_to_feishu('follow')
     # Follow.get_follow_users('follow')
-    Follow.get_videos_from_follow('follow')
+    Follow.get_videos_from_follow('follow', 'dev')

+ 12 - 11
main/recommend_list.py

@@ -10,10 +10,12 @@ import sys
 import time
 import requests
 import urllib3
+
 sys.path.append(os.getcwd())
 from main.common import Common
 from main.feishu_lib import Feishu
 from main.publish import Publish
+
 proxies = {"http": None, "https": None}
 
 
@@ -158,12 +160,11 @@ class KuaiShou:
                     title3 = title_split3[-1]
 
                 video_title = title3.strip().replace("\n", "") \
-                    .replace("/", "").replace("快手", "").replace(" ", "") \
-                    .replace(" ", "").replace("&NBSP", "").replace("\r", "") \
-                    .replace("#", "").replace(".", "。").replace("\\", "") \
-                    .replace(":", "").replace("*", "").replace("?", "") \
-                    .replace("?", "").replace('"', "").replace("<", "") \
-                    .replace(">", "").replace("|", "")[:40]
+                                  .replace("/", "").replace("快手", "").replace(" ", "").replace(" ", "") \
+                                  .replace("&NBSP", "").replace("\r", "").replace("#", "").replace(".", "。") \
+                                  .replace("\\", "").replace(":", "").replace("*", "").replace("?", "") \
+                                  .replace("?", "").replace('"', "").replace("<", "").replace(">", "").replace("|", "")[
+                              :40]
 
                 if "photoId" not in feeds[i]:
                     video_id = "0"
@@ -260,10 +261,10 @@ class KuaiShou:
                 elif any(word if word in kuaishou_title else False for word in cls.sensitive_words()) is True:
                     Common.logger(log_type).info("视频已中敏感词:{}\n".format(kuaishou_title))
                 # 从 云文档 去重:https://w42nne6hzg.feishu.cn/sheets/shtcnp4SaJt37q6OOOrYzPMjQkg?sheet=3cd128
-                elif video_id in [j for m in Feishu.get_values_batch(log_type, "kuaishou", "3cd128") for j in m]:
+                elif str(video_id) in [j for m in Feishu.get_values_batch(log_type, "kuaishou", "3cd128") for j in m]:
                     Common.logger(log_type).info("该视频已下载:{}\n", video_title)
                 # 从 云文档 去重:https://w42nne6hzg.feishu.cn/sheets/shtcnp4SaJt37q6OOOrYzPMjQkg?sheet=JK6npf
-                elif video_id in [j for n in Feishu.get_values_batch(log_type, "kuaishou", "JK6npf") for j in n]:
+                elif str(video_id) in [j for n in Feishu.get_values_batch(log_type, "kuaishou", "JK6npf") for j in n]:
                     Common.logger(log_type).info("该视频已在feeds中:{}\n", video_title)
                 else:
                     # feeds工作表,插入首行
@@ -275,7 +276,7 @@ class KuaiShou:
                     # 看一看云文档,工作表 kanyikan_feeds_1 中写入数据
                     values = [[str(time.strftime("%Y/%m/%d %H:%M:%S", time.localtime(get_feeds_time))),
                                "推荐榜",
-                               video_id,
+                               str(video_id),
                                video_title,
                                video_play_cnt,
                                video_comment_cnt,
@@ -347,8 +348,8 @@ class KuaiShou:
                     Common.logger(log_type).info("空行,删除成功\n")
                     return
                 # 去重
-                elif download_video_id in [j for m in Feishu.get_values_batch(log_type, "kuaishou", "3cd128") for j in
-                                           m]:
+                elif str(download_video_id) in [j for m in Feishu.get_values_batch(log_type, "kuaishou", "3cd128") for j
+                                                in m]:
                     # 删除行或列,可选 ROWS、COLUMNS
                     Feishu.dimension_range(log_type, "kuaishou", "JK6npf", "ROWS", i + 1, i + 1)
                     Common.logger(log_type).info("该视频已下载:{},删除成功\n", download_video_title)