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代碼里需要忽略這些位置

快速恢復文件和種子要一起移動


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM