|
@@ -27,9 +27,6 @@ class HourList:
|
|
|
hour_uid = wechat_sheet[5][1]
|
|
|
hour_token = wechat_sheet[6][1]
|
|
|
|
|
|
- # # 小时级数据表
|
|
|
- # hour_sheet = Feishu.get_values_batch("hour", "xiaoniangao", "ba0da4")
|
|
|
-
|
|
|
# 生成 uid、token
|
|
|
@classmethod
|
|
|
def get_uid_token(cls):
|
|
@@ -238,29 +235,18 @@ class HourList:
|
|
|
expression = cls.get_expression()
|
|
|
expression_list = expression[0]
|
|
|
char_list = expression[1]
|
|
|
- # print(f"expression_list:{expression_list}")
|
|
|
- # print(f"char_list:{char_list}")
|
|
|
# 随机取一个表情
|
|
|
expression = random.choice(expression_list)
|
|
|
- # print(f"expression:{expression}")
|
|
|
# 生成标题list[表情+title, title+表情]
|
|
|
expression_title_list = [expression + befor_video_title, befor_video_title + expression]
|
|
|
- # print(f"expression_title_list:{expression_title_list}")
|
|
|
# 从标题list中随机取一个标题
|
|
|
title_list1 = random.choice(expression_title_list)
|
|
|
- # print(f"title_list1:{title_list1}")
|
|
|
# 生成标题:原标题+符号
|
|
|
title_list2 = befor_video_title + random.choice(char_list)
|
|
|
- # print(f"befor_video_title:{befor_video_title}")
|
|
|
-
|
|
|
- # title_list3 = befor_video_title.replace(
|
|
|
- # ",", random.choice(expression_list)).replace(",", random.choice(expression_list))
|
|
|
# 表情和标题组合,与标题和符号组合,汇总成待使用的标题列表
|
|
|
title_list4 = [title_list2, title_list1]
|
|
|
- # print(f"title_list4:{title_list4}")
|
|
|
# 最终标题
|
|
|
video_title = random.choice(title_list4)
|
|
|
- # print(f"video_title:{video_title}\n")
|
|
|
else:
|
|
|
video_title = 0
|
|
|
|
|
@@ -288,12 +274,6 @@ class HourList:
|
|
|
else:
|
|
|
video_share_cnt = 0
|
|
|
|
|
|
- # # 评论量
|
|
|
- # if "comment_count" in feeds[i]:
|
|
|
- # video_comment_cnt = feeds[i]["comment_count"]
|
|
|
- # else:
|
|
|
- # video_comment_cnt = 0
|
|
|
-
|
|
|
# 时长
|
|
|
if "du" in feeds[i]:
|
|
|
video_duration = int(feeds[i]["du"] / 1000)
|
|
@@ -345,17 +325,11 @@ class HourList:
|
|
|
Common.logger(log_type).info("标题:{}", video_title)
|
|
|
Common.logger(log_type).info("视频ID:{}", video_id)
|
|
|
Common.logger(log_type).info("播放量:{}", video_play_cnt)
|
|
|
- # Common.logger(log_type).info("点赞量:{}", video_like_cnt)
|
|
|
- # Common.logger(log_type).info("分享量:{}", video_share_cnt)
|
|
|
- # Common.logger(log_type).info("评论数:{}", video_comment_cnt)
|
|
|
Common.logger(log_type).info("时长:{}秒", video_duration)
|
|
|
- # Common.logger(log_type).info("宽高:{}*{}", video_width, video_height)
|
|
|
Common.logger(log_type).info(
|
|
|
"视频发布时间:{}", time.strftime(
|
|
|
"%Y/%m/%d %H:%M:%S", time.localtime(int(video_send_time) / 1000)))
|
|
|
Common.logger(log_type).info("用户名:{}", user_name)
|
|
|
- # Common.logger(log_type).info("用户头像:{}", head_url)
|
|
|
- # Common.logger(log_type).info("封面:{}", cover_url)
|
|
|
Common.logger(log_type).info("播放地址:{}", video_url)
|
|
|
|
|
|
# 过滤无效视频
|
|
@@ -364,6 +338,7 @@ class HourList:
|
|
|
or cover_url == 0 or video_url == 0:
|
|
|
Common.logger(log_type).warning("无效视频")
|
|
|
|
|
|
+ # 抓取基础规则过滤
|
|
|
elif cls.download_rule(video_duration, video_width, video_height, video_play_cnt,
|
|
|
video_like_cnt, video_share_cnt, video_send_time) is False:
|
|
|
Common.logger(log_type).info("不满足基础门槛规则")
|
|
@@ -373,22 +348,27 @@ class HourList:
|
|
|
Common.logger(log_type).info("视频已中敏感词:{}".format(video_title))
|
|
|
time.sleep(1)
|
|
|
|
|
|
- # 从云文档中去重:https://w42nne6hzg.feishu.cn/sheets/shtcnYxiyQ1wLklo1W5Kdqc9cGh?sheet=yatRv2
|
|
|
+ # 从云文档中去重: 小时级_已下载表
|
|
|
elif video_id in [j for i in Feishu.get_values_batch(log_type, "xiaoniangao", "yatRv2") for j in i]:
|
|
|
Common.logger(log_type).info("该视频已下载:{}", video_title)
|
|
|
time.sleep(1)
|
|
|
|
|
|
- # 从云文档中去重:https://w42nne6hzg.feishu.cn/sheets/shtcnYxiyQ1wLklo1W5Kdqc9cGh?sheet=2zD8cv
|
|
|
- elif video_id in [j for i in Feishu.get_values_batch(log_type, "xiaoniangao", "2zD8cv") for j in i]:
|
|
|
+ # 从云文档中去重: 用户主页_已下载表
|
|
|
+ elif video_id in [j for i in Feishu.get_values_batch(log_type, "xiaoniangao", "Wu0CeL") for j in i]:
|
|
|
+ Common.logger(log_type).info("该视频已下载:{}", video_title)
|
|
|
+ time.sleep(1)
|
|
|
+
|
|
|
+ # 从云文档去重: 播放量_已下载表
|
|
|
+ elif video_id in [j for i in Feishu.get_values_batch(log_type, "xiaoniangao", "c85k1C") for j in i]:
|
|
|
Common.logger(log_type).info("该视频已下载:{}", video_title)
|
|
|
time.sleep(1)
|
|
|
|
|
|
- # 从云文档去重:https://w42nne6hzg.feishu.cn/sheets/shtcnYxiyQ1wLklo1W5Kdqc9cGh?sheet=ba0da4
|
|
|
+ # 从云文档去重: 小年糕小时级数据_feeds
|
|
|
elif video_id in [j for i in Feishu.get_values_batch("hour", "xiaoniangao", "ba0da4") for j in i]:
|
|
|
Common.logger(log_type).info("该视频已保存过:{}", video_title)
|
|
|
time.sleep(1)
|
|
|
+
|
|
|
else:
|
|
|
- Common.logger(log_type).info("该视频未下载,添加至feeds中:{}".format(video_title))
|
|
|
# feeds工作表,插入空行
|
|
|
time.sleep(1)
|
|
|
Feishu.insert_columns(log_type, "xiaoniangao", "ba0da4", "ROWS", 2, 3)
|
|
@@ -410,9 +390,10 @@ class HourList:
|
|
|
# 等待 1s,防止操作云文档太频繁,导致报错
|
|
|
time.sleep(1)
|
|
|
Feishu.update_values(log_type, "xiaoniangao", "ba0da4", "A3:K3", values)
|
|
|
+ Common.logger(log_type).info("视频添加至小时级数据_feeds成功:{}\n".format(video_title))
|
|
|
|
|
|
except Exception as e:
|
|
|
- Common.logger(log_type).error("获取小时榜视频列表异常:{}", e)
|
|
|
+ Common.logger(log_type).error("获取小时榜视频列表异常:{}\n", e)
|
|
|
|
|
|
# 更新小时榜数据
|
|
|
@classmethod
|
|
@@ -710,7 +691,7 @@ class HourList:
|
|
|
except Exception as e:
|
|
|
Common.logger(log_type).error("视频详情:{},异常:{}", v_title, e)
|
|
|
except Exception as e:
|
|
|
- Common.logger(log_type).error("获取小时榜数据异常:{}", e)
|
|
|
+ Common.logger(log_type).error("获取小时榜数据异常:{}\n", e)
|
|
|
|
|
|
# 下载/上传
|
|
|
@classmethod
|
|
@@ -803,11 +784,14 @@ class HourList:
|
|
|
# elif any(word if word in v_id else False for word in cls.sensitive_videoid_words()) is True:
|
|
|
# Common.logger(log_type).info("视频ID带字母:{}".format(v_id))
|
|
|
|
|
|
- # 从云文档中去重:https://w42nne6hzg.feishu.cn/sheets/shtcnYxiyQ1wLklo1W5Kdqc9cGh?sheet=yatRv2
|
|
|
+ # 从云文档中去重: 小时级_已下载表
|
|
|
elif v_id in [j for i in Feishu.get_values_batch(log_type, "xiaoniangao", "yatRv2") for j in i]:
|
|
|
Common.logger(log_type).info("该视频已下载:{}", v_title)
|
|
|
- # 从云文档中去重:https://w42nne6hzg.feishu.cn/sheets/shtcnYxiyQ1wLklo1W5Kdqc9cGh?sheet=yatRv2
|
|
|
- elif v_id in [j for i in Feishu.get_values_batch(log_type, "xiaoniangao", "2zD8cv") for j in i]:
|
|
|
+ # 从云文档中去重: 用户主页_已下载表
|
|
|
+ elif v_id in [j for i in Feishu.get_values_batch(log_type, "xiaoniangao", "Wu0CeL") for j in i]:
|
|
|
+ Common.logger(log_type).info("该视频已下载:{}", v_title)
|
|
|
+ # 从云文档中去重: 播放量_已下载表
|
|
|
+ elif v_id in [j for i in Feishu.get_values_batch(log_type, "xiaoniangao", "c85k1C") for j in i]:
|
|
|
Common.logger(log_type).info("该视频已下载:{}", v_title)
|
|
|
|
|
|
# 播放量大于 50000,直接下载
|
|
@@ -942,25 +926,6 @@ class HourList:
|
|
|
time.sleep(1)
|
|
|
Feishu.update_values(log_type, "xiaoniangao", "yatRv2", "F2:W2", values)
|
|
|
|
|
|
- # 保存视频信息到监控表
|
|
|
- Common.logger(log_type).info("添加视频到监控表:{}", v_title)
|
|
|
- # 插入空行
|
|
|
- time.sleep(1)
|
|
|
- Feishu.insert_columns(log_type, "monitor", "N7e2yI", "ROWS", 1, 2)
|
|
|
- # 视频信息写入监控表
|
|
|
- values = [[time.strftime("%Y/%m/%d %H:%M:%S", time.localtime(int(upload_time))),
|
|
|
- v_id,
|
|
|
- v_title,
|
|
|
- our_video_link,
|
|
|
- p_id,
|
|
|
- p_mid,
|
|
|
- hour_user_name,
|
|
|
- int(hour_video_duration) / 1000,
|
|
|
- time.strftime("%Y/%m/%d %H:%M:%S",
|
|
|
- time.localtime(int(hour_video_send_time) / 1000)),
|
|
|
- hour_play_cnt]]
|
|
|
- time.sleep(1)
|
|
|
- Feishu.update_values(log_type, "monitor", "N7e2yI", "F2:O2", values)
|
|
|
except Exception as e:
|
|
|
Common.logger(log_type).error("下载视频异常:{}", e)
|
|
|
|
|
@@ -1097,33 +1062,12 @@ class HourList:
|
|
|
hour_video_url]]
|
|
|
time.sleep(1)
|
|
|
Feishu.update_values(log_type, "xiaoniangao", "yatRv2", "F2:W2", values)
|
|
|
-
|
|
|
- # 保存视频信息到监控表
|
|
|
- Common.logger(log_type).info("添加视频到监控表:{}", v_title)
|
|
|
- # 插入空行
|
|
|
- time.sleep(1)
|
|
|
- Feishu.insert_columns(log_type, "monitor", "N7e2yI", "ROWS", 1, 2)
|
|
|
- # 视频信息写入监控表
|
|
|
- values = [[time.strftime("%Y/%m/%d %H:%M:%S", time.localtime(int(upload_time))),
|
|
|
- v_id,
|
|
|
- v_title,
|
|
|
- our_video_link,
|
|
|
- p_id,
|
|
|
- p_mid,
|
|
|
- hour_user_name,
|
|
|
- int(hour_video_duration) / 1000,
|
|
|
- time.strftime("%Y/%m/%d %H:%M:%S",
|
|
|
- time.localtime(int(hour_video_send_time) / 1000)),
|
|
|
- hour_play_cnt]]
|
|
|
- time.sleep(1)
|
|
|
- Feishu.update_values(log_type, "monitor", "N7e2yI", "F2:O2", values)
|
|
|
except Exception as e:
|
|
|
Common.logger(log_type).error("下载视频异常:{}", e)
|
|
|
elif int(ten_cnt) >= 2000 and int(fifteen_cnt) >= 2000:
|
|
|
Common.logger(log_type).info(
|
|
|
"10:00 and 15:00 数据上升量:{} and {} >= 2000", ten_cnt, fifteen_cnt)
|
|
|
Common.logger(log_type).info("满足下载规则,开始下载视频")
|
|
|
-
|
|
|
try:
|
|
|
url = "https://kapi.xiaoniangao.cn/profile/get_profile_by_id"
|
|
|
headers = {
|
|
@@ -1251,33 +1195,12 @@ class HourList:
|
|
|
hour_video_url]]
|
|
|
time.sleep(1)
|
|
|
Feishu.update_values(log_type, "xiaoniangao", "yatRv2", "F2:W2", values)
|
|
|
-
|
|
|
- # 保存视频信息到监控表
|
|
|
- Common.logger(log_type).info("添加视频到监控表:{}", v_title)
|
|
|
- # 插入空行
|
|
|
- time.sleep(1)
|
|
|
- Feishu.insert_columns(log_type, "monitor", "N7e2yI", "ROWS", 1, 2)
|
|
|
- # 视频信息写入监控表
|
|
|
- values = [[time.strftime("%Y/%m/%d %H:%M:%S", time.localtime(int(upload_time))),
|
|
|
- v_id,
|
|
|
- v_title,
|
|
|
- our_video_link,
|
|
|
- p_id,
|
|
|
- p_mid,
|
|
|
- hour_user_name,
|
|
|
- int(hour_video_duration) / 1000,
|
|
|
- time.strftime("%Y/%m/%d %H:%M:%S",
|
|
|
- time.localtime(int(hour_video_send_time) / 1000)),
|
|
|
- hour_play_cnt]]
|
|
|
- time.sleep(1)
|
|
|
- Feishu.update_values(log_type, "monitor", "N7e2yI", "F2:O2", values)
|
|
|
except Exception as e:
|
|
|
Common.logger(log_type).error("下载视频异常:{}", e)
|
|
|
elif int(fifteen_cnt) >= 2000 and int(twenty_cnt) >= 2000:
|
|
|
Common.logger(log_type).info(
|
|
|
"15:00 and 20:00 数据上升量:{} and {} >= 2000", fifteen_cnt, twenty_cnt)
|
|
|
Common.logger(log_type).info("满足下载规则,开始下载视频")
|
|
|
-
|
|
|
try:
|
|
|
url = "https://kapi.xiaoniangao.cn/profile/get_profile_by_id"
|
|
|
headers = {
|
|
@@ -1405,33 +1328,12 @@ class HourList:
|
|
|
hour_video_url]]
|
|
|
time.sleep(1)
|
|
|
Feishu.update_values(log_type, "xiaoniangao", "yatRv2", "F2:W2", values)
|
|
|
-
|
|
|
- # 保存视频信息到监控表
|
|
|
- Common.logger(log_type).info("添加视频到监控表:{}", v_title)
|
|
|
- # 插入空行
|
|
|
- time.sleep(1)
|
|
|
- Feishu.insert_columns(log_type, "monitor", "N7e2yI", "ROWS", 1, 2)
|
|
|
- # 视频信息写入监控表
|
|
|
- values = [[time.strftime("%Y/%m/%d %H:%M:%S", time.localtime(int(upload_time))),
|
|
|
- v_id,
|
|
|
- v_title,
|
|
|
- our_video_link,
|
|
|
- p_id,
|
|
|
- p_mid,
|
|
|
- hour_user_name,
|
|
|
- int(hour_video_duration) / 1000,
|
|
|
- time.strftime("%Y/%m/%d %H:%M:%S",
|
|
|
- time.localtime(int(hour_video_send_time) / 1000)),
|
|
|
- hour_play_cnt]]
|
|
|
- time.sleep(1)
|
|
|
- Feishu.update_values(log_type, "monitor", "N7e2yI", "F2:O2", values)
|
|
|
except Exception as e:
|
|
|
Common.logger(log_type).error("下载视频异常:{}", e)
|
|
|
elif int(yesterday_twenty_cnt) >= 2000 and int(ten_cnt) >= 2000:
|
|
|
Common.logger(log_type).info("昨日20:00 and 今日10:00 数据上升量:{} and {} >= 2000",
|
|
|
yesterday_twenty_cnt, ten_cnt)
|
|
|
Common.logger(log_type).info("满足下载规则,开始下载视频")
|
|
|
-
|
|
|
try:
|
|
|
url = "https://kapi.xiaoniangao.cn/profile/get_profile_by_id"
|
|
|
headers = {
|
|
@@ -1559,34 +1461,15 @@ class HourList:
|
|
|
hour_video_url]]
|
|
|
time.sleep(1)
|
|
|
Feishu.update_values(log_type, "xiaoniangao", "yatRv2", "F2:W2", values)
|
|
|
-
|
|
|
- # 保存视频信息到监控表
|
|
|
- Common.logger(log_type).info("添加视频到监控表:{}", v_title)
|
|
|
- # 插入空行
|
|
|
- time.sleep(1)
|
|
|
- Feishu.insert_columns(log_type, "monitor", "N7e2yI", "ROWS", 1, 2)
|
|
|
- # 视频信息写入监控表
|
|
|
- values = [[time.strftime("%Y/%m/%d %H:%M:%S", time.localtime(int(upload_time))),
|
|
|
- v_id,
|
|
|
- v_title,
|
|
|
- our_video_link,
|
|
|
- p_id,
|
|
|
- p_mid,
|
|
|
- hour_user_name,
|
|
|
- int(hour_video_duration) / 1000,
|
|
|
- time.strftime("%Y/%m/%d %H:%M:%S",
|
|
|
- time.localtime(int(hour_video_send_time) / 1000)),
|
|
|
- hour_play_cnt]]
|
|
|
- time.sleep(1)
|
|
|
- Feishu.update_values(log_type, "monitor", "N7e2yI", "F2:O2", values)
|
|
|
except Exception as e:
|
|
|
Common.logger(log_type).error("下载视频异常:{}", e)
|
|
|
else:
|
|
|
Common.logger(log_type).info("上升量不满足下载规则")
|
|
|
except Exception as e:
|
|
|
- Common.logger(log_type).error("下载视频时,获取飞书信息异常:{}", e)
|
|
|
+ Common.logger(log_type).error("下载视频时,获取飞书信息异常:{}\n", e)
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
HourList.get_hour_list_feeds("hour")
|
|
|
- # HourList.get_expression("hour")
|
|
|
+
|
|
|
+ pass
|