wangkun 2 years ago
parent
commit
e5b28021a9

+ 73 - 128
README.md

@@ -1,135 +1,80 @@
-看一看+小程序爬虫:推荐页
+# 看一看+小程序爬虫
+1. git: https://git.yishihui.com/Server/crawler_kanyikan.git
+2. feishu: https://w42nne6hzg.feishu.cn/sheets/shtcngRPoDYAi24x52j2nDuHMih
 
+#### 软件架构
 python==3.10.0
 loguru==0.6.0
 oss2==2.15.0
 requests==2.27.1
 urllib3==1.26.9
 
-执行入口:
-
-cd ./crawler-kanyikan-Windows
-
-python3 main/run_XXX.py
-
-
-==========2022/6/29===========
-
-已下载视频表:预留前 5 列备用
-
-已下载视频表增加列:站内视频链接
-
-已下载视频,同步信息至监控表:https://w42nne6hzg.feishu.cn/sheets/shtcnlZWYazInhf7Z60jkbLRJyd?sheet=6fed97
-
-
-
-==========2022/6/17===========
-
-(recommend_feeds)0-24点
-
-- 7日内播放大于2万
-
-- 或播放大于15万
-
-- 新增:download_play_sendtime.py
-
-- 执行入口:run_download_play_sendtime.py
-
-
-
-==========2022/6/16===========
-
-- 1.凌晨0点-15点      3日内播放大于2万 爬取
-
-- 2.晚上15点-24点     15万播放爬取
-
-- 视频发布7日内,播放量大于2万
-
-- 视频时长40秒以上
-
-- 分辨率 宽或高大于720  
-
-- 分享量>0
-
-- 站内标题=看一看视频原标题 
-
-- 站内封面图=看一看视频原封面图
-
-
-==========2022/4/21===========
-
-- 视频发布7日内,播放量大于1万(当前时间 - 发布时间 <= 7 天)
-
-- 任务执行规则:
-
-    1.凌晨0点-10点      7日内播放大于1万 爬取
-
-    2.早上10点-20点     内容上升榜 爬取
-
-    3.晚上20点-24点     15万播放爬取
-
-
-
-==========2022/4/15===========
-
-- 视频发布3日内,播放量大于2万(当前时间 - 发布时间 <= 3 天)
-
-- 视频时长1分钟以上,10分钟以下
-
-- 分辨率 宽或高大于720
-
-- 分享量>0
-
-- 站内标题=看一看视频原标题
-
-- 站内封面图=看一看视频原封面图
-
-- 任务执行规则:
-
-    1.凌晨0点-10点      3日内播放大于2万 爬取
-
-    2.早上10点-20点     内容上升榜 爬取
-
-    3.晚上20点-24点     15万播放爬取
-
-
-
-==========2022/3/29===========
-
-1.凌晨5:00 - 21:00,跑上升榜爬虫(循环隔 1 小时,检查播放量>=1000)
-
-2.晚上21:00 - 5:00,跑播放量爬虫(播放量>=200000)
-
-3.视频下载后,立即上传
-
-
-==========2022/3/24===========
-
-1.周一至周五,跑上升榜爬虫(循环隔 1 小时,检查播放量>=1000)
-
-2.周六至周日,跑播放量爬虫(播放量>=200000)
-
-3.视频下载后,立即上传
-
-4.下周一时,暂停播放量爬虫,恢复上升榜爬虫
-
-
-==========2022/3/15===========
-
-1.拿到外网视频 list
-
-2.去重
-
-3.获取当前抓取时间、以及播放量、加上基本规则,存储本地:
-
-	3.1 分辨率,宽或者高 >= 720 或 无分辨
-
-	3.2 600 >= 时长 >= 60
-
-4.循环隔 1 小时,检查播放量 >=1000(当前播放量 - 1 小时前的播放量),开始抓取。同时从本地存储中删除,加入到去重文本中。
-
-5.下载总条数,先不限制
-
-6.下载时间:早上 8 点 - 晚上 21 点截止
-
-7.下载完成后立即上传
+#### 使用说明
+1. cd ./crawler-kanyikan-Windows
+2. python3 main/run_XXX.py
+
+#### 需求
+2022/11/09
+1. 合并推荐榜及朋友圈代码
+
+2022/6/29
+1. 已下载视频表:预留前 5 列备用 
+2. 已下载视频表增加列:站内视频链接 
+3. 已下载视频,同步信息至监控表:https://w42nne6hzg.feishu.cn/sheets/shtcnlZWYazInhf7Z60jkbLRJyd?sheet=6fed97
+
+2022/6/17
+1. 推荐榜运行时间: recommend_feeds 0-24点
+2. 7日内播放大于2万,或播放大于15万
+3. 新增:download_play_sendtime.py
+4. 执行入口:run_download_play_sendtime.py
+
+2022/6/16
+1. 凌晨0点-15点 3日内播放大于2万 爬取
+2. 晚上15点-24点     15万播放爬取
+3. 视频发布7日内,播放量大于2万
+4. 视频时长40秒以上
+5. 分辨率 宽或高大于720
+6. 分享量>0
+7. 站内标题=看一看视频原标题 
+8. 站内封面图=看一看视频原封面图
+
+2022/4/21
+1. 视频发布7日内,播放量大于1万(当前时间 - 发布时间 <= 7 天)
+2. 任务执行规则: 
+   1. 凌晨0点-10点 7日内播放大于1万 爬取
+   2. 早上10点-20点 内容上升榜 爬取
+   3. 晚上20点-24点     15万播放爬取
+
+2022/4/15
+1. 视频发布3日内,播放量大于2万(当前时间 - 发布时间 <= 3 天)
+2. 视频时长1分钟以上,10分钟以下
+3. 分辨率 宽或高大于720
+4. 分享量>0
+5. 站内标题=看一看视频原标题
+6. 站内封面图=看一看视频原封面图
+7. 任务执行规则:
+   1. 凌晨0点-10点      3日内播放大于2万 爬取
+   2. 早上10点-20点     内容上升榜 爬取
+   3. 晚上20点-24点     15万播放爬取
+
+2022/3/29
+1. 凌晨5:00 - 21:00,跑上升榜爬虫(循环隔 1 小时,检查播放量>=1000)
+2. 晚上21:00 - 5:00,跑播放量爬虫(播放量>=200000)
+3. 视频下载后,立即上传
+
+2022/3/24
+1. 周一至周五,跑上升榜爬虫(循环隔 1 小时,检查播放量>=1000)
+2. 周六至周日,跑播放量爬虫(播放量>=200000)
+3. 视频下载后,立即上传
+4. 下周一时,暂停播放量爬虫,恢复上升榜爬虫
+
+2022/3/15
+1. 拿到外网视频 list
+2. 去重
+3. 获取当前抓取时间、以及播放量、加上基本规则,存储本地:
+   1. 分辨率,宽或者高 >= 720 或 无分辨
+   2. 600 >= 时长 >= 60
+4. 循环隔 1 小时,检查播放量 >=1000(当前播放量 - 1 小时前的播放量),开始抓取。同时从本地存储中删除,加入到去重文本中。
+5. 下载总条数,先不限制
+6. 下载时间:早上 8 点 - 晚上 21 点截止
+7. 下载完成后立即上传

+ 3 - 0
chlsfiles/__init__.py

@@ -0,0 +1,3 @@
+# -*- coding: utf-8 -*-
+# @Author: wangkun
+# @Time: 2022/11/9

+ 9 - 11
main/common.py

@@ -13,7 +13,6 @@ import time
 import requests
 import urllib3
 from loguru import logger
-
 proxies = {"http": None, "https": None}
 
 
@@ -40,10 +39,7 @@ class Common:
             os.makedirs(log_path)
 
         # 日志文件名
-        if log_type == "recommend":
-            log_name = time.strftime("%Y-%m-%d", time.localtime(time.time())) + '-kanyikan-recommend.log'
-        else:
-            log_name = time.strftime("%Y-%m-%d", time.localtime(time.time())) + '-kanyikan.log'
+        log_name = time.strftime("%Y-%m-%d", time.localtime(time.time())) + '-kanyikan'+str(log_type)+'.log'
 
         # 日志不打印到控制台
         logger.remove(handler_id=None)
@@ -57,12 +53,12 @@ class Common:
 
         return logger
 
-    # 清除日志,保留最近 7 个文件
+    # 清除日志,保留最近 10 个文件
     @classmethod
     def del_logs(cls, log_type):
         """
         清除冗余日志文件
-        :return: 保留最近 7 个日志
+        :return: 保留最近 10 个日志
         """
         log_dir = "./logs/"
         all_files = sorted(os.listdir(log_dir))
@@ -72,15 +68,14 @@ class Common:
             if name == ".log":
                 all_logs.append(log)
 
-        if len(all_logs) <= 7:
+        if len(all_logs) <= 10:
             pass
         else:
-            for file in all_logs[:len(all_logs) - 7]:
+            for file in all_logs[:len(all_logs) - 10]:
                 os.remove(log_dir + file)
         cls.logger(log_type).info("清除冗余日志成功")
 
-        # 删除 charles 缓存文件,只保留最近的两个文件
-
+    # 删除 charles 缓存文件,只保留最近的7个文件
     @classmethod
     def del_charles_files(cls, log_type):
         # 目标文件夹下所有文件
@@ -98,6 +93,9 @@ class Common:
         视频封面,或视频播放地址:d_url
         下载保存路径:"./files/{d_title}/"
         """
+        videos_dir = r"./videos/"
+        if not os.path.exists(videos_dir):
+            os.mkdir(videos_dir)
         # 首先创建一个保存该视频相关信息的文件夹
         video_dir = "./videos/" + d_name + "/"
         if not os.path.exists(video_dir):

+ 431 - 0
main/kanyikan_moment.py

@@ -0,0 +1,431 @@
+# -*- coding: utf-8 -*-
+# @Author: wangkun
+# @Time: 2022/6/10
+import os
+import random
+import sys
+import time
+import requests
+import urllib3
+sys.path.append(os.getcwd())
+from main.feishu_lib import Feishu
+from main.common import Common
+from main.kanyikan_moment_publish import Publish
+proxies = {"http": None, "https": None}
+
+
+class Moment:
+    # 过滤词库
+    @classmethod
+    def sensitive_words(cls):
+        word_list = []
+        # 从云文档读取所有敏感词,添加到词库列表
+        lists = Feishu.get_values_batch("moment", "kanyikan", "rofdM5")
+        for i in lists:
+            for j in i:
+                # 过滤空的单元格内容
+                if j is None:
+                    pass
+                else:
+                    word_list.append(j)
+        return word_list
+
+    # 朋友圈视频 ID
+    @classmethod
+    def moment_videoids(cls):
+        try:
+            videoid_list = []
+            # 从云文档读取所有敏感词,添加到词库列表
+            lists = Feishu.get_values_batch("moment", "kanyikan", "iK58HX")
+            for i in lists:
+                for j in i:
+                    # 过滤空的单元格内容
+                    if j is None:
+                        pass
+                    else:
+                        videoid_list.append(j)
+            return videoid_list
+        except Exception as e:
+            Common.logger("moment").error("获取朋友圈视频ID异常:{}", e)
+            return "t3256lo1cmk"
+
+    # 抓取基础规则
+    @staticmethod
+    def download_rule(d_duration, d_width, d_height, d_play_cnt, d_like_cnt, d_share_cnt):
+        """
+        抓取基础规则
+        :param d_duration: 时长
+        :param d_width: 宽
+        :param d_height: 高
+        :param d_play_cnt: 播放量
+        :param d_like_cnt: 点赞量
+        :param d_share_cnt: 分享量
+        :return: 满足规则,返回 True;反之,返回 False
+        """
+        if int(float(d_duration)) >= 60:
+            if int(d_width) >= 0 or int(d_height) >= 0:
+                if int(d_play_cnt) >= 100000:
+                    if int(d_like_cnt) >= 0:
+                        if int(d_share_cnt) >= 0:
+                            return True
+                        else:
+                            return False
+                    else:
+                        return False
+                else:
+                    return False
+            return False
+        return False
+
+    # 获取推荐视频列表
+    @classmethod
+    def get_recommend(cls):
+        url = "https://search.weixin.qq.com/cgi-bin/recwxa/snsgetvideoinfo?"
+        headers = {
+            "content-type": "application/json",
+            "Accept-Encoding": "gzip,compress,br,deflate",
+            "User-Agent": "Mozilla/5.0 (iPhone; CPU iPhone OS 14_7_1 like Mac OS X)"
+                          " AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148"
+                          " MicroMessenger/8.0.20(0x18001442) NetType/WIFI Language/zh_CN",
+            "Referer": "https://servicewechat.com/wxbb9a805eb4f9533c/236/page-frame.html"
+        }
+        time.sleep(1)
+        videoid = random.choice(cls.moment_videoids())
+        # Common.logger("moment").info("videoid:{}", videoid)
+        params = {
+            "vid": videoid,
+            "openid": "1924336296754305",
+            "model": "iPhone 11<iPhone12,1>14.7.1",
+            "sharesearchid": "8406805193800900989",
+            "shareOpenid": "oh_m45YffSEGxvDH--6s6g9ZkPxg",
+        }
+        try:
+            urllib3.disable_warnings()
+            r = requests.get(url=url, headers=headers, params=params, proxies=proxies, verify=False)
+            # Common.logger("moment").info("response:{}", r.json())
+            if "rec_video_list" not in r.json()["data"]:
+                Common.logger("moment").warning("该视频无推荐视频列表:{}", videoid)
+            else:
+                feeds = r.json()["data"]["rec_video_list"]
+                for i in range(len(feeds)):
+                    # video_id
+                    if "vid" in feeds[i]:
+                        video_id = feeds[i]["vid"]
+                    else:
+                        video_id = 0
+
+                    # video_title
+                    if "title" in feeds[i]:
+                        video_title = feeds[i]["title"].strip().replace("\n", "") \
+                                .replace("/", "").replace("\\", "").replace("\r", "") \
+                                .replace(":", "").replace("*", "").replace("?", "") \
+                                .replace("?", "").replace('"', "").replace("<", "") \
+                                .replace(">", "").replace("|", "").replace(" ", "") \
+                                .replace("&NBSP", "").replace(".", "。").replace(" ", "") \
+                                .replace("小年糕", "").replace("#", "").replace("Merge", "")
+                    else:
+                        video_title = 0
+
+                    # video_play_cnt
+                    if "played_cnt" in feeds[i]:
+                        video_play_cnt = feeds[i]["played_cnt"]
+                    else:
+                        video_play_cnt = 0
+
+                    # video_comment_cnt
+                    if "comment_cnt" in feeds[i]:
+                        video_comment_cnt = feeds[i]["comment_cnt"]
+                    else:
+                        video_comment_cnt = 0
+
+                    # video_liked_cnt
+                    if "liked_cnt" in feeds[i]:
+                        video_liked_cnt = feeds[i]["liked_cnt"]
+                    else:
+                        video_liked_cnt = 0
+
+                    # video_share_cnt
+                    if "shared_cnt" in feeds[i]:
+                        video_share_cnt = feeds[i]["shared_cnt"]
+                    else:
+                        video_share_cnt = 0
+
+                    # video_duration
+                    if "duration" in feeds[i]:
+                        video_duration = feeds[i]["duration"]
+                    else:
+                        video_duration = 0
+
+                    # video_width / video_height
+                    if "width" in feeds[i] or "height" in feeds[i]:
+                        video_width = feeds[i]["width"]
+                        video_height = feeds[i]["height"]
+                    else:
+                        video_width = 0
+                        video_height = 0
+
+                    # video_send_time
+                    if "upload_time" in feeds[i]:
+                        video_send_time = feeds[i]["upload_time"]
+                    else:
+                        video_send_time = 0
+
+                    # user_name
+                    if "user_info" not in feeds[i]:
+                        user_name = 0
+                    elif "nickname" not in feeds[i]["user_info"]:
+                        user_name = 0
+                    else:
+                        user_name = feeds[i]["user_info"]["nickname"].strip().replace("\n", "")
+
+                    # user_id
+                    if "user_info" not in feeds[i]:
+                        user_id = 0
+                    elif "openid" not in feeds[i]["user_info"]:
+                        user_id = 0
+                    else:
+                        user_id = feeds[i]["user_info"]["openid"]
+
+                    # head_url
+                    if "user_info" not in feeds[i]:
+                        head_url = 0
+                    elif "headimg_url" not in feeds[i]["user_info"]:
+                        head_url = 0
+                    else:
+                        head_url = feeds[i]["user_info"]["headimg_url"]
+
+                    # cover_url
+                    if "cover_url" not in feeds[i]:
+                        cover_url = 0
+                    else:
+                        cover_url = feeds[i]["cover_url"]
+
+                    # video_url
+                    if "play_info" not in feeds[i]:
+                        video_url = 0
+                    elif "items" not in feeds[i]["play_info"]:
+                        video_url = 0
+                    else:
+                        video_url = feeds[i]["play_info"]["items"][-1]["play_url"]
+
+                    Common.logger("moment").info("video_id:{}", video_id)
+                    Common.logger("moment").info("video_title:{}", video_title)
+                    Common.logger("moment").info("user_name:{}", user_name)
+                    Common.logger("moment").info("video_play_cnt:{}", video_play_cnt)
+                    Common.logger("moment").info("video_liked_cnt:{}", video_liked_cnt)
+                    Common.logger("moment").info("video_share_cnt:{}", video_share_cnt)
+                    Common.logger("moment").info("video_duration:{}", video_duration)
+                    Common.logger("moment").info("video_width * video_height:{}*{}", video_width, video_height)
+                    Common.logger("moment").info("video_url:{}", video_url)
+
+                    # 过滤无效视频
+                    if video_id == 0 or video_title == 0 or video_duration == 0 or video_send_time == 0 or user_id == 0\
+                            or head_url == 0 or cover_url == 0 or video_url == 0:
+                        Common.logger("moment").warning("无效视频")
+                    # 抓取基础规则
+                    elif cls.download_rule(
+                            d_duration=video_duration, d_width=video_width, d_height=video_height,
+                            d_play_cnt=video_play_cnt, d_like_cnt=video_liked_cnt,
+                            d_share_cnt=video_share_cnt) is False:
+                        Common.logger("moment").info("不满足基础规则:{}", video_title)
+                    elif int(video_send_time) < 1659283200:
+                        Common.logger("moment").info('发布时间{}<2022-08-01', video_send_time)
+                    # 过滤词库
+                    elif any(word if word in video_title else False for word in cls.sensitive_words()) is True:
+                        Common.logger("moment").info("视频已中过滤词:{}".format(video_title))
+                    # 从已下载视频表去重:https://w42nne6hzg.feishu.cn/sheets/shtcngRPoDYAi24x52j2nDuHMih?sheet=20ce0c
+                    elif video_id in [j for m in Feishu.get_values_batch("moment", "kanyikan", "20ce0c") for j in m]:
+                        Common.logger("moment").info("该视频已下载:{}", video_title)
+                    # 从feeds视频表去重:https://w42nne6hzg.feishu.cn/sheets/shtcngRPoDYAi24x52j2nDuHMih?sheet=tGqZMX
+                    elif video_id in [j for n in Feishu.get_values_batch("moment", "kanyikan", "tGqZMX") for j in n]:
+                        Common.logger("moment").info("该视频已在moment_feeds中:{}", video_title)
+                    else:
+                        Common.logger("moment").info("该视频未下载,添加至moment_feeds中:{}", video_title)
+                        # 看一看+工作表,插入首行
+                        Feishu.insert_columns("moment", "kanyikan", "tGqZMX", "ROWS", 1, 2)
+                        # 获取当前时间
+                        get_feeds_time = int(time.time())
+                        # 准备写入云文档的数据
+                        values = [[time.strftime("%Y/%m/%d %H:%M:%S", time.localtime(get_feeds_time)),
+                                   "朋友圈",
+                                   video_id,
+                                   video_title,
+                                   video_play_cnt,
+                                   video_comment_cnt,
+                                   video_liked_cnt,
+                                   video_share_cnt,
+                                   video_duration,
+                                   str(video_width)+"*"+str(video_height),
+                                   time.strftime("%Y/%m/%d %H:%M:%S", time.localtime(video_send_time)),
+                                   user_name,
+                                   user_id,
+                                   head_url,
+                                   cover_url,
+                                   video_url]]
+                        time.sleep(1)
+                        Feishu.update_values("moment", "kanyikan", "tGqZMX", "A2:P2", values)
+
+        except Exception as e:
+            Common.logger("moment").error("获取视频列表异常:{}", e)
+
+    # 下载/上传视频
+    @classmethod
+    def download_publish(cls, env):
+        try:
+            moment_feeds = Feishu.get_values_batch("moment", "kanyikan", "tGqZMX")
+            for i in range(1, len(moment_feeds) + 1):
+                time.sleep(1)
+                # download_push_time = moment_feeds[i][0]
+                download_video_id = moment_feeds[i][2]
+                download_video_title = moment_feeds[i][3]
+                download_video_play_cnt = moment_feeds[i][4]
+                download_video_comment_cnt = moment_feeds[i][5]
+                download_video_like_cnt = moment_feeds[i][6]
+                download_video_share_cnt = moment_feeds[i][7]
+                download_video_duration = moment_feeds[i][8]
+                download_video_resolution = moment_feeds[i][9]
+                download_video_send_time = moment_feeds[i][10]
+                download_user_name = moment_feeds[i][11]
+                download_user_id = moment_feeds[i][12]
+                download_head_url = moment_feeds[i][13]
+                download_cover_url = moment_feeds[i][14]
+                download_video_url = moment_feeds[i][15]
+
+                Common.logger("moment").info("正在判断第{}行,视频:{}", i, download_video_title)
+
+                # 发布时间的时间戳格式(秒为单位)
+                v_send_time = int(time.mktime(time.strptime(download_video_send_time, "%Y/%m/%d %H:%M:%S")))
+                # 抓取时间的时间戳格式(秒为单位)
+                # v_push_time = int(time.mktime(time.strptime(download_push_time, "%Y/%m/%d %H:%M:%S")))
+
+                # 过滤空行及空标题视频
+                if download_video_id is None\
+                        or download_video_id == ""\
+                        or download_video_title is None\
+                        or download_video_title == "":
+                    Common.logger("moment").warning("标题为空或空行,删除")
+                    # 删除行或列,可选 ROWS、COLUMNS
+                    Feishu.dimension_range("moment", "kanyikan", "tGqZMX", "ROWS", i + 1, i + 1)
+                    return
+                # # 视频的抓取时间小于 2 天
+                # elif int(time.time()) - v_push_time > 172800:
+                #     Common.logger("moment").info("抓取时间超过2天:{}", download_video_title)
+                #     # 删除行或列,可选 ROWS、COLUMNS
+                #     Feishu.dimension_range("tGqZMX", "ROWS", i + 1, i + 1)
+                #     return
+                # 视频发布时间不小于 2021-06-01 00:00:00
+                elif v_send_time < 1622476800:
+                    Common.logger("moment").info(
+                        "发布时间小于2021年6月:{},{}", download_video_title, download_video_send_time)
+                    # 删除行或列,可选 ROWS、COLUMNS
+                    Feishu.dimension_range("moment", "kanyikan", "tGqZMX", "ROWS", i + 1, i + 1)
+                    return
+                # 从已下载视频表中去重
+                elif download_video_id in [j for m in Feishu.get_values_batch(
+                        "moment", "kanyikan", "20ce0c") for j in m]:
+                    Common.logger("moment").info("视频已下载:{}", download_video_title)
+                    # 删除行或列,可选 ROWS、COLUMNS
+                    Feishu.dimension_range("moment", "kanyikan", "tGqZMX", "ROWS", i + 1, i + 1)
+                    return
+                else:
+                    Common.logger("moment").info("开始下载视频:{}", download_video_title)
+                    # 下载封面
+                    Common.download_method(log_type="moment", text="cover",
+                                           d_name=str(download_video_title), d_url=str(download_cover_url))
+                    # 下载视频
+                    Common.download_method(log_type="moment", text="video",
+                                           d_name=str(download_video_title), d_url=str(download_video_url))
+                    # 保存视频信息至 "./videos/{download_video_title}/info.txt"
+                    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" +
+                                  str(download_video_play_cnt) + "\n" +
+                                  str(download_video_comment_cnt) + "\n" +
+                                  str(download_video_like_cnt) + "\n" +
+                                  str(download_video_share_cnt) + "\n" +
+                                  str(download_video_resolution) + "\n" +
+                                  str(int(time.mktime(
+                                      time.strptime(download_video_send_time, "%Y/%m/%d %H:%M:%S")))) + "\n" +
+                                  str(download_user_name) + "\n" +
+                                  str(download_head_url) + "\n" +
+                                  str(download_video_url) + "\n" +
+                                  str(download_cover_url) + "\n" +
+                                  "KANYIKAN_MOMENT")
+                    Common.logger("moment").info("==========视频信息已保存至info.txt==========")
+
+                    # 上传视频
+                    Common.logger("moment").info("开始上传视频:{}".format(download_video_title))
+                    our_video_id = Publish.upload_and_publish("moment", env, "play")
+                    our_video_link = "https://admin.piaoquantv.com/cms/post-detail/" + str(our_video_id) + "/info"
+                    Common.logger("moment").info("视频上传完成:{}", download_video_title)
+
+                    # 保存视频 ID 到云文档:https://w42nne6hzg.feishu.cn/sheets/shtcngRPoDYAi24x52j2nDuHMih?sheet=20ce0c
+                    Common.logger("moment").info("保存视频ID至云文档:{}", download_video_title)
+                    # 视频ID工作表,插入首行
+                    Feishu.insert_columns("moment", "kanyikan", "20ce0c", "ROWS", 1, 2)
+                    # 视频ID工作表,首行写入数据
+                    upload_time = int(time.time())
+                    values = [[time.strftime("%Y/%m/%d %H:%M:%S", time.localtime(upload_time)),
+                               "朋友圈",
+                               str(download_video_id),
+                               str(download_video_title),
+                               our_video_link,
+                               download_video_play_cnt,
+                               download_video_comment_cnt,
+                               download_video_like_cnt,
+                               download_video_share_cnt,
+                               download_video_duration,
+                               str(download_video_resolution),
+                               str(download_video_send_time),
+                               str(download_user_name),
+                               str(download_user_id),
+                               str(download_head_url),
+                               str(download_cover_url),
+                               str(download_video_url)]]
+                    time.sleep(1)
+                    Feishu.update_values("moment", "kanyikan", "20ce0c", "F2:W2", values)
+
+                    # 保存视频信息到监控表
+                    Common.logger("moment").info("添加视频到监控表:{}", download_video_title)
+                    # 插入空行
+                    time.sleep(1)
+                    Feishu.insert_columns("moment", "monitor", "6fed97", "ROWS", 1, 2)
+                    # 视频信息写入监控表
+                    values = [[time.strftime("%Y/%m/%d %H:%M:%S", time.localtime(int(upload_time))),
+                               str(download_video_id),
+                               download_video_title,
+                               our_video_link,
+                               download_video_duration,
+                               str(download_video_send_time),
+                               download_video_play_cnt]]
+                    time.sleep(1)
+                    Feishu.update_values("moment", "monitor", "6fed97", "F2:L2", values)
+
+                    # 删除行或列,可选 ROWS、COLUMNS
+                    Feishu.dimension_range("moment", "kanyikan", "tGqZMX", "ROWS", i + 1, i + 1)
+                    return
+        except Exception as e:
+            Common.logger("moment").error("下载视频异常:{}", e)
+            # 删除行或列,可选 ROWS、COLUMNS
+            Feishu.dimension_range("moment", "kanyikan", "tGqZMX", "ROWS", 2, 2)
+
+    # 执行下载/上传
+    @classmethod
+    def run_download_publish(cls, env):
+        try:
+            while True:
+                if len(Feishu.get_values_batch("moment", "kanyikan", "tGqZMX")) == 1:
+                    break
+                else:
+                    cls.download_publish(env)
+        except Exception as e:
+            Common.logger("moment").error("执行下载/上传异常:{}", e)
+
+
+if __name__ == "__main__":
+    kuaishou = Moment()
+    kuaishou.run_download_publish("dev")
+
+    pass

+ 256 - 0
main/kanyikan_moment_publish.py

@@ -0,0 +1,256 @@
+# -*- coding: utf-8 -*-
+# @Author: wangkun
+# @Time: 2022/6/10
+"""
+上传视频到阿里云 OSS
+上传视频到管理后台
+"""
+import json
+import os
+import random
+import time
+
+import oss2
+import requests
+import urllib3
+from main.common import Common
+
+proxies = {"http": None, "https": None}
+
+
+class Publish:
+    @classmethod
+    def publish_video_dev(cls, log_type, request_data):
+        """
+        loginUid  站内uid (随机)
+        appType  默认:888888
+        crawlerSrcId   站外视频ID
+        crawlerSrcCode   渠道(自定义 KYK)
+        crawlerSrcPublishTimestamp  视频原发布时间
+        crawlerTaskTimestamp   爬虫创建时间(可以是当前时间)
+        videoPath  视频oss地址
+        coverImgPath  视频封面oss地址
+        title  标题
+        totalTime  视频时长
+        viewStatus  视频的有效状态 默认1
+        versionCode  版本 默认1
+        :return:
+        """
+        # Common.logger(log_type).info('publish request data: {}'.format(request_data))
+        result = cls.request_post('https://videotest.yishihui.com/longvideoapi/crawler/video/send', request_data)
+        # Common.logger(log_type).info('publish result: {}'.format(result))
+        video_id = result["data"]["id"]
+        if result['code'] != 0:
+            Common.logger(log_type).error('pushlish failure msg = {}'.format(result['msg']))
+        else:
+            Common.logger(log_type).info('publish success video_id = : {}'.format(request_data['crawlerSrcId']))
+        return video_id
+
+    @classmethod
+    def publish_video_prod(cls, log_type, request_data):
+        """
+        loginUid  站内uid (随机)
+        appType  默认:888888
+        crawlerSrcId   站外视频ID
+        crawlerSrcCode   渠道(自定义 KYK)
+        crawlerSrcPublishTimestamp  视频原发布时间
+        crawlerTaskTimestamp   爬虫创建时间(可以是当前时间)
+        videoPath  视频oss地址
+        coverImgPath  视频封面oss地址
+        title  标题
+        totalTime  视频时长
+        viewStatus  视频的有效状态 默认1
+        versionCode  版本 默认1
+        :return:
+        """
+        result = cls.request_post('https://longvideoapi.piaoquantv.com/longvideoapi/crawler/video/send', request_data)
+        # Common.logger(log_type).info('publish result: {}'.format(result))
+        video_id = result["data"]["id"]
+        if result['code'] != 0:
+            Common.logger(log_type).error('pushlish failure msg = {}'.format(result['msg']))
+        else:
+            Common.logger(log_type).info('publish success video_id = : {}'.format(request_data['crawlerSrcId']))
+        return video_id
+
+    @classmethod
+    def request_post(cls, request_url, request_data):
+        """
+        post 请求 HTTP接口
+        :param request_url: 接口URL
+        :param request_data: 请求参数
+        :return: res_data json格式
+        """
+        urllib3.disable_warnings()
+        response = requests.post(url=request_url, data=request_data, proxies=proxies, verify=False)
+        if response.status_code == 200:
+            res_data = json.loads(response.text)
+            return res_data
+
+    # 以下代码展示了基本的文件上传、下载、罗列、删除用法。
+
+    # 首先初始化AccessKeyId、AccessKeySecret、Endpoint等信息。
+    # 通过环境变量获取,或者把诸如“<你的AccessKeyId>”替换成真实的AccessKeyId等。
+    #
+    # 以杭州区域为例,Endpoint可以是:
+    #   http://oss-cn-hangzhou.aliyuncs.com
+    #   https://oss-cn-hangzhou.aliyuncs.com
+    # 分别以HTTP、HTTPS协议访问。
+    access_key_id = os.getenv('OSS_TEST_ACCESS_KEY_ID', 'LTAIP6x1l3DXfSxm')
+    access_key_secret = os.getenv('OSS_TEST_ACCESS_KEY_SECRET', 'KbTaM9ars4OX3PMS6Xm7rtxGr1FLon')
+    bucket_name = os.getenv('OSS_TEST_BUCKET', 'art-pubbucket')
+    # endpoint = os.getenv('OSS_TEST_ENDPOINT', 'oss-cn-hangzhou-internal.aliyuncs.com')
+    endpoint = os.getenv('OSS_TEST_ENDPOINT', 'oss-cn-hangzhou.aliyuncs.com')
+
+    # 确认上面的参数都填写正确了
+    for param in (access_key_id, access_key_secret, bucket_name, endpoint):
+        assert '<' not in param, '请设置参数:' + param
+
+    # 创建Bucket对象,所有Object相关的接口都可以通过Bucket对象来进行
+    bucket = oss2.Bucket(oss2.Auth(access_key_id, access_key_secret), endpoint, bucket_name)
+
+    """
+    处理流程:
+    1. 定时(每天凌晨1点执行一次)循环files文件下的内容 结构:files -> 视频文件夹 -> 视频文件 + 封面图 + 基本信息
+    2. 视频文件和封面上传到oss
+    - 视频文件oss目录  longvideo/crawler_local/video/prod/文件名
+    - 视频封面oss目录  longvideo/crawler_local/image/prod/文件名
+    3. 发布视频
+    - 读取 基本信息 调用发布接口
+    """
+    # env 日期20220225 文件名
+    oss_file_path_video = r'longvideo/crawler_local/video/{}/{}/{}'
+    oss_file_path_image = r'longvideo/crawler_local/image/{}/{}/{}'
+
+    @classmethod
+    def put_file(cls, log_type, oss_file, local_file):
+        cls.bucket.put_object_from_file(oss_file, local_file)
+        Common.logger(log_type).info("put oss file = {}, local file = {} success".format(oss_file, local_file))
+
+    # 清除本地文件
+    @classmethod
+    def remove_local_file(cls, log_type, local_file):
+        os.remove(local_file)
+        Common.logger(log_type).info("remove local file = {} success".format(local_file))
+
+    # 清除本地文件夹
+    @classmethod
+    def remove_local_file_dir(cls, log_type, local_file):
+        os.rmdir(local_file)
+        Common.logger(log_type).info("remove local file dir = {} success".format(local_file))
+
+    local_file_path = './videos'
+    video_file = 'video'
+    image_file = 'image'
+    info_file = 'info'
+    uids_dev_up = [6267140]
+    uids_dev_play = [6267141]
+    uids_prod_up = [20631208, 20631209, 20631210, 20631211, 20631212,
+                    20631213, 20631214, 20631215, 20631216, 20631217]
+    uids_prod_play = [20631208, 20631209, 20631210, 20631211, 20631212,
+                      20631213, 20631214, 20631215, 20631216, 20631217,
+                      20631223, 20631224, 20631225, 20631226, 20631227]
+
+    @classmethod
+    def upload_and_publish(cls, log_type, env, job):
+        """
+        上传视频到 oss
+        :param log_type: 哪个日志
+        :param env: 测试环境:dev,正式环境:prod
+        :param job: 上升榜:up,播放量:play
+        """
+        Common.logger(log_type).info("upload_and_publish starting...")
+        today = time.strftime("%Y%m%d", time.localtime())
+        # videos 目录下的所有视频文件夹
+        files = os.listdir(cls.local_file_path)
+        for f in files:
+            try:
+                # 单个视频文件夹
+                fi_d = os.path.join(cls.local_file_path, f)
+                # 确认为视频文件夹
+                if os.path.isdir(fi_d):
+                    Common.logger(log_type).info('dir = {}'.format(fi_d))
+                    # 列出所有视频文件夹
+                    dir_files = os.listdir(fi_d)
+                    data = {'appType': '888888', 'crawlerSrcCode': 'KANYIKAN', 'viewStatus': '1', 'versionCode': '1'}
+                    now_timestamp = int(round(time.time() * 1000))
+                    data['crawlerTaskTimestamp'] = str(now_timestamp)
+                    global uid
+                    if env == "dev" and job == "up":
+                        uid = str(random.choice(cls.uids_dev_up))
+                    elif env == "dev" and job == "play":
+                        uid = str(random.choice(cls.uids_dev_play))
+                    elif env == "prod" and job == "up":
+                        uid = str(random.choice(cls.uids_prod_up))
+                    elif env == "prod" and job == "play":
+                        uid = str(random.choice(cls.uids_prod_play))
+                    data['loginUid'] = uid
+                    # 单个视频文件夹下的所有视频文件
+                    for fi in dir_files:
+                        # 视频文件夹下的所有文件路径
+                        fi_path = fi_d + '/' + fi
+                        Common.logger(log_type).info('dir fi_path = {}'.format(fi_path))
+                        # 读取 info.txt,赋值给 data
+                        if cls.info_file in fi:
+                            f = open(fi_path, "r", encoding="UTF-8")
+                            # 读取数据 数据准确性写入的时候保证 读取暂不处理
+                            for i in range(14):
+                                line = f.readline()
+                                line = line.replace('\n', '')
+                                if line is not None and len(line) != 0 and not line.isspace():
+                                    Common.logger(log_type).info("line = {}".format(line))
+                                    if i == 0:
+                                        data['crawlerSrcId'] = line
+                                    elif i == 1:
+                                        data['title'] = line
+                                    elif i == 2:
+                                        data['totalTime'] = line
+                                    elif i == 8:
+                                        data['crawlerSrcPublishTimestamp'] = line
+                                else:
+                                    Common.logger(log_type).warning("{} line is None".format(fi_path))
+                            f.close()
+                            # remove info.txt
+                            cls.remove_local_file(log_type, fi_path)
+                    # 刷新数据
+                    dir_files = os.listdir(fi_d)
+                    for fi in dir_files:
+                        fi_path = fi_d + '/' + fi
+                        Common.logger(log_type).info('dir fi_path = {}'.format(fi_path))
+                        # 上传oss
+                        if cls.video_file in fi:
+                            global oss_video_file
+                            if env == "dev":
+                                oss_video_file = cls.oss_file_path_video.format("dev", today, data['crawlerSrcId'])
+                            elif env == "prod":
+                                oss_video_file = cls.oss_file_path_video.format("prod", today, data['crawlerSrcId'])
+                            Common.logger(log_type).info("oss_video_file = {}".format(oss_video_file))
+                            cls.put_file(log_type, oss_video_file, fi_path)
+                            data['videoPath'] = oss_video_file
+                            Common.logger(log_type).info("videoPath = {}".format(oss_video_file))
+                        elif cls.image_file in fi:
+                            global oss_image_file
+                            if env == "dev":
+                                oss_image_file = cls.oss_file_path_image.format("env", today, data['crawlerSrcId'])
+                            elif env == "prod":
+                                oss_image_file = cls.oss_file_path_image.format("prod", today, data['crawlerSrcId'])
+                            Common.logger(log_type).info("oss_image_file = {}".format(oss_image_file))
+                            cls.put_file(log_type, oss_image_file, fi_path)
+                            data['coverImgPath'] = oss_image_file
+                            Common.logger(log_type).info("coverImgPath = {}".format(oss_image_file))
+                        # 全部remove
+                        cls.remove_local_file(log_type, fi_path)
+
+                    # 发布
+                    if env == "dev":
+                        video_id = cls.publish_video_dev(log_type, data)
+                    elif env == "prod":
+                        video_id = cls.publish_video_prod(log_type, data)
+                    else:
+                        video_id = cls.publish_video_dev(log_type, data)
+                    cls.remove_local_file_dir(log_type, fi_d)
+                    return video_id
+
+                else:
+                    Common.logger(log_type).error('file not a dir = {}'.format(fi_d))
+            except Exception as e:
+                Common.logger(log_type).exception('upload_and_publish error', e)

+ 4 - 4
main/get_feeds.py → main/kanyikan_recommend_feeds.py

@@ -36,7 +36,7 @@ def kanyikan_sensitive_words(log_type):
     return word_list
 
 
-def get_feeds(log_type):
+def get_recommend_feeds(log_type):
     """
     1.从看一看+小程序首页推荐,获取视频列表
     2.先在 https://w42nne6hzg.feishu.cn/sheets/shtcngRPoDYAi24x52j2nDuHMih?sheet=20ce0c 中去重
@@ -80,12 +80,12 @@ def get_feeds(log_type):
             Common.logger(log_type).info("获取视频list时,session过期,随机睡眠 31-50 秒")
             # 如果返回空信息,则随机睡眠 31-40 秒
             time.sleep(random.randint(31, 40))
-            get_feeds(log_type)
+            get_recommend_feeds(log_type)
         elif "items" not in response["data"]:
             Common.logger(log_type).info("获取视频list时,response:{},随机睡眠 1-3 分钟", response)
             # 如果返回空信息,则随机睡眠 1-3 分钟
             time.sleep(random.randint(60, 180))
-            get_feeds(log_type)
+            get_recommend_feeds(log_type)
         else:
             items = response["data"]["items"]
             for i in range(len(items)):
@@ -252,4 +252,4 @@ def get_feeds(log_type):
 
 
 if __name__ == "__main__":
-    get_feeds("recommend")
+    get_recommend_feeds("recommend")

+ 5 - 5
main/download_play.py → main/kanyikan_recommend_play.py

@@ -11,12 +11,12 @@ import time
 
 sys.path.append(os.getcwd())
 from main.common import Common
-from main.get_feeds import get_feeds
-from main.publish import Publish
+from main.kanyikan_recommend_feeds import get_recommend_feeds
+from main.kanyikan_recommend_publish import Publish
 from main.feishu_lib import Feishu
 
 
-class DownloadPlay:
+class RecommendPlay:
     # 下载规则
     @staticmethod
     def play_rule(play_width, play_height, play_duration, play_play_cnt):
@@ -176,6 +176,6 @@ class DownloadPlay:
 
 
 if __name__ == "__main__":
-    download_play = DownloadPlay()
-    get_feeds("recommend")
+    download_play = RecommendPlay()
+    get_recommend_feeds("recommend")
     download_play.run_download_play_video("dev")

+ 3 - 3
main/download_play_sendtime.py → main/kanyikan_recommend_play_sendtime.py

@@ -10,13 +10,13 @@ import urllib3
 sys.path.append(os.getcwd())
 from main.common import Common
 # from main.get_feeds import get_feeds
-from main.publish import Publish
+from main.kanyikan_recommend_publish import Publish
 from main.feishu_lib import Feishu
 
 proxies = {"http": None, "https": None}
 
 
-class DownloadPlaySendtime:
+class RecommendPlaySendtime:
 
     # 抓取基础规则,写入recommend_feeds表
     @staticmethod
@@ -244,5 +244,5 @@ class DownloadPlaySendtime:
 
 
 if __name__ == "__main__":
-    download_sendtime = DownloadPlaySendtime()
+    download_sendtime = RecommendPlaySendtime()
     download_sendtime.run_download_play_sendtime("dev")

+ 0 - 0
main/publish.py → main/kanyikan_recommend_publish.py


+ 5 - 5
main/download_sendtime.py → main/kanyikan_recommend_sendtime.py

@@ -16,14 +16,14 @@ import urllib3
 
 sys.path.append(os.getcwd())
 from main.common import Common
-from main.get_feeds import get_feeds
-from main.publish import Publish
+from main.kanyikan_recommend_feeds import get_recommend_feeds
+from main.kanyikan_recommend_publish import Publish
 from main.feishu_lib import Feishu
 
 proxies = {"http": None, "https": None}
 
 
-class DownloadSendtime:
+class RecommendSendtime:
 
     @staticmethod
     def send_time_rule(send_time_width, send_time_height, send_time_duration, send_time_share_cnt):
@@ -228,6 +228,6 @@ class DownloadSendtime:
 
 
 if __name__ == "__main__":
-    download_sendtime = DownloadSendtime()
-    get_feeds("recommend")
+    download_sendtime = RecommendSendtime()
+    get_recommend_feeds("recommend")
     download_sendtime.download_sendtime_video("dev")

+ 5 - 5
main/download_up.py → main/kanyikan_recommend_up.py

@@ -18,14 +18,14 @@ import requests
 import urllib3
 sys.path.append(os.getcwd())
 from main.common import Common
-from main.get_feeds import get_feeds
-from main.publish import Publish
+from main.kanyikan_recommend_feeds import get_recommend_feeds
+from main.kanyikan_recommend_publish import Publish
 from main.feishu_lib import Feishu
 
 proxies = {"http": None, "https": None}
 
 
-class DownloadUp:
+class RecommendUp:
 
     @staticmethod
     def up_rule(up_width, up_height, up_duration, up_play_cnt):
@@ -264,6 +264,6 @@ class DownloadUp:
 
 
 if __name__ == "__main__":
-    downloadup = DownloadUp()
-    get_feeds("recommend")
+    downloadup = RecommendUp()
+    get_recommend_feeds("recommend")
     downloadup.download_up_video("dev")

+ 0 - 121
main/run.py

@@ -1,121 +0,0 @@
-# -*- coding: utf-8 -*-
-# @Author: wangkun
-# @Time: 2022/4/18
-import datetime
-import os
-import random
-import sys
-import time
-sys.path.append(os.getcwd())
-from main.download_sendtime import DownloadSendtime
-from main.download_up import DownloadUp
-from main.common import Common
-from main.download_play import DownloadPlay
-from main.get_feeds import get_feeds
-
-
-class Main:
-
-    @classmethod
-    def download_play_job(cls):
-        """
-        播放量脚本任务
-        """
-        while True:
-            play_now = datetime.datetime.now()
-            # 指定时间结束抓取视频
-            if play_now.hour == 0:
-                Common.logger("recommend").info("结束抓取播放量视频\n")
-                time.sleep(3)
-                break
-            else:
-                # 获取视频信息,并下载
-                get_feeds("recommend")
-                DownloadPlay.run_download_play_video("prod")
-                # 请求随机间隔时间
-                time.sleep(random.randint(31, 40))
-
-        # 删除 charles 缓存文件
-        Common.del_charles_files("recommend")
-        # 删除多余日志
-        Common.del_logs("recommend")
-
-    @classmethod
-    def download_up_job(cls):
-        """
-        上升榜脚本任务
-        """
-        while True:
-            up_now = datetime.datetime.now()
-            # 指定时间结束抓取视频
-            if up_now.hour > 19:
-                Common.logger("recommend").info("结束抓取上升榜视频\n")
-                time.sleep(3)
-                break
-            else:
-                # 获取视频信息,并下载
-                get_feeds("recommend")
-                DownloadUp.download_up_video("prod")
-                # 请求随机间隔时间
-                time.sleep(random.randint(31, 40))
-
-        # 删除 charles 缓存文件
-        Common.del_charles_files("recommend")
-        # 删除多余日志
-        Common.del_logs("recommend")
-
-    @classmethod
-    def download_sendtime_job(cls):
-        """
-        发布时间榜脚本任务
-        """
-        while True:
-            sendtime_now = datetime.datetime.now()
-            # 指定时间结束抓取视频
-            if sendtime_now.hour > 14:
-                Common.logger("recommend").info("结束抓取7天榜单视频\n")
-                time.sleep(3)
-                break
-            else:
-                # 获取视频信息,并下载
-                get_feeds("recommend")
-                DownloadSendtime.run_download_sendtime_video()
-                # 请求随机间隔时间
-                time.sleep(random.randint(31, 40))
-
-        # 删除 charles 缓存文件
-        Common.del_charles_files("recommend")
-        # 删除多余日志
-        Common.del_logs("recommend")
-
-    @classmethod
-    def main(cls):
-        """
-        - 1.凌晨0点-10点      3日内播放大于2万 爬取
-        - 2.早上10点-20点     内容上升榜 爬取
-        - 3.晚上20点-24点     15万播放爬取
-        """
-        while True:
-            while True:
-                main_now = datetime.datetime.now()
-                if 14 >= main_now.hour >= 0:
-                    Common.logger("recommend").info("开始抓取7天榜单视频\n")
-                    time.sleep(1)
-                    cls.download_sendtime_job()
-                # elif 19 >= main_now.hour >= 10:
-                #     Common.logger().info("开始抓取上升榜视频\n")
-                #     time.sleep(1)
-                #     cls.download_up_job()
-                elif 24 >= main_now.hour >= 15:
-                    Common.logger("recommend").info("开始抓取播放量视频\n")
-                    time.sleep(1)
-                    cls.download_play_job()
-                else:
-                    Common.logger("recommend").info("结束今天抓取及上传任务\n")
-                    time.sleep(60)
-                    break
-
-
-if __name__ == "__main__":
-    main = Main()
-    main.main()

+ 33 - 0
main/run_kanyikan_moment.py

@@ -0,0 +1,33 @@
+# -*- coding: utf-8 -*-
+# @Author: wangkun
+# @Time: 2022/6/10
+import datetime
+import sys
+import os
+import random
+import time
+sys.path.append(os.getcwd())
+from main.common import Common
+from main.kanyikan_moment import Moment
+
+
+def main():
+    while True:
+        while True:
+            main_time = datetime.datetime.now()
+            if 1 >= main_time.hour >= 0:
+                break
+            else:
+                for i in range(20):
+                    Common.logger("moment").info("开始第{}/20次抓取看一看+朋友圈视频", i+1)
+                    Moment.get_recommend()
+                    time.sleep(random.randint(3, 5))
+
+                Common.logger("moment").info("开始分析并下载/上传视频")
+                Moment.run_download_publish("prod")
+                Common.del_logs("moment")
+                break
+
+
+if __name__ == "__main__":
+    main()

+ 4 - 4
main/run_recommend.py → main/run_kanyikan_recommend.py

@@ -8,8 +8,8 @@ import sys
 import time
 sys.path.append(os.getcwd())
 from main.common import Common
-from main.get_feeds import get_feeds
-from main.download_play_sendtime import DownloadPlaySendtime
+from main.kanyikan_recommend_feeds import get_recommend_feeds
+from main.kanyikan_recommend_play_sendtime import RecommendPlaySendtime
 
 
 class Main:
@@ -22,8 +22,8 @@ class Main:
                     break
                 else:
                     Common.logger("recommend").info("开始抓取看一看+推荐列表")
-                    get_feeds("recommend")
-                    DownloadPlaySendtime.run_download_play_sendtime("prod")
+                    get_recommend_feeds("recommend")
+                    RecommendPlaySendtime.run_download_play_sendtime("prod")
                     Common.del_logs("recommend")
                     Common.del_charles_files("recommend")
                     time.sleep(random.randint(3, 5))