| 
														
															@@ -24,10 +24,8 @@ from application.common.messageQueue import MQ 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 from application.common.log import AliyunLogger 
														 | 
														
														 | 
														
															 from application.common.log import AliyunLogger 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 from application.common.mysql import MysqlHelper 
														 | 
														
														 | 
														
															 from application.common.mysql import MysqlHelper 
														 | 
													
												
											
												
													
														| 
														 | 
														
															  
														 | 
														
														 | 
														
															  
														 | 
													
												
											
												
													
														| 
														 | 
														
															-video_view_count = 0 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-video_view_lists = [] 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+ 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 def video_view(content_id, account_id): 
														 | 
														
														 | 
														
															 def video_view(content_id, account_id): 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-    global video_view_count 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															     headers = { 
														 | 
														
														 | 
														
															     headers = { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         "Content-Type": "application/json" 
														 | 
														
														 | 
														
															         "Content-Type": "application/json" 
														 | 
													
												
											
												
													
														| 
														 | 
														
															     } 
														 | 
														
														 | 
														
															     } 
														 | 
													
												
											
										
											
												
													
														 | 
														
															@@ -52,8 +50,6 @@ def video_view(content_id, account_id): 
														 | 
													
												
											
												
													
														| 
														 | 
														
															             # 业务逻辑处理(示例) 
														 | 
														
														 | 
														
															             # 业务逻辑处理(示例) 
														 | 
													
												
											
												
													
														| 
														 | 
														
															             if code == 0: 
														 | 
														
														 | 
														
															             if code == 0: 
														 | 
													
												
											
												
													
														| 
														 | 
														
															                 print("请求成功") 
														 | 
														
														 | 
														
															                 print("请求成功") 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-                video_view_count += 1 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-                video_history(content_id) 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															             else: 
														 | 
														
														 | 
														
															             else: 
														 | 
													
												
											
												
													
														| 
														 | 
														
															                 print(f"请求失败,错误码: {code}, 消息: {msg}") 
														 | 
														
														 | 
														
															                 print(f"请求失败,错误码: {code}, 消息: {msg}") 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         else: 
														 | 
														
														 | 
														
															         else: 
														 | 
													
												
											
										
											
												
													
														 | 
														
															@@ -63,7 +59,7 @@ def video_view(content_id, account_id): 
														 | 
													
												
											
												
													
														| 
														 | 
														
															     except json.JSONDecodeError: 
														 | 
														
														 | 
														
															     except json.JSONDecodeError: 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         print("响应不是有效的 JSON 格式") 
														 | 
														
														 | 
														
															         print("响应不是有效的 JSON 格式") 
														 | 
													
												
											
												
													
														| 
														 | 
														
															  
														 | 
														
														 | 
														
															  
														 | 
													
												
											
												
													
														| 
														 | 
														
															-def video_history(): 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+def video_history(video_view_lists): 
														 | 
													
												
											
												
													
														| 
														 | 
														
															     headers = { 
														 | 
														
														 | 
														
															     headers = { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         "Content-Type": "application/json" 
														 | 
														
														 | 
														
															         "Content-Type": "application/json" 
														 | 
													
												
											
												
													
														| 
														 | 
														
															     } 
														 | 
														
														 | 
														
															     } 
														 | 
													
												
											
										
											
												
													
														 | 
														
															@@ -86,7 +82,6 @@ def video_history(): 
														 | 
													
												
											
												
													
														| 
														 | 
														
															             msg = result.get("msg") 
														 | 
														
														 | 
														
															             msg = result.get("msg") 
														 | 
													
												
											
												
													
														| 
														 | 
														
															             # 业务逻辑处理(示例) 
														 | 
														
														 | 
														
															             # 业务逻辑处理(示例) 
														 | 
													
												
											
												
													
														| 
														 | 
														
															             if code == 0: 
														 | 
														
														 | 
														
															             if code == 0: 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-                video_view_lists.clear() 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															                 print("请求成功") 
														 | 
														
														 | 
														
															                 print("请求成功") 
														 | 
													
												
											
												
													
														| 
														 | 
														
															             else: 
														 | 
														
														 | 
														
															             else: 
														 | 
													
												
											
												
													
														| 
														 | 
														
															                 print(f"请求失败,错误码: {code}, 消息: {msg}") 
														 | 
														
														 | 
														
															                 print(f"请求失败,错误码: {code}, 消息: {msg}") 
														 | 
													
												
											
										
											
												
													
														 | 
														
															@@ -153,11 +148,14 @@ class ZFQZTJLRecommend(object): 
														 | 
													
												
											
												
													
														| 
														 | 
														
															                     message="抓取单条视频失败,请求失败" 
														 | 
														
														 | 
														
															                     message="抓取单条视频失败,请求失败" 
														 | 
													
												
											
												
													
														| 
														 | 
														
															                     ), 
														 | 
														
														 | 
														
															                     ), 
														 | 
													
												
											
												
													
														| 
														 | 
														
															                 return 
														 | 
														
														 | 
														
															                 return 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+            video_view_lists = [] 
														 | 
													
												
											
												
													
														| 
														 | 
														
															             for index, video_obj in enumerate(response['data']['data'], 1): 
														 | 
														
														 | 
														
															             for index, video_obj in enumerate(response['data']['data'], 1): 
														 | 
													
												
											
												
													
														| 
														 | 
														
															                 try: 
														 | 
														
														 | 
														
															                 try: 
														 | 
													
												
											
												
													
														| 
														 | 
														
															                     self.aliyun_log.logging( 
														 | 
														
														 | 
														
															                     self.aliyun_log.logging( 
														 | 
													
												
											
												
													
														| 
														 | 
														
															                         code="1001", message="扫描到一条视频", data=video_obj 
														 | 
														
														 | 
														
															                         code="1001", message="扫描到一条视频", data=video_obj 
														 | 
													
												
											
												
													
														| 
														 | 
														
															                     ) 
														 | 
														
														 | 
														
															                     ) 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+                    vid = video_obj['id'] 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+                    video_view_lists.append(str(vid)) 
														 | 
													
												
											
												
													
														| 
														 | 
														
															                     self.process_video_obj(video_obj,title_rule) 
														 | 
														
														 | 
														
															                     self.process_video_obj(video_obj,title_rule) 
														 | 
													
												
											
												
													
														| 
														 | 
														
															                 except Exception as e: 
														 | 
														
														 | 
														
															                 except Exception as e: 
														 | 
													
												
											
												
													
														| 
														 | 
														
															                     self.aliyun_log.logging( 
														 | 
														
														 | 
														
															                     self.aliyun_log.logging( 
														 | 
													
												
											
										
											
												
													
														 | 
														
															@@ -170,6 +168,7 @@ class ZFQZTJLRecommend(object): 
														 | 
													
												
											
												
													
														| 
														 | 
														
															                     return 
														 | 
														
														 | 
														
															                     return 
														 | 
													
												
											
												
													
														| 
														 | 
														
															                 # time.sleep(random.randint(5, 10)) 
														 | 
														
														 | 
														
															                 # time.sleep(random.randint(5, 10)) 
														 | 
													
												
											
												
													
														| 
														 | 
														
															                 time.sleep(random.randint(5, 30)) 
														 | 
														
														 | 
														
															                 time.sleep(random.randint(5, 30)) 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+            video_history(video_view_lists) 
														 | 
													
												
											
												
													
														| 
														 | 
														
															  
														 | 
														
														 | 
														
															  
														 | 
													
												
											
												
													
														| 
														 | 
														
															     def process_video_obj(self, video_obj, title_rule): 
														 | 
														
														 | 
														
															     def process_video_obj(self, video_obj, title_rule): 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         """ 
														 | 
														
														 | 
														
															         """ 
														 | 
													
												
											
										
											
												
													
														 | 
														
															@@ -255,15 +254,10 @@ class ZFQZTJLRecommend(object): 
														 | 
													
												
											
												
													
														| 
														 | 
														
															             self.mq.send_msg(mq_obj) 
														 | 
														
														 | 
														
															             self.mq.send_msg(mq_obj) 
														 | 
													
												
											
												
													
														| 
														 | 
														
															             self.aliyun_log.logging(code="1002", message="成功发送至 ETL", data=mq_obj) 
														 | 
														
														 | 
														
															             self.aliyun_log.logging(code="1002", message="成功发送至 ETL", data=mq_obj) 
														 | 
													
												
											
												
													
														| 
														 | 
														
															             video_view(vid, mid) 
														 | 
														
														 | 
														
															             video_view(vid, mid) 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-            video_view_count += 1 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-            video_view_lists.append(str(vid)) 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-            if video_view_count % 4 == 0: 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-                video_history() 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															             self.aliyun_log.logging(code="1010", message="触发曝光", data=mq_obj) 
														 | 
														
														 | 
														
															             self.aliyun_log.logging(code="1010", message="触发曝光", data=mq_obj) 
														 | 
													
												
											
												
													
														| 
														 | 
														
															             if self.download_cnt >= int( 
														 | 
														
														 | 
														
															             if self.download_cnt >= int( 
														 | 
													
												
											
												
													
														| 
														 | 
														
															                     self.rule_dict.get("videos_cnt", {}).get("min", 200) 
														 | 
														
														 | 
														
															                     self.rule_dict.get("videos_cnt", {}).get("min", 200) 
														 | 
													
												
											
												
													
														| 
														 | 
														
															             ): 
														 | 
														
														 | 
														
															             ): 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-                video_history() 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															                 self.limit_flag = True 
														 | 
														
														 | 
														
															                 self.limit_flag = True 
														 | 
													
												
											
												
													
														| 
														 | 
														
															  
														 | 
														
														 | 
														
															  
														 | 
													
												
											
												
													
														| 
														 | 
														
															     def run(self): 
														 | 
														
														 | 
														
															     def run(self): 
														 | 
													
												
											
										
											
												
													
														 | 
														
															@@ -276,6 +270,7 @@ if __name__ == '__main__': 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         mode="recommend", 
														 | 
														
														 | 
														
															         mode="recommend", 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         rule_dict={}, 
														 | 
														
														 | 
														
															         rule_dict={}, 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         user_list=[{"uid": 75590470, "link": "zfqz推荐流_接口1", "nick_name": "做你的尾巴"}, {"uid": 75590471, "link": "zfqz推荐流_接口2", "nick_name": "能够相遇"}, {"uid": 75590472, "link": "zfqz推荐流_接口3", "nick_name": "一别两宽各生欢喜"}, {"uid": 75590473, "link": "zfqz推荐流_接口4", "nick_name": "惹火"}, {"uid": 75590475, "link": "zfqz推荐流_接口5", "nick_name": "顾九"}, {"uid": 75590476, "link": "zfqz推荐流_接口6", "nick_name": "宠一身脾气惯一身毛病"}], 
														 | 
														
														 | 
														
															         user_list=[{"uid": 75590470, "link": "zfqz推荐流_接口1", "nick_name": "做你的尾巴"}, {"uid": 75590471, "link": "zfqz推荐流_接口2", "nick_name": "能够相遇"}, {"uid": 75590472, "link": "zfqz推荐流_接口3", "nick_name": "一别两宽各生欢喜"}, {"uid": 75590473, "link": "zfqz推荐流_接口4", "nick_name": "惹火"}, {"uid": 75590475, "link": "zfqz推荐流_接口5", "nick_name": "顾九"}, {"uid": 75590476, "link": "zfqz推荐流_接口6", "nick_name": "宠一身脾气惯一身毛病"}], 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+ 
														 | 
													
												
											
												
													
														| 
														 | 
														
															     ) 
														 | 
														
														 | 
														
															     ) 
														 | 
													
												
											
												
													
														| 
														 | 
														
															     J.get_recommend_list() 
														 | 
														
														 | 
														
															     J.get_recommend_list() 
														 | 
													
												
											
												
													
														| 
														 | 
														
															     # J.logic() 
														 | 
														
														 | 
														
															     # J.logic() 
														 |