flexget.utils.bittorrent module
Torrenting utils, mostly for handling bencoding and torrent files.
-
class flexget.utils.bittorrent.Torrent(content)[source]
Bases: object
Represents a torrent.
- Parameters:
content (bytes)
-
KEY_TYPE
alias of str
-
classmethod from_file(file)[source]
Create torrent from file on disk.
- Parameters:
file (Path)
- Return type:
Torrent
-
add_multitracker(tracker)[source]
Append multi-tracker to this torrent.
- Parameters:
tracker (str)
- Return type:
None
-
encode()[source]
- Return type:
bytes
-
get_filelist()[source]
Return array containing fileinfo dictionaries (name, length, path).
- Return type:
list[dict[str, str | int]]
-
remove_multitracker(tracker)[source]
Remove passed multi-tracker from this torrent.
- Parameters:
tracker (str)
- Return type:
None
-
set_libtorrent_resume(chunks, files)[source]
- Return type:
None
-
property info_hash: str
Return Torrent info hash.
-
property is_multi_file: bool
Return True if the torrent is a multi-file torrent.
-
property libtorrent_resume: dict
-
property name: str
Return name of the torrent.
-
property piece_size: int
-
property private: int | bool
-
property size: int
Return total size of the torrent.
-
property trackers: list[str]
- Returns:
List of trackers, supports single-tracker and multi-tracker implementations
-
flexget.utils.bittorrent.bdecode(text)[source]
- Parameters:
text (bytes)
- Return type:
dict[str, Any]
-
flexget.utils.bittorrent.bencode(data)[source]
- Parameters:
data (bytes | str | int | list | dict)
- Return type:
bytes
-
flexget.utils.bittorrent.clean_meta(meta, including_info=False, log_func=None)[source]
Clean meta dict. Optionally log changes using the given logger.
See also http://packages.python.org/pyrocore/apidocs/pyrocore.util.metafile-pysrc.html#clean_meta
@param log_func: If given, a callable accepting a string message.
@return: Set of keys removed from C{meta}.
- Parameters:
-
-
flexget.utils.bittorrent.decode_item(src_iter, token)[source]
- Parameters:
-
- Return type:
bytes | str | int | list | dict
-
flexget.utils.bittorrent.encode_bytes(data)[source]
- Parameters:
data (bytes)
- Return type:
bytes
-
flexget.utils.bittorrent.encode_dictionary(data)[source]
- Parameters:
data (dict)
- Return type:
bytes
-
flexget.utils.bittorrent.encode_integer(data)[source]
- Parameters:
data (int)
- Return type:
bytes
-
flexget.utils.bittorrent.encode_list(data)[source]
- Parameters:
data (list)
- Return type:
bytes
-
flexget.utils.bittorrent.encode_string(data)[source]
- Parameters:
data (str)
- Return type:
bytes
-
flexget.utils.bittorrent.is_torrent_file(metafilepath)[source]
Check whether a file looks like a metafile by peeking into its content.
Note that this doesn’t ensure that the file is a complete and valid torrent,
it just allows fast filtering of candidate files.
@param metafilepath: Path to the file to check, must have read permissions for it.
@return: True if there is a high probability this is a metafile.
- Parameters:
metafilepath (Path)
- Return type:
bool
-
flexget.utils.bittorrent.tokenize(text, match=<built-in method match of re.Pattern object>)[source]
- Parameters:
text (bytes)
- Return type:
Generator[bytes, None, None]