[quote="Danzig"]
[quote="Douman"]
Still, i'm unable to understand how we should form:
piece_priority
pieces
@Danzig
Why in your script these variables are equal?
According to documentation:
piece_priority - string of bytes. Each byte is interpreted as an integer and is the priority of that piece.
pieces - A string with piece flags, one character per piece. Bit 1 means we have that piece. Bit 2 means we have verified that this piece is correct. This only applies when the torrent is in seed_mode.
[/quote]
Yeah, pieces means that we have a piece (or not), but despite the documentation bit 2 doesn't seem to matter much to qbittorent, so I just set it to 1 when we have the piece, 0 when we don't.
piece_priority is 0 when a the piece belongs to a file not to be downloaded, and 1 (and perhaps 2,3,4+) when it has to be/has been downloaded. File priority is set elsewhere, so I didn't really care for the priority of individual pieces, except for the not downloading bit.
So these two are equal in the script, because I considered this approach "good enough"
[/quote]
Ok, i see.
Well, one more thing, i cannot comprehend that fully:
res['have'].unpack('b*').first.scan(/./).map {|i| (i.to_i(2)*1) }.pack('C'*npieces)
Code: Select all
unpuck(b*) - returns list of strings with bits? What would be a separator? Or it as regex takes all 0 and 1?
first - takes the [0]?
scan(/./) - takes 1 number?
i.to_i(2)*1 - um... 1?
pack(C*npieces) - creates string from result of map?