| 
														
															@@ -57,6 +57,11 @@ class ZhongQingKanDianRecommend: 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         self.LocalLog = Local.logger(self.platform, self.mode) 
														 | 
														
														 | 
														
															         self.LocalLog = Local.logger(self.platform, self.mode) 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         self.session = requests.session() 
														 | 
														
														 | 
														
															         self.session = requests.session() 
														 | 
													
												
											
												
													
														| 
														 | 
														
															  
														 | 
														
														 | 
														
															  
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+    def __del__(self): 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        if self.session: 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+            self.LocalLog.info("session 被正确关闭") 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+            self.session.close() 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+ 
														 | 
													
												
											
												
													
														| 
														 | 
														
															     def send_request(self, path, data): 
														 | 
														
														 | 
														
															     def send_request(self, path, data): 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         """发送带重试机制的API请求""" 
														 | 
														
														 | 
														
															         """发送带重试机制的API请求""" 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         for attempt in range(self.MAX_RETRIES): 
														 | 
														
														 | 
														
															         for attempt in range(self.MAX_RETRIES): 
														 | 
													
												
											
										
											
												
													
														 | 
														
															@@ -91,8 +96,8 @@ class ZhongQingKanDianRecommend: 
														 | 
													
												
											
												
													
														| 
														 | 
														
															             except Exception as e: 
														 | 
														
														 | 
														
															             except Exception as e: 
														 | 
													
												
											
												
													
														| 
														 | 
														
															                 tb_info = traceback.format_exc() 
														 | 
														
														 | 
														
															                 tb_info = traceback.format_exc() 
														 | 
													
												
											
												
													
														| 
														 | 
														
															                 self.LocalLog.error(f"{path}请求异常: {str(e)} \n {tb_info}") 
														 | 
														
														 | 
														
															                 self.LocalLog.error(f"{path}请求异常: {str(e)} \n {tb_info}") 
														 | 
													
												
											
												
													
														| 
														 | 
														
															- 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-            time.sleep(random.randint(5, 10)) 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+            if attempt < self.MAX_RETRIES - 1: 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+                time.sleep(random.randint(5, 10)) 
														 | 
													
												
											
												
													
														| 
														 | 
														
															  
														 | 
														
														 | 
														
															  
														 | 
													
												
											
												
													
														| 
														 | 
														
															         # 所有重试失败,记录错误并返回None 
														 | 
														
														 | 
														
															         # 所有重试失败,记录错误并返回None 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         self.LocalLog.error(f"{path}达到最大重试次数") 
														 | 
														
														 | 
														
															         self.LocalLog.error(f"{path}达到最大重试次数") 
														 | 
													
												
											
										
											
												
													
														 | 
														
															@@ -346,6 +351,6 @@ if __name__ == '__main__': 
														 | 
													
												
											
												
													
														| 
														 | 
														
															     ZhongQingKanDianRecommend( 
														 | 
														
														 | 
														
															     ZhongQingKanDianRecommend( 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         platform="zhongqingkandian", 
														 | 
														
														 | 
														
															         platform="zhongqingkandian", 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         mode="recommend", 
														 | 
														
														 | 
														
															         mode="recommend", 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-        rule_dict={'videos_cnt': {'min': 110, 'max': 0}, 'duration': {'min': 30, 'max': 1200}}, 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        rule_dict={'videos_cnt': {'min': 2, 'max': 0}, 'duration': {'min': 30, 'max': 1200}}, 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         user_list=[{"uid": 81522822, "link": "中青看点推荐", "nick_name": "免不了俗"}] 
														 | 
														
														 | 
														
															         user_list=[{"uid": 81522822, "link": "中青看点推荐", "nick_name": "免不了俗"}] 
														 | 
													
												
											
												
													
														| 
														 | 
														
															     ).run() 
														 | 
														
														 | 
														
															     ).run() 
														 |