| 
					
				 | 
			
			
				@@ -5,6 +5,7 @@ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 公共方法,包含:生成log / 删除log / 获取session  / 下载方法 / 读取文件 / 统计下载数 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 """ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import json 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import shutil 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 from datetime import date, timedelta 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import datetime 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import os 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -82,6 +83,17 @@ class Common: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         # 删除 charles 缓存文件,只保留最近的两个文件 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    # 删除某个文件夹下所有文件 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    @classmethod 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    def del_files(cls, log_type): 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        filepath = "./videos/" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        del_list = os.listdir(filepath) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        for f in del_list: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            file_path = os.path.join(filepath, f) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if os.path.isdir(file_path): 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                shutil.rmtree(file_path) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        cls.logger(log_type).info("删除文件夹成功\n") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     # 封装下载视频或封面的方法 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     @classmethod 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     def download_method(cls, log_type, text, d_name, d_url): 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -91,6 +103,10 @@ class Common: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         视频封面,或视频播放地址:d_url 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         下载保存路径:"./files/{d_title}/" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         """ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        videos_path = "./videos/" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if not os.path.exists(videos_path): 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            os.mkdir(videos_path) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         # 首先创建一个保存该视频相关信息的文件夹 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         video_dir = "./videos/" + d_name + "/" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         if not os.path.exists(video_dir): 
			 |