|
@@ -14,6 +14,12 @@ proxies = {"http": None, "https": None}
|
|
|
|
|
|
|
|
|
class HourList:
|
|
|
+ hour_x_b3_traceid = Feishu.get_range_value("person-log", "xiaoniangao", "dzcWHw", "B3:B3")[0]
|
|
|
+ hour_x_token_id = Feishu.get_range_value("person-log", "xiaoniangao", "dzcWHw", "B4:B4")[0]
|
|
|
+ hour_referer = Feishu.get_range_value("person-log", "xiaoniangao", "dzcWHw", "B5:B5")[0][0]["link"]
|
|
|
+ hour_uid = Feishu.get_range_value("person-log", "xiaoniangao", "dzcWHw", "B6:B6")[0]
|
|
|
+ hour_token = Feishu.get_range_value("person-log", "xiaoniangao", "dzcWHw", "B7:B7")[0]
|
|
|
+
|
|
|
# 过滤敏感词
|
|
|
@classmethod
|
|
|
def sensitive_words(cls):
|
|
@@ -41,9 +47,9 @@ class HourList:
|
|
|
"T", "U", "V", "W", "X", "Y", "Z"]
|
|
|
return words_list
|
|
|
|
|
|
- # 下载规则
|
|
|
+ # 基础门槛规则
|
|
|
@staticmethod
|
|
|
- def download_rule(d_duration, d_width, d_height, d_play_cnt, d_like_cnt, d_share_cnt):
|
|
|
+ def download_rule(d_duration, d_width, d_height, d_play_cnt, d_like_cnt, d_share_cnt, d_send_time):
|
|
|
"""
|
|
|
下载视频的基本规则
|
|
|
:param d_duration: 时长
|
|
@@ -52,14 +58,24 @@ class HourList:
|
|
|
:param d_play_cnt: 播放量
|
|
|
:param d_like_cnt: 点赞量
|
|
|
:param d_share_cnt: 分享量
|
|
|
+ :param d_send_time: 发布时间
|
|
|
:return: 满足规则,返回 True;反之,返回 False
|
|
|
"""
|
|
|
+ # 视频时长
|
|
|
if 600 >= int(float(d_duration)) >= 60:
|
|
|
+ # 宽或高
|
|
|
if int(d_width) >= 0 or int(d_height) >= 0:
|
|
|
- if int(d_play_cnt) >= 0:
|
|
|
+ # 播放量
|
|
|
+ if int(d_play_cnt) >= 5000:
|
|
|
+ # 点赞量
|
|
|
if int(d_like_cnt) >= 0:
|
|
|
+ # 分享量
|
|
|
if int(d_share_cnt) >= 0:
|
|
|
- return True
|
|
|
+ # 发布时间 <= 7 天
|
|
|
+ if int(time.time()) - int(d_send_time)/1000 <= 604800:
|
|
|
+ return True
|
|
|
+ else:
|
|
|
+ return False
|
|
|
else:
|
|
|
return False
|
|
|
else:
|
|
@@ -119,15 +135,15 @@ class HourList:
|
|
|
"""
|
|
|
url = "https://kapi.xiaoniangao.cn/trends/get_recommend_trends"
|
|
|
headers = {
|
|
|
- "x-b3-traceid": "bd267349bf41b",
|
|
|
- "X-Token-Id": "86f6d7cc2b2b6870004df5d16c82aaf3-1185665701",
|
|
|
- "uid": "8fde3c6c-c070-4379-bfc4-15c7e85139c9",
|
|
|
+ "x-b3-traceid": cls.hour_x_b3_traceid,
|
|
|
+ "X-Token-Id": cls.hour_x_token_id,
|
|
|
+ "uid": cls.hour_uid,
|
|
|
"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(0x18001432) NetType/WIFI Language/zh_CN',
|
|
|
- "Referer": "https://servicewechat.com/wxd7911e4c177690e4/617/page-frame.html"
|
|
|
+ "Referer": cls.hour_referer
|
|
|
}
|
|
|
data = {
|
|
|
"log_params": {
|
|
@@ -174,8 +190,8 @@ class HourList:
|
|
|
"session_id": "7bcce313-b57d-4305-8d14-6ebd9a1bad29"
|
|
|
},
|
|
|
"refresh": False,
|
|
|
- "token": "90747742180aeb22c0fe3a3c6a38f3d9",
|
|
|
- "uid": "8fde3c6c-c070-4379-bfc4-15c7e85139c9",
|
|
|
+ "token": cls.hour_token,
|
|
|
+ "uid": cls.hour_uid,
|
|
|
"proj": "ma",
|
|
|
"wx_ver": "8.0.20",
|
|
|
"code_ver": "3.62.0"
|
|
@@ -314,21 +330,10 @@ class HourList:
|
|
|
or cover_url == "" or video_url == "":
|
|
|
Common.logger().warning("无效视频")
|
|
|
|
|
|
- # 判断发布时间是否 > 7天
|
|
|
- elif int(time.time()) - int(video_send_time) / 1000 > 604800:
|
|
|
- Common.logger().info("发布时间大于7天", video_title)
|
|
|
-
|
|
|
- # 判断播放量是否 > 5000
|
|
|
- elif int(video_play_cnt) < 5000:
|
|
|
- Common.logger().info("该视频7天内播放量<5000:{}", video_title)
|
|
|
-
|
|
|
- # 判断视频 ID 长度,不大于 13 位
|
|
|
- elif len(str(video_id)) > 13:
|
|
|
- Common.logger().info("视频ID长度大于13位:{}", video_id)
|
|
|
-
|
|
|
- # 过滤带字母的视频ID
|
|
|
- elif any(word if word in video_id else False for word in cls.sensitive_videoid_words()) is True:
|
|
|
- Common.logger().info("视频ID带字母:{}".format(video_id))
|
|
|
+ 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().info("不满足基础门槛规则")
|
|
|
|
|
|
# 过滤敏感词
|
|
|
elif any(word if word in video_title else False for word in cls.sensitive_words()) is True:
|
|
@@ -441,15 +446,15 @@ class HourList:
|
|
|
|
|
|
url = "https://kapi.xiaoniangao.cn/profile/get_profile_by_id"
|
|
|
headers = {
|
|
|
- "x-b3-traceid": "bd267349bf41b",
|
|
|
- "X-Token-Id": "86f6d7cc2b2b6870004df5d16c82aaf3-1185665701",
|
|
|
- "uid": "8fde3c6c-c070-4379-bfc4-15c7e85139c9",
|
|
|
+ "x-b3-traceid": cls.hour_x_b3_traceid,
|
|
|
+ "X-Token-Id": cls.hour_x_token_id,
|
|
|
+ "uid": cls.hour_uid,
|
|
|
"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(0x18001432) NetType/WIFI Language/zh_CN',
|
|
|
- "Referer": "https://servicewechat.com/wxd7911e4c177690e4/617/page-frame.html"
|
|
|
+ "Referer": cls.hour_referer
|
|
|
}
|
|
|
data = {
|
|
|
"play_src": "1",
|
|
@@ -465,8 +470,8 @@ class HourList:
|
|
|
"no_follow": True,
|
|
|
"vid": v_id,
|
|
|
"hot_l1_comment": True,
|
|
|
- "token": "90747742180aeb22c0fe3a3c6a38f3d9",
|
|
|
- "uid": "8fde3c6c-c070-4379-bfc4-15c7e85139c9",
|
|
|
+ "token": cls.hour_token,
|
|
|
+ "uid": cls.hour_uid,
|
|
|
"proj": "ma",
|
|
|
"wx_ver": "8.0.20",
|
|
|
"code_ver": "3.62.0",
|
|
@@ -794,15 +799,20 @@ class HourList:
|
|
|
# 判断视频 ID 长度,不大于 13 位
|
|
|
if len(str(v_id)) > 13:
|
|
|
Common.logger().info("视频ID长度大于13位:{}", v_id)
|
|
|
+
|
|
|
+ # 判断视频时长:1-10min
|
|
|
elif int(v_duration) > 600 or int(v_duration) < 60:
|
|
|
Common.logger().info("视频时长不在 1-10分钟 之间")
|
|
|
+
|
|
|
# 过滤带字母的视频ID
|
|
|
elif any(word if word in v_id else False for word in cls.sensitive_videoid_words()) is True:
|
|
|
Common.logger().info("视频ID带字母:{}".format(v_id))
|
|
|
- # 从云文档中去重:https://w42nne6hzg.feishu.cn/sheets/shtcnYxiyQ1wLklo1W5Kdqc9cGh?sheet=yatRv2
|
|
|
+
|
|
|
+ # 从云文档中去重:https://w42nne6hzg.feishu.cn/sheets/shtcnYxiyQ1wLklo1W5Kdqc9cGh?sheet=yatRv2
|
|
|
elif v_id in [j for i in Feishu.get_values_batch("logs", "xiaoniangao", "yatRv2") for j in i]:
|
|
|
Common.logger().info("该视频已下载:{}", v_title)
|
|
|
time.sleep(1)
|
|
|
+
|
|
|
# 上升榜判断逻辑,任意时间段上升量>=5000,连续两个时间段上升量>=2000
|
|
|
elif int(ten_cnt) >= 5000 or int(fifteen_cnt) >= 5000 or int(twenty_cnt) >= 5000:
|
|
|
Common.logger().info("10:00 or 15:00 or 20:00 数据上升量:{} or {} or {} >= 5000",
|
|
@@ -812,15 +822,15 @@ class HourList:
|
|
|
try:
|
|
|
url = "https://kapi.xiaoniangao.cn/profile/get_profile_by_id"
|
|
|
headers = {
|
|
|
- "x-b3-traceid": "bd267349bf41b",
|
|
|
- "X-Token-Id": "86f6d7cc2b2b6870004df5d16c82aaf3-1185665701",
|
|
|
- "uid": "8fde3c6c-c070-4379-bfc4-15c7e85139c9",
|
|
|
+ "x-b3-traceid": cls.hour_x_b3_traceid,
|
|
|
+ "X-Token-Id": cls.hour_x_token_id,
|
|
|
+ "uid": cls.hour_uid,
|
|
|
"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(0x18001432) NetType/WIFI Language/zh_CN',
|
|
|
- "Referer": "https://servicewechat.com/wxd7911e4c177690e4/617/page-frame.html"
|
|
|
+ "Referer": cls.hour_referer
|
|
|
}
|
|
|
data = {
|
|
|
"play_src": "1",
|
|
@@ -836,8 +846,8 @@ class HourList:
|
|
|
"no_follow": True,
|
|
|
"vid": v_id,
|
|
|
"hot_l1_comment": True,
|
|
|
- "token": "90747742180aeb22c0fe3a3c6a38f3d9",
|
|
|
- "uid": "8fde3c6c-c070-4379-bfc4-15c7e85139c9",
|
|
|
+ "token": cls.hour_token,
|
|
|
+ "uid": cls.hour_uid,
|
|
|
"proj": "ma",
|
|
|
"wx_ver": "8.0.20",
|
|
|
"code_ver": "3.62.0",
|
|
@@ -941,15 +951,15 @@ class HourList:
|
|
|
try:
|
|
|
url = "https://kapi.xiaoniangao.cn/profile/get_profile_by_id"
|
|
|
headers = {
|
|
|
- "x-b3-traceid": "bd267349bf41b",
|
|
|
- "X-Token-Id": "86f6d7cc2b2b6870004df5d16c82aaf3-1185665701",
|
|
|
- "uid": "8fde3c6c-c070-4379-bfc4-15c7e85139c9",
|
|
|
+ "x-b3-traceid": cls.hour_x_b3_traceid,
|
|
|
+ "X-Token-Id": cls.hour_x_token_id,
|
|
|
+ "uid": cls.hour_uid,
|
|
|
"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(0x18001432) NetType/WIFI Language/zh_CN',
|
|
|
- "Referer": "https://servicewechat.com/wxd7911e4c177690e4/617/page-frame.html"
|
|
|
+ "Referer": cls.hour_referer
|
|
|
}
|
|
|
data = {
|
|
|
"play_src": "1",
|
|
@@ -965,8 +975,8 @@ class HourList:
|
|
|
"no_follow": True,
|
|
|
"vid": v_id,
|
|
|
"hot_l1_comment": True,
|
|
|
- "token": "90747742180aeb22c0fe3a3c6a38f3d9",
|
|
|
- "uid": "8fde3c6c-c070-4379-bfc4-15c7e85139c9",
|
|
|
+ "token": cls.hour_token,
|
|
|
+ "uid": cls.hour_uid,
|
|
|
"proj": "ma",
|
|
|
"wx_ver": "8.0.20",
|
|
|
"code_ver": "3.62.0",
|
|
@@ -1070,15 +1080,15 @@ class HourList:
|
|
|
try:
|
|
|
url = "https://kapi.xiaoniangao.cn/profile/get_profile_by_id"
|
|
|
headers = {
|
|
|
- "x-b3-traceid": "bd267349bf41b",
|
|
|
- "X-Token-Id": "86f6d7cc2b2b6870004df5d16c82aaf3-1185665701",
|
|
|
- "uid": "8fde3c6c-c070-4379-bfc4-15c7e85139c9",
|
|
|
+ "x-b3-traceid": cls.hour_x_b3_traceid,
|
|
|
+ "X-Token-Id": cls.hour_x_token_id,
|
|
|
+ "uid": cls.hour_uid,
|
|
|
"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(0x18001432) NetType/WIFI Language/zh_CN',
|
|
|
- "Referer": "https://servicewechat.com/wxd7911e4c177690e4/617/page-frame.html"
|
|
|
+ "Referer": cls.hour_referer
|
|
|
}
|
|
|
data = {
|
|
|
"play_src": "1",
|
|
@@ -1094,8 +1104,8 @@ class HourList:
|
|
|
"no_follow": True,
|
|
|
"vid": v_id,
|
|
|
"hot_l1_comment": True,
|
|
|
- "token": "90747742180aeb22c0fe3a3c6a38f3d9",
|
|
|
- "uid": "8fde3c6c-c070-4379-bfc4-15c7e85139c9",
|
|
|
+ "token": cls.hour_token,
|
|
|
+ "uid": cls.hour_uid,
|
|
|
"proj": "ma",
|
|
|
"wx_ver": "8.0.20",
|
|
|
"code_ver": "3.62.0",
|
|
@@ -1200,15 +1210,15 @@ class HourList:
|
|
|
try:
|
|
|
url = "https://kapi.xiaoniangao.cn/profile/get_profile_by_id"
|
|
|
headers = {
|
|
|
- "x-b3-traceid": "bd267349bf41b",
|
|
|
- "X-Token-Id": "86f6d7cc2b2b6870004df5d16c82aaf3-1185665701",
|
|
|
- "uid": "8fde3c6c-c070-4379-bfc4-15c7e85139c9",
|
|
|
+ "x-b3-traceid": cls.hour_x_b3_traceid,
|
|
|
+ "X-Token-Id": cls.hour_x_token_id,
|
|
|
+ "uid": cls.hour_uid,
|
|
|
"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(0x18001432) NetType/WIFI Language/zh_CN',
|
|
|
- "Referer": "https://servicewechat.com/wxd7911e4c177690e4/617/page-frame.html"
|
|
|
+ "Referer": cls.hour_referer
|
|
|
}
|
|
|
data = {
|
|
|
"play_src": "1",
|
|
@@ -1224,8 +1234,8 @@ class HourList:
|
|
|
"no_follow": True,
|
|
|
"vid": v_id,
|
|
|
"hot_l1_comment": True,
|
|
|
- "token": "90747742180aeb22c0fe3a3c6a38f3d9",
|
|
|
- "uid": "8fde3c6c-c070-4379-bfc4-15c7e85139c9",
|
|
|
+ "token": cls.hour_token,
|
|
|
+ "uid": cls.hour_uid,
|
|
|
"proj": "ma",
|
|
|
"wx_ver": "8.0.20",
|
|
|
"code_ver": "3.62.0",
|