TORRENTINFO(1) | torrentinfo | TORRENTINFO(1) |
NAME¶
torrentinfo - torrentinfo Documentation
This documentation aims to provide at least an overview of what to expect when using or scripting against torrentinfo.
ABOUT¶
torrentinfo parses .torrent files and displays information about the torrent and the files that it references. On the default basic setting it shows:
- Torrent name
- Tracker URL
- The creator of the torrent
- The torrent's creation date
- The number of files (if a multi-file torrent)
- The name of the file (if a single-file torrent)
- The total size of the file/files
If asked to display file information the path and size of each file is listed.
Additionally the entire torrent can be shown in hierachical form.
WHY FORK?¶
I forked the original project simply because it was missing functionality I desired, namely what the -t flag does now. It turned out that the code was an undocummented mess but it worked so no one bothered. It was no longer listed on the creators website and the original creator was surprised that anyone even found it useful. For this reason I decided to the dust off the project, clean it up, document it and provide a few tests along the way.
I'm keeping the original name of the project in case someone (like me) finds themself in a similar position and does a Google search for "torrentinfo".
USAGE¶
usage: torrentinfo [-h] [-v] [-t | -f | -d] [-a] [-n] filename [filename ...]:
Print information about torrent files positional arguments:
filename Torrent files to process optional arguments:
-h, --help show this help message and exit
-v, --version Print version and quit
-t, --top Only show top level file/directory
-f, --files Show files within the torrent
-d, --detailed Print more information about the files
-e, --everything Print everything we can about the torrent
-a, --ascii Only print out ascii
-n, --nocolour No ANSI colour
If no settings are specified the script will default to showing the basic information on each file.
BUGS¶
Any bugs or fixes should be submitted to my GitHub <https://github.com/Fuuzetsu/torrentinfo>.
CREDITS¶
I like to give credit where it's due. Vrai Stacey <http://vrai.net> is the original creator but no longer maintains the project .
TORRENTINFO¶
Parses .torrent files and displays various summaries of the information contained within.
Published under the GNU Public License: http://www.gnu.org/copyleft/gpl.html
- class torrentinfo.Config(formatter, out=<_io.TextIOWrapper name='<stdout>' mode='w' encoding='utf-8'>, err=<_io.TextIOWrapper name='<stderr>' mode='w' encoding='utf-8'>, tab_char=' ')
- Class storing configuration propagated throughout the program.
- class torrentinfo.StringBuffer(string)
- String processing class.
- exception BufferOverrun
- Raised when the buffer goes past EOF.
- exception CharacterExpected
- Raised when the buffer doesn't find the expected character.
- get(length)
- Gets certain amount of characters from the buffer.
- Parameters
- length (int) -- Number of characters to get from the buffer
- Returns
- str -- first length characters from the buffer
- Raises
- BufferOverrun
- get_upto(character)
- Gets all characters in a string until the specified one, exclusive.
- Parameters
- character (str) -- Character until which the string should be collected
- Returns
- str -- collected string from the buffer up to character
- Raises
- CharacterExpected
- is_eof()
- Checks whether we're at the end of the string.
- Returns
- bool -- true if this instance reached end of line
- peek()
- Peeks at the next character in the string.
- unicode_get(length, destructive=True, replacement='×')
- A get method called when bytes are encountered. Casts into unicode where at all possible or uses the replacement character otherwise.
- length (int) -- number of characters to get from the buffer
- destructive (bool) -- decides whether to progress the buffer
- replacement (str) -- Replacement to use character if unicode decode fails
- Returns
- str -- Unicode string from the string buffer
- class torrentinfo.TextFormatter(colour)
- Class used to format strings before printing.
- string_format(format_spec, config, string='')
- Attaches colour codes to strings before outputting them.
- class torrentinfo.Torrent(filename, string_buffer)
- A class modelling a parsed torrent file.
- exception torrentinfo.UnexpectedType
- Thrown when the torrent file is not just a single dictionary
- exception torrentinfo.UnknownTypeChar
- Thrown when Torrent.parse encounters unexpected character
- torrentinfo.basic(config, torrent)
- Prints out basic information about a Torrent instance.
- config (Config) -- configuration object to use in this method
- torrent (Torrent) -- torrent instance to use for information
- torrentinfo.basic_files(config, torrent)
- Prints out basic file information of a Torrent instance.
- config (Config) -- configuration object to use in this method
- torrent (Torrent) -- torrent instance to use for information
- torrentinfo.decode(string_buffer)
- Decodes a bencoded string.
- Parameters
- string_buffer (StringBuffer) -- bencoded torrent file content buffer
- Returns
- dict
- item (dict or list or str or int) -- item to print
- config (Config) -- configuration object to use in this method
- depth (int) -- indentation depth
- newline (bool) -- indicates whether to insert a newline after certain strings
- as_utf_repr (bool) -- indicates whether only ASCII should be printed
- torrentinfo.dump_as_date(number, config)
- Dumps out the Integer instance as a date.
- n (int) -- number to format
- config (Config) -- configuration object to use in this method
- torrentinfo.dump_as_size(number, config, depth)
- Dumps the string to the stdout as file size after formatting it.
- n (int) -- number to format
- config (Config) -- configuration object to use in this method
- depth (int) -- indentation depth
- torrentinfo.get_line(config, prefix, key, torrent, is_date=False)
- Print lines from a torrent instance.
- config (Config) -- configuration object to use in this method
- prefix (str) -- prefix to insert in front of the line
- key (str) -- key name in the torrent to print out
- torrent (Torrent) -- torrent instance to use for information
- depth (int) -- indentation depth
- is_date (bool) -- indicates whether the line is a date
- format_spec (int) -- default colour to use for the text
- torrentinfo.is_ascii_only(string)
- Checks whether a string is ascii only.
- Parameters
- string (str) -- string to check
- Returns
- bool
- torrentinfo.list_files(config, torrent, detailed=False)
- Prints out a list of files using a Torrent instance
- config (Config) -- configuration object to use in this method
- torrent (Torrent) -- torrent instance to use for information
- detailed -- indicates whether to print more information about files
- detailed -- bool
- torrentinfo.load_torrent(filename)
- Loads file contents from a torrent file
- Parameters
- filename (str:) -- torrent file path
- Returns
- StringBuffer
- torrentinfo.main(alt_args=None, out=<_io.TextIOWrapper name='<stdout>' mode='w' encoding='utf-8'>, err=<_io.TextIOWrapper name='<stderr>' mode='w' encoding='utf-8'>)
- Main control flow function used to encapsulate initialisation.
- torrentinfo.start_line(config, prefix, depth, postfix='', format_spec=1)
- Print the first line during information output.
- config (Config) -- configuration object to use in this method
- prefix (str) -- prefix to insert in front of the line
- depth (int) -- indentation depth
- postfix (str) -- postfix to insert at the back of the line
- format_spec (int) -- default colour to use for the text
- torrentinfo.top(config, torrent)
- Prints out the top file/directory name as well as torrent file name.
- config (Config) -- configuration object to use in this method
- torrent (Torrent) -- torrent instance to use for information
AUTHOR¶
Mateusz Kowalczyk
COPYRIGHT¶
2024, Mateusz Kowalczyk
__DATE__ | 1.8 |