Bläddra i källkod

update push file

wangkun 3 år sedan
förälder
incheckning
fad7eca37e
4 ändrade filer med 15 tillägg och 15 borttagningar
  1. 1 1
      main/common.py
  2. 7 7
      main/download_kuaishou.py
  3. 6 6
      main/download_weishi.py
  4. 1 1
      main/publish.py

+ 1 - 1
main/common.py

@@ -125,7 +125,7 @@ class Common:
         :param t_name: 文件名
         :return: 文件内容
         """
-        with open("./txt/" + t_name, "r", encoding="utf8") as f:
+        with open("./txt/" + t_name, "r", encoding="UTF-8") as f:
             return f.readlines()
 
     @classmethod

+ 7 - 7
main/download_kuaishou.py

@@ -306,7 +306,7 @@ class KuaiShou:
                             else:
                                 basic_time = int(time.time())
                                 Common.crawler_log().info("添加视频信息至kuaishou_feeds.txt:{}".format(video_title))
-                                with open("./txt/kuaishou_feeds.txt", "a", encoding="utf8") as f_a:
+                                with open("./txt/kuaishou_feeds.txt", "a", encoding="UTF-8") as f_a:
                                     f_a.write(str(basic_time) + " + " +
                                               str(photo_id) + " + " +
                                               str(video_play_cnt) + " + " +
@@ -337,7 +337,7 @@ class KuaiShou:
                                 else:
                                     basic_time = int(time.time())
                                     Common.crawler_log().info("添加视频信息至kuaishou_feeds.txt:{}".format(video_title))
-                                    with open("./txt/kuaishou_feeds.txt", "a", encoding="utf8") as f_a:
+                                    with open("./txt/kuaishou_feeds.txt", "a", encoding="UTF-8") as f_a:
                                         f_a.write(str(basic_time) + " + " +
                                                   str(photo_id) + " + " +
                                                   str(video_play_cnt) + " + " +
@@ -396,18 +396,18 @@ class KuaiShou:
                 Common.download_method(text="video", d_name=download_video_title, d_url=download_video_url)
 
                 # 保存视频信息至 kuaishou_videoid.txt
-                with open("./txt/kuaishou_videoid.txt", "a", encoding="utf8") as fa:
+                with open("./txt/kuaishou_videoid.txt", "a", encoding="UTF-8") as fa:
                     fa.write(download_photo_id + "\n")
 
                 # 添加视频 ID 到 list,用于统计当次下载总数
                 cls.download_video_list.append(download_photo_id)
 
                 # # 保存视频信息至 {today}_kuaishou_videoid.txt
-                # with open("./txt/" + str(Common.today) + "_kuaishou_videoid.txt", "a", encoding="utf8") as fc:
+                # with open("./txt/" + str(Common.today) + "_kuaishou_videoid.txt", "a", encoding="UTF-8") as fc:
                 #     fc.write(download_photo_id + "\n")
 
                 # 保存视频信息至 "./videos/{download_video_title}/info.txt"
-                with open("./videos/" + download_video_title + "/info.txt", "a", encoding="utf8") as f_a:
+                with open("./videos/" + download_video_title + "/info.txt", "a", encoding="UTF-8") as f_a:
                     f_a.write(str(download_photo_id) + "\n" +
                               str(download_video_title) + "\n" +
                               str(download_video_duration) + "\n" +
@@ -433,7 +433,7 @@ class KuaiShou:
 
                 # 删除该视频在kuaishou_feeds.txt中的信息
                 Common.crawler_log().info("删除该视频在kuaishou_feeds.txt中的信息:{}".format(download_video_title))
-                with open("./txt/kuaishou_feeds.txt", "r", encoding="utf8") as f_r:
+                with open("./txt/kuaishou_feeds.txt", "r", encoding="UTF-8") as f_r:
                     lines = f_r.readlines()
                 with open("./txt/kuaishou_feeds.txt", "w", encoding="utf-8") as f_w:
                     for line in lines:
@@ -443,7 +443,7 @@ class KuaiShou:
             else:
                 # 删除该视频在 recommend.txt中的信息
                 Common.crawler_log().info("该视频不满足下载规则,删除在kuaishou_feeds.txt中的信息:{}".format(download_video_title))
-                with open("./txt/kuaishou_feeds.txt", "r", encoding="utf8") as f_r:
+                with open("./txt/kuaishou_feeds.txt", "r", encoding="UTF-8") as f_r:
                     lines = f_r.readlines()
                 with open("./txt/kuaishou_feeds.txt", "w", encoding="utf-8") as f_w:
                     for line in lines:

+ 6 - 6
main/download_weishi.py

@@ -211,7 +211,7 @@ class Weishi:
                                     and video_duration != "0" and video_id != "0":
                                 basic_time = int(time.time())
                                 Common.crawler_log().info("添加视频信息至weishi_feeds.txt:{}".format(video_title))
-                                with open("./txt/weishi_feeds.txt", "a", encoding="utf8") as f_a:
+                                with open("./txt/weishi_feeds.txt", "a", encoding="UTF-8") as f_a:
                                     f_a.write(str(basic_time) + " + " +
                                               str(video_id) + " + " +
                                               str(video_play_cnt) + " + " +
@@ -237,7 +237,7 @@ class Weishi:
                                 else:
                                     basic_time = int(time.time())
                                     Common.crawler_log().info("添加视频信息至weishi_feeds.txt:{}".format(video_title))
-                                    with open("./txt/weishi_feeds.txt", "a", encoding="utf8") as f_a:
+                                    with open("./txt/weishi_feeds.txt", "a", encoding="UTF-8") as f_a:
                                         f_a.write(str(basic_time) + " + " +
                                                   str(video_id) + " + " +
                                                   str(video_play_cnt) + " + " +
@@ -291,10 +291,10 @@ class Weishi:
                 # 下载视频
                 Common.download_method(text="video", d_name=download_video_title, d_url=download_video_url)
                 # 保存视频信息至 weishi_videoid.txt
-                with open("./txt/weishi_videoid.txt", "a", encoding="utf8") as fa:
+                with open("./txt/weishi_videoid.txt", "a", encoding="UTF-8") as fa:
                     fa.write(download_video_id + "\n")
                 # 保存视频信息至 "./videos/{download_video_title}/info.txt"
-                with open("./videos/" + download_video_title + "/info.txt", "a", encoding="utf8") as f_a:
+                with open("./videos/" + download_video_title + "/info.txt", "a", encoding="UTF-8") as f_a:
                     f_a.write(str(download_video_id) + "\n" +
                               str(download_video_title) + "\n" +
                               str(download_video_duration) + "\n" +
@@ -320,7 +320,7 @@ class Weishi:
 
                 # 删除该视频在weishi_feeds.txt中的信息
                 Common.crawler_log().info("删除该视频在weishi_feeds.txt中的信息:{}".format(download_video_title))
-                with open("./txt/weishi_feeds.txt", "r", encoding="utf8") as f_r:
+                with open("./txt/weishi_feeds.txt", "r", encoding="UTF-8") as f_r:
                     lines = f_r.readlines()
                 with open("./txt/weishi_feeds.txt", "w", encoding="utf-8") as f_w:
                     for line in lines:
@@ -330,7 +330,7 @@ class Weishi:
             else:
                 # 删除该视频在weishi_feeds.txt中的信息
                 Common.crawler_log().info("该视频不满足下载规则,删除在weishi_feeds.txt中的信息:{}".format(download_video_title))
-                with open("./txt/weishi_feeds.txt", "r", encoding="utf8") as f_r:
+                with open("./txt/weishi_feeds.txt", "r", encoding="UTF-8") as f_r:
                     lines = f_r.readlines()
                 with open("./txt/weishi_feeds.txt", "w", encoding="utf-8") as f_w:
                     for line in lines:

+ 1 - 1
main/publish.py

@@ -187,7 +187,7 @@ class Publish:
                         Common.crawler_log().info('dir fi_path = {}'.format(fi_path))
                         # 读取 info.txt,赋值给 data
                         if cls.info_file in fi:
-                            f = open(fi_path)
+                            f = open(fi_path, "r", encoding="UTF-8")
                             # 读取数据 数据准确性写入的时候保证 读取暂不处理
                             for i in range(14):
                                 line = f.readline()