较稳定版本

main
roger_home_pc 1 year ago
parent 4e6808c1c2
commit c5fb3554a9
  1. 11
      db.py
  2. 13
      main.py
  3. 4
      req.py

11
db.py

@ -37,6 +37,17 @@ class DbAction:
self.cursor.execute(query_sql, (data_id,))
self.conn.commit()
def get_retry(self):
query_sql = f"SELECT h.id, h.save_link, h.`code` FROM scrapyh h WHERE h.date IN ({self.date_list})"
ext_filter = " AND file_name = '链接密码错误'"
query_sql = query_sql + ext_filter
print(query_sql)
# 错误调试
# query_sql = query_sql + " AND id IN ('35334', '35335', '35336', '35337', '35338', '35339')"
self.cursor.execute(query_sql)
return self.cursor.fetchall()
def disconnect_db(self):
self.cursor.close()
self.conn.close()

@ -10,12 +10,13 @@ get_end_date = '2023-08-09'
# 整理链接格式
def format_link(link):
def format_link(link, code):
if '?pwd=' in link:
link = link[:-9]
# code = link[-4:]
if 'init?surl=' in link:
link = 'https://pan.baidu.com/s/1' + link[38:60]
return link
return link, code
# 封装通用方法
@ -25,9 +26,9 @@ def req(_data, req_obj, db_obj):
save_path = [base_temp_path, _data['cate'] + '_' + date_str + r'/', str(_data['id'])]
print('-' * 30 + str(_data['id']) + '-' * 30)
print(save_path)
link = format_link(_data['save_link'])
print(_data['save_link'], ' -> ', link, ' ', _data['code'])
result, name = req_obj.process(save_path, link, _data['code'])
link, code = format_link(_data['save_link'], _data['code'])
print(_data['save_link'], ' -> ', link, ' ', _data['code'], ' -> ', code)
result, name = req_obj.process(save_path, link, code)
if result:
db_obj.update_file_name(_data['id'], name)
print(f'{_data["id"]}保存成功' + '\n' * 2)
@ -69,6 +70,8 @@ def main():
db_obj.mark_failed(_data['id'])
print('重试后依然失败:')
print(failed_id)
print('请手动重试以下链接:')
print(db_obj.get_retry())
except Exception as e:
print(e)
finally:

@ -19,6 +19,7 @@ ERROR_CODES = {
'百度网盘 请输入提取码': '链接错误,缺少提取码',
-9: '链接错误,提取码错误或验证已过期',
-62: '链接错误尝试次数过多,请手动转存或稍后再试',
-65: '操作过于频繁,请您稍后重试',
105: '链接错误,链接格式不正确',
-4: '转存失败,无效登录。请退出账号在其他地方的登录',
-6: '转存失败,请用浏览器无痕模式获取 Cookie',
@ -168,6 +169,9 @@ class ReqAction:
if isinstance(base_path_list, list) and save_path not in [_dir['path'] for _dir in base_path_list]:
self.create_dir(save_path)
verified_links = self.verify_links(save_link, save_code)
if isinstance(verified_links, int):
if verified_links == -9:
return True, '链接密码错误'
if isinstance(verified_links, list):
result, name = self.transfer_files(verified_links, save_path)
if result == 0 or result == 4:

Loading…
Cancel
Save