This documentation aims to provide at least an overview of what to expect when using or scripting against torrentinfo.
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.
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: 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.
TorrentInfo uses the standard Python distribution utilities. So it should just be a case of uncompressing the archive and running:
./setup.py install
The user running this must have sufficient permissions to create a file in the install directory.
I like to give credit where it’s due. Vrai Stacey is the original creator but no longer maintains the project .
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 storing configuration propagated throughout the program.
String processing class.
Raised when the buffer doesn’t find the expected character.
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 |
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 |
Checks whether we’re at the end of the string.
Returns: | bool – true if this instance reached end of line |
---|
Peeks at the next character in the string.
Returns: | str – next character of this instance |
---|---|
Raises : | BufferOverrun |
A get method called when bytes are encountered. Casts into unicode where at all possible or uses the replacement character otherwise.
Parameters: |
|
---|---|
Returns: | str – Unicode string from the string buffer |
A class modelling a parsed torrent file.
Thrown when the torrent file is not just a single dictionary
Thrown when Torrent.parse encounters unexpected character
Prints out basic information about a Torrent instance.
Parameters: |
|
---|
Prints out basic file information of a Torrent instance.
Parameters: |
|
---|
Decodes a bencoded string.
Parameters: | string_buffer (StringBuffer) – bencoded torrent file content buffer |
---|---|
Returns: | dict |
Printing method.
Parameters: |
|
---|
Dumps out the Integer instance as a date.
Parameters: |
|
---|
Dumps the string to the stdout as file size after formatting it.
Parameters: |
|
---|
Print lines from a torrent instance.
Parameters: |
|
---|
Checks whether a string is ascii only.
Parameters: | string (str) – string to check |
---|---|
Returns: | bool |
Prints out a list of files using a Torrent instance
Parameters: |
|
---|
Loads file contents from a torrent file
Parameters: | filename (str:) – torrent file path |
---|---|
Returns: | StringBuffer |
Main control flow function used to encapsulate initialisation.
Print the first line during information output.
Parameters: |
|
---|