Ubuntu下qBittorrent种子备份(提取)
Ubuntu下安装qBittorrent后,种子会自动保存在 /root/.local/share/qBittorrent/BT_backup 目录下
文件夹里的文件成对出现,后缀为.torrent和.fastresume
前者为原始种子文件,后者记录了种子的详细信息,包含tracker、添加时间、保存位置、速度限制、上传限制等
机器换了系统,重装了bt软件,种子太多,提取出来重新导入并做种
分析.fastresume文件,以下是一小段
qBt-tempPathDisabledi0e9:save_path10:/aqq/soul/9:seed_modei0e12:seeding_timei4372246e19
应该是冒号:起分割作用,前面的数字代表冒号后有几个字符,e应该是表示结束位置
save_path表示存储的位置
added_timei4212877e时间,从1970年开始的秒数
active_timei4212877活动时间,添加时间后开始算
只要知道存储位置就够了,原来的种子是一个分类存一个文件夹
用python把BT_backup这个文件夹里的种子分类存
1 # -*- coding: utf-8 -*- 2 import os 3 import re 4 import shutil 5 6 path = "C:\\Users\\Freya\\Desktop\\BT_backup" 7 #新建种子分类文件夹 8 tccf = os.path.join(path,'tccf_seed') 9 if not os.path.exists(tccf): 10 os.mkdir(tccf) 11 12 filelist = os.listdir(path) #该文件夹下所有的文件(包括文件夹) 13 count = 0 14 15 for file in filelist: 16 #.fast文件的完整路径 17 olddir = os.path.join(path,file) 18 #如果是文件夹则跳过 19 if os.path.isdir(olddir): 20 continue 21 #是fastresume文件 22 if os.path.splitext(file)[1]=='.fastresume': 23 f = open(olddir, 'rb') 24 file2text = f.read().decode('utf-8', 'ignore') 25 f.close() 26 #modify /aqq 27 mo_league = re.compile(r'/aqq/ccf/').search(file2text) 28 if mo_league != None: 29 #.torent文件的完整路径 30 torrentdir = os.path.join(path,os.path.splitext(file)[0] + '.torrent') 31 #move to each 32 shutil.move(olddir, tccf) 33 shutil.move(torrentdir, tccf) 34 count += 1 35 print(count)
要注意的问题:
.fastresume文件打开会有一段乱码,python代码里需要忽略这些位置
快速恢复文件和种子要一起移动