Rebuild
rebuild
#
Clases and functions for the rebuild or reassemble subcommand.
Re-assemble a torrent into the propper directory structure as indicated by a torrent meta file, and validate the contents of each file allong the way. Displays a progress bar for each torrent.
Assembler(metafiles: list, contents: list, dest: str)
#
Bases: CbMixin
Does most of the work in attempting the structure of torrentfiles.
Requires three paths as arguments. - torrent metafile or directory containing multiple meta files - directory containing the contents of meta file - directory where torrents will be re-assembled
Reassemble given torrent file from given cli arguments.
Rebuild metafiles and contents into their original directory structure as much as possible in the destination directory. Takes two paths as parameters, - file or directory containing 1 or more torrent meta files - path to where the contents are belived to be located.
PARAMETER | DESCRIPTION |
---|---|
metafiles |
path to torrent metafile or directory containing torrent metafiles.
TYPE:
|
contents |
path to content or directory containing content that belongs to torrentfile.
TYPE:
|
dest |
path to the directory where rebuild will take place.
TYPE:
|
Source code in torrentfile\rebuild.py
433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 |
|
assemble_torrents()
#
Assemble collection of torrent files into original structure.
RETURNS | DESCRIPTION |
---|---|
int
|
number of files copied |
Source code in torrentfile\rebuild.py
484 485 486 487 488 489 490 491 492 493 494 495 496 497 |
|
rebuild(metafile: Metadata) -> None
#
Build the torrent file structure from contents of directory.
Traverse contents dir and compare discovered files with files listed in torrent metadata and copy the matches to the destination directory respecting folder structures along the way.
Source code in torrentfile\rebuild.py
499 500 501 502 503 504 505 506 507 508 |
|
Metadata(path: str)
#
Class containing the metadata contents of a torrent file.
Construct metadata object for torrent info.
PARAMETER | DESCRIPTION |
---|---|
path |
path to the .torrent file.
TYPE:
|
Source code in torrentfile\rebuild.py
210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 |
|
extract()
#
Decode and extract information for the .torrent file.
Source code in torrentfile\rebuild.py
234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 |
|
rebuild(filemap: dict, dest: str)
#
Rebuild torrent file contents from filemap at dest.
Searches through the contents of the meta file and compares filenames with those in the filemap dict, and if found checks their contents, and copies them to the destination path.
PARAMETER | DESCRIPTION |
---|---|
filemap |
filesystem information
TYPE:
|
dest |
destiantion path
TYPE:
|
Source code in torrentfile\rebuild.py
391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 |
|
PathNode(start: int = None, stop: int = None, full: str = None, filename: str = None, path: str = None, length: int = None)
#
Base class representing information regarding a file included in torrent.
Hold file information that contributes to the contents of torrent.
PARAMETER | DESCRIPTION |
---|---|
start |
where the piece starts, by default None
TYPE:
|
stop |
where the piece ends, by default None
TYPE:
|
full |
full path, by default None
TYPE:
|
filename |
filename, by default None
TYPE:
|
path |
parent path, by default None
TYPE:
|
length |
size, by default None
TYPE:
|
Source code in torrentfile\rebuild.py
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
|
__len__() -> int
#
Return size of the file.
RETURNS | DESCRIPTION |
---|---|
int
|
total size |
Source code in torrentfile\rebuild.py
104 105 106 107 108 109 110 111 112 113 |
|
get_part(path: str) -> bytes
#
Extract the part of the file needed to complete the hash.
PARAMETER | DESCRIPTION |
---|---|
path |
filesystem path location of file.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
bytes
|
part of the file’s contents |
Source code in torrentfile\rebuild.py
81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 |
|
PieceNode(piece: bytes)
#
Base class representing a single SHA1 hash block of data from a torrent.
Store information about an individual SHA1 hash for a torrent file.
extended_summary
PARAMETER | DESCRIPTION |
---|---|
piece |
SHA1 hash bytes
TYPE:
|
Source code in torrentfile\rebuild.py
121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 |
|
append(pathnode: PathNode)
#
Append the path argument to the paths list attribute.
PARAMETER | DESCRIPTION |
---|---|
pathnode |
the pathnode
TYPE:
|
Source code in torrentfile\rebuild.py
137 138 139 140 141 142 143 144 145 146 |
|
find_matches(filemap: dict, dest: str) -> bool
#
Find the matching files for each path in the node.
PARAMETER | DESCRIPTION |
---|---|
filemap |
filename and details
TYPE:
|
dest |
target destination path
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
bool
|
success status |
Source code in torrentfile\rebuild.py
184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 |
|