From 9623f7012a3a59e26ae81bb3729cbc4c2e803d5e Mon Sep 17 00:00:00 2001 From: roger_home_pc Date: Wed, 16 Aug 2023 21:42:28 +0800 Subject: [PATCH] =?UTF-8?q?=E5=9F=BA=E6=9C=AC=E5=8F=AF=E4=BB=A5=E8=BF=90?= =?UTF-8?q?=E8=A1=8C=E4=BA=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- data_dict.py | 33 +++++++++++++++++---------------- db.py | 10 +++++++--- main.py | 15 +++++++++------ 3 files changed, 33 insertions(+), 25 deletions(-) diff --git a/data_dict.py b/data_dict.py index 8c13423..1ac7048 100644 --- a/data_dict.py +++ b/data_dict.py @@ -31,6 +31,22 @@ pwd_dict = { 'fulizifanji.club或者fulizifanji.xyz': ['fulizifanji.club', 'fulizifanji.xyz'] } +special_symbols = {'==1==': '<', + '==2==': '>', + '==3==': '|', + '==4==': '*', + '==5==': '?', + '==6==': '/', + '==7==': '\\', + '==8==': ':', + '==9==': "'", + '==10==': '"', + } + +escape_list = [('&', '&'), ('"', '"'), ('<', '<'), ('>', '>'), (' ', ' ')] + +check_size = {'.mp3': '.zip', } + ext_name_list = {'.7': '.7z', '.7z111': '.7z', '.7z12': '.7z', @@ -54,20 +70,5 @@ ext_name_list = {'.7': '.7z', '.下载后改成rar': '.rar', '.c': '.zip', '.word': '.rar', + '.7删除z': '.7z', } - -special_symbols = {'==1==': '<', - '==2==': '>', - '==3==': '|', - '==4==': '*', - '==5==': '?', - '==6==': '/', - '==7==': '\\', - '==8==': ':', - '==9==': "'", - '==10==': '"', - } - -escape_list = [('&', '&'), ('"', '"'), ('<', '<'), ('>', '>'), (' ', ' ')] - -check_size = {'.mp3': '.zip', } diff --git a/db.py b/db.py index d715d36..750c416 100644 --- a/db.py +++ b/db.py @@ -45,6 +45,10 @@ class DbAction: self.cursor.execute(SELECT_SQL, (_pwd,)) result = self.cursor.fetchone() if not result: - INSERT_SQL = "INSERT INTO scrapyh_pwd sp VALUES (pwd = %s);" - self.cursor.execute(INSERT_SQL, (_pwd,)) - self.conn.commit() + try: + INSERT_SQL = "INSERT INTO scrapyh_pwd (pwd) VALUES (%s);" + self.cursor.execute(INSERT_SQL, (_pwd,)) + self.conn.commit() + except Exception as e: + print(e) + self.conn.rollback() diff --git a/main.py b/main.py index 2077595..83a55d2 100644 --- a/main.py +++ b/main.py @@ -25,12 +25,15 @@ def start_unzip_task(): # 从数据库中获取数据 data = db_obj.get_data_by_id(folder) + print(data) if data and all_file['handle_zip']: # 解压, 增加适用历史密码重试的功能 if unzip_obj.unzip(all_file['handle_zip'][0], data['unzip_pwd']): file_obj.del_all_files(all_file['zip']) else: + print('password') + print(db_obj.get_available_pwd()) for pwd in db_obj.get_available_pwd(): result = unzip_obj.unzip(all_file['handle_zip'][0], pwd) if result: @@ -56,7 +59,7 @@ def start_unzip_task(): # 检查打印结果 if not all_file['handle_zip'] and not all_file['zip'] and not all_file['unknown']: - db_obj.insert_pwd(data['pwd']) + db_obj.insert_pwd(data['unzip_pwd']) unzip_succeed.append(folder) if folder not in unzip_succeed else '' logger.info('全部文件已解压') return result @@ -66,10 +69,10 @@ def start_unzip_task(): def start_collation_task(): logger.info('开始整理文件夹') for folder in file_obj.get_root_folder_list(): - file_col_obj = file.FilesCollection(folder) + folder_path = os.path.join(root_path, folder) + file_col_obj = file.FilesCollection(folder_path) if db_obj.get_data_by_id(folder) and folder not in unzip_failed: logger.info(f'开始整理 {folder}') - folder_path = os.path.join(root_path, folder) # 清除多余的文件 file_col_obj.clear_files() # 整理无效文件夹 @@ -86,16 +89,16 @@ def start_collation_task(): def main(): n = 1 # unzip_result = False - while n <= 3: + while n <= 5: logger.info(f'第{n}轮解压任务') unzip_result = start_unzip_task() if unzip_result: break n += 1 - logger.info('失败的任务:') - logger.info(', '.join(unzip_failed)) # if unzip_result: start_collation_task() + logger.info('失败的任务:') + logger.info(', '.join(unzip_failed)) if __name__ == '__main__':