mirror of
https://github.com/rumanzo/bt2qbt.git
synced 2024-11-22 02:12:39 +01:00
Created structure for new fastresume file
This commit is contained in:
parent
1e4df94c8c
commit
b39116b511
37
b2q.go
37
b2q.go
@ -1,26 +1,19 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"github.com/zeebo/bencode"
|
||||
"fmt"
|
||||
"github.com/zeebo/bencode"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
//"github.com/davecgh/go-spew"
|
||||
//"reflect"
|
||||
"crypto/sha1"
|
||||
"encoding/hex"
|
||||
"io"
|
||||
"strings"
|
||||
"sync"
|
||||
//"github.com/davecgh/go-spew/spew"
|
||||
)
|
||||
|
||||
type Torrent struct {
|
||||
name, path string
|
||||
prio []byte
|
||||
added int64
|
||||
labels, files []string
|
||||
}
|
||||
|
||||
func decodetorrentfile(path string) map[string]interface{} {
|
||||
dat, err := ioutil.ReadFile(path)
|
||||
if err != nil {
|
||||
@ -42,8 +35,23 @@ func gethash(info interface{}) string {
|
||||
return hash
|
||||
}
|
||||
|
||||
func logic(key string, value interface{}, storrents *[]*Torrent, bitdir *string, wg *sync.WaitGroup) {
|
||||
func logic(key string, value interface{}, bitdir *string, wg *sync.WaitGroup) {
|
||||
defer wg.Done()
|
||||
newstructure := map[string]interface{}{"active_time": new(int), "added_time": new(int), "announce_to_dht": new(int),
|
||||
"announce_to_lsd": new(int), "announce_to_trackers": new(int), "auto_managed": new(int),
|
||||
"banned_peers": new(string), "banned_peers6": new(string), "blocks per piece": new(int),
|
||||
"completed_time": new(int), "download_rate_limit": new(int), "file sizes": new([][]int),
|
||||
"file-format": new(int), "file-version": new(int), "file_priority": new([]int), "finished_time": new(int),
|
||||
"info-hash": new([]byte), "last_seen_complete": new(int), "libtorrent-version": new(string),
|
||||
"max_connections": new(int), "max_uploads": new(int), "num_complete": new(int), "num_downloaded": new(int),
|
||||
"num_incomplete": new(int), "paused": new(int), "peers": new(string), "peers6": new(string),
|
||||
"pieces": new([]byte), "qBt-category": new(string), "qBt-hasRootFolder": new(int), "qBt-name": new(string),
|
||||
"qBt-queuePosition": new(int), "qBt-ratioLimit": new(int), "qBt-savePath": new(string),
|
||||
"qBt-seedStatus": new(int), "qBt-seedingTimeLimit": new(int), "qBt-tags": new([]string),
|
||||
"qBt-tempPathDisabled": new(int), "save_path": new(string), "seed_mode": new(int), "seeding_time": new(int),
|
||||
"sequential_download": new(int), "super_seeding": new(int), "total_downloaded": new(int),
|
||||
"total_uploadedv": new(int), "trackers": new([][]string), "upload_rate_limit": new(int),
|
||||
}
|
||||
local := value.(map[string]interface{})
|
||||
uncastedlabel := local["labels"].([]interface{})
|
||||
newlabels := make([]string, len(uncastedlabel), len(uncastedlabel)+1)
|
||||
@ -65,10 +73,7 @@ func logic(key string, value interface{}, storrents *[]*Torrent, bitdir *string,
|
||||
files = append(files, strings.Join(newpath, "/"))
|
||||
}
|
||||
}
|
||||
ltorrent := Torrent{key, local["path"].(string), []byte(local["prio"].(string)),
|
||||
local["added_on"].(int64), newlabels, files}
|
||||
*storrents = append(*storrents, <orrent)
|
||||
fmt.Println(ltorrent.name, gethash(torrentfile["info"]))
|
||||
fmt.Println(newstructure)
|
||||
}
|
||||
|
||||
func main() {
|
||||
@ -78,13 +83,11 @@ func main() {
|
||||
|
||||
torrent := decodetorrentfile(bitfile)
|
||||
|
||||
var storrents []*Torrent
|
||||
for key, value := range torrent {
|
||||
if key != ".fileguard" && key != "rec" {
|
||||
wg.Add(1)
|
||||
go logic(key, value, &storrents, &bitdir, &wg)
|
||||
go logic(key, value, &bitdir, &wg)
|
||||
}
|
||||
}
|
||||
wg.Wait()
|
||||
fmt.Println(storrents[0])
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user