基本可以运行了

main
roger_home_pc 2 years ago
parent a20c2d2e43
commit 9623f7012a
  1. 33
      data_dict.py
  2. 10
      db.py
  3. 15
      main.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 = [('&amp;', '&'), ('&quot;', '"'), ('&lt;', '<'), ('&gt;', '>'), ('&nbsp;', ' ')]
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 = [('&amp;', '&'), ('&quot;', '"'), ('&lt;', '<'), ('&gt;', '>'), ('&nbsp;', ' ')]
check_size = {'.mp3': '.zip', }

10
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()

@ -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__':

Loading…
Cancel
Save