mirror of
https://github.com/rumanzo/bt2qbt.git
synced 2024-11-22 02:12:39 +01:00
Bittorrent to qBittorrent pieces convert
( res['have'].unpack('b*').first.scan(/./).map {|i| (i.to_i(2)*1) }.pack('C'*npieces) from ruby)
This commit is contained in:
parent
788092a8ed
commit
6c853ae393
19
b2q.go
19
b2q.go
@ -14,6 +14,7 @@ import (
|
||||
//"github.com/davecgh/go-spew/spew"
|
||||
"log"
|
||||
"bufio"
|
||||
//"unicode/utf8"
|
||||
)
|
||||
|
||||
func decodetorrentfile(path string) map[string]interface{} {
|
||||
@ -56,6 +57,18 @@ func gethash(info interface{}) string {
|
||||
return hash
|
||||
}
|
||||
|
||||
func piecesconvert(s []byte ) (newpieces []byte) {
|
||||
var binString string
|
||||
for _, c := range s {
|
||||
binString = fmt.Sprintf("%s%b",binString, c)
|
||||
}
|
||||
for _, c := range binString {
|
||||
chr, _ := fmt.Printf("%c", int(c))
|
||||
newpieces = append(newpieces, byte(chr))
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func logic(key string, value interface{}, bitdir *string, wg *sync.WaitGroup) {
|
||||
defer wg.Done()
|
||||
newstructure := map[string]interface{}{"active_time": 0, "added_time": 0, "announce_to_dht": 0,
|
||||
@ -97,12 +110,10 @@ func logic(key string, value interface{}, bitdir *string, wg *sync.WaitGroup) {
|
||||
newstructure["added_time"] = local["added_on"]
|
||||
newstructure["completed_time"] = local["completed_on"]
|
||||
newstructure["info-hash"] = local["info"]
|
||||
//newstructure["pieces"] = local["info"]
|
||||
//newstructure["qBt-savePath"] = local["
|
||||
newstructure["qBt-tags"] = local["labels"]
|
||||
//newstructure["trackers"].([][]string)[0] = local["trackers"].([]string)
|
||||
newstructure["blocks per piece"] = torrentfile["info"].(map[string]interface{})["piece length"].(int64) / local["blocksize"].(int64)
|
||||
newstructure["pieces"] = piecesconvert([]byte(local["have"].(string)))
|
||||
encodetorrentfile("F:/test.fastdecode", newstructure)
|
||||
fmt.Println(newstructure)
|
||||
}
|
||||
|
||||
func main() {
|
||||
|
Loading…
Reference in New Issue
Block a user