|
@@ -7,7 +7,7 @@ import time
|
|
|
sys.path.append(os.getcwd())
|
|
|
|
|
|
from application.common import MysqlHelper, AliyunLogger
|
|
|
-from application.common.redis.pyredis import RedisClient
|
|
|
+# from application.common.redis.pyredis import RedisClient
|
|
|
|
|
|
|
|
|
class PiaoQuanPipeline(object):
|
|
@@ -25,7 +25,7 @@ class PiaoQuanPipeline(object):
|
|
|
self.mysql = MysqlHelper(env=env, mode=mode, platform=platform)
|
|
|
self.aliyun_log = AliyunLogger(platform=platform, mode=mode, env=env)
|
|
|
self.account = account
|
|
|
- self.red = RedisClient()
|
|
|
+ # self.red = RedisClient()
|
|
|
|
|
|
def publish_time_flag(self):
|
|
|
"""
|
|
@@ -135,6 +135,8 @@ class PiaoQuanPipeline(object):
|
|
|
return True
|
|
|
if self.platform == "yuannifuqichangzai" and self.mode == "recommend":
|
|
|
return True
|
|
|
+ if self.platform == "benshanzhufu" and self.mode == "recommend":
|
|
|
+ return True
|
|
|
if self.platform == "zuihaodesongni" and self.mode == "recommend":
|
|
|
return True
|
|
|
if self.platform == "tiantianjufuqi" and self.mode == "recommend":
|
|
@@ -154,6 +156,12 @@ class PiaoQuanPipeline(object):
|
|
|
video_time = self.mysql.select(sql=sql_2)[0][0].timestamp()
|
|
|
if int(time.time()) - video_time >= 86400 * 4:
|
|
|
return True
|
|
|
+ # 小年糕推荐流和祝福圈子推荐流 3 天去重一次
|
|
|
+ elif self.platform == "xiaoniangaotuijianliu" or self.platform == "zhufuquanzituijianliu":
|
|
|
+ sql_2 = f"""select create_time from crawler_video where out_video_id="{out_id}";"""
|
|
|
+ video_time = self.mysql.select(sql=sql_2)[0][0].timestamp()
|
|
|
+ if int(time.time()) - video_time >= 86400 * 3:
|
|
|
+ return True
|
|
|
self.aliyun_log.logging(
|
|
|
code="2002",
|
|
|
trace_id=self.trace_id,
|
|
@@ -164,26 +172,26 @@ class PiaoQuanPipeline(object):
|
|
|
return False
|
|
|
return True
|
|
|
|
|
|
- def mq_exists(self):
|
|
|
- """
|
|
|
- 检测 mq 是否已经发送过了
|
|
|
- :return:
|
|
|
- """
|
|
|
- if self.red.connect():
|
|
|
- index_txt = "{}-{}".format(self.platform, self.item['video_id'])
|
|
|
- index_md5 = hashlib.md5(index_txt.encode()).hexdigest()
|
|
|
- if self.red.select(index_md5):
|
|
|
- self.aliyun_log.logging(
|
|
|
- code="2007",
|
|
|
- trace_id=self.trace_id,
|
|
|
- message="该视频 mq 已经发送"
|
|
|
- )
|
|
|
- return False
|
|
|
- else:
|
|
|
- self.red.insert(index_md5, int(time.time()), 43200)
|
|
|
- return True
|
|
|
- else:
|
|
|
- return True
|
|
|
+ # def mq_exists(self):
|
|
|
+ # """
|
|
|
+ # 检测 mq 是否已经发送过了
|
|
|
+ # :return:
|
|
|
+ # """
|
|
|
+ # if self.red.connect():
|
|
|
+ # index_txt = "{}-{}".format(self.platform, self.item['video_id'])
|
|
|
+ # index_md5 = hashlib.md5(index_txt.encode()).hexdigest()
|
|
|
+ # if self.red.select(index_md5):
|
|
|
+ # self.aliyun_log.logging(
|
|
|
+ # code="2007",
|
|
|
+ # trace_id=self.trace_id,
|
|
|
+ # message="该视频 mq 已经发送"
|
|
|
+ # )
|
|
|
+ # return False
|
|
|
+ # else:
|
|
|
+ # self.red.insert(index_md5, int(time.time()), 43200)
|
|
|
+ # return True
|
|
|
+ # else:
|
|
|
+ # return True
|
|
|
|
|
|
def process_item(self):
|
|
|
"""
|
|
@@ -191,8 +199,8 @@ class PiaoQuanPipeline(object):
|
|
|
:return:
|
|
|
"""
|
|
|
# 判断该 mq 是否已经发了
|
|
|
- if not self.mq_exists():
|
|
|
- return False
|
|
|
+ # if not self.mq_exists():
|
|
|
+ # return False
|
|
|
if not self.publish_time_flag():
|
|
|
# 记录相关日志
|
|
|
return False
|