TORRENTINFO(1)

πŸ“¦ version 1.8.7, in opensuse-leap 16.0

πŸ’– TORRENTINFO(1) πŸ’–

hiii bestie, welcome to torrentinfo(1) β€” the manual page for torrentinfo, which is literally a whole mood. This doc's whole goal? To give you at least an overview of what you're getting into when you use torrentinfo or script against it. 🫢


✨ NAME ✨

torrentinfo β€” torrentinfo Documentation.

No cap, this documentation aims to provide at least an overview of what to expect when using or scripting against torrentinfo. That's the assignment. πŸ’…


🌸 ABOUT 🌸

okay so torrentinfo parses .torrent files and displays information about the torrent and the files that it references. That's the whole vibe. ✨

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. cute, right? πŸŽ€

Additionally, the entire torrent can be shown in hierarchical form β€” like a little tree of everything. iconic. 🌈


πŸ¦‹ WHY FORK? πŸ¦‹

ngl, 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". iykyk. πŸ”₯


πŸ’… USAGE πŸ’…

usage: torrentinfo [-h] [-v] [-t | -f | -d] [-a] [-n] filename [filename
...]:

Print information about torrent files β€” that's the whole thing, bestie.

  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

now let's break those flags down like a group chat read-receipt situation πŸ‘‘

🌟 positional arguments

  • filename β€” Torrent files to process. yeah girl, you can toss more than one at it ✨

🌟 optional arguments

  • -h, --help β€” show this help message and exit. the classic escape hatch πŸšͺ
  • -v, --version β€” Print version and quit. one job, does it flawlessly πŸ’…
  • -t, --top β€” Only show top level file/directory. the whole reason for the fork, lowkey πŸ‘€
  • -f, --files β€” Show files within the torrent. peek inside πŸŽ€
  • -d, --detailed β€” Print more information about the files. give me the lore πŸ“–
  • -e, --everything β€” Print everything we can about the torrent. main character energy, no crumbs left 😀
  • -a, --ascii β€” Only print out ascii. for the plain-text girlies 🫢
  • -n, --nocolour β€” No ANSI colour. turning the sparkle off, respectfully βœ¨β†’πŸ˜Ά
If no settings are specified the script will default to showing the basic information on each file. it's giving "sensible defaults", fr fr.

πŸ’€ BUGS πŸ’€

Any bugs or fixes should be submitted to my GitHub <https://github.com/Fuuzetsu/torrentinfo>. pls and thank you 🫢


πŸ“ 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 . (yes that space before the period is part of the original, we're keeping it, don't @ me 😭)


πŸ‘‘ TORRENTINFO πŸ‘‘

Parses .torrent files and displays various summaries of the information contained within. that's the mission statement, periodt. 🌟

Published under the GNU Public License: <http://www.gnu.org/copyleft/gpl.html> πŸ’–

okay so now we're getting into the actual API and it's a lot but stay with me, we're going section by section and every single parameter is coming with us 🧚

πŸŽ€ 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. yes, tab_char is a space by default, that's just how it is 🫢

🌸 class torrentinfo.StringBuffer(string)

String processing class. the little engine that could ✨

exception BufferOverrun

Raised when the buffer goes past EOF. you went too far, babe 😭

exception CharacterExpected

Raised when the buffer doesn't find the expected character. rude but fair πŸ’€

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. like, stop before the character, don't include it πŸŽ€

  • 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. vibe check on the buffer πŸ¦‹

  • Returns β€” bool β€” true if this instance reached end of line

peek()

Peeks at the next character in the string. just a lil look, no touching πŸ‘€

  • Returns β€” str β€” next character of this instance
  • Raises BufferOverrun

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.

  • Parameters
    • 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. the glam squad of the codebase ✨

string_format(format_spec, config, string='')

Attaches colour codes to strings before outputting them.

  • Parameters
    • format_spec (int) β€” value of the colour code
    • string (str) β€” string to colour

🌈 class torrentinfo.Torrent(filename, string_buffer)

A class modelling a parsed torrent file. the main character, honestly πŸ‘‘

exception torrentinfo.UnexpectedType

Thrown when the torrent file is not just a single dictionary. it wanted one dict, it got something else, it's not okay πŸ’€

exception torrentinfo.UnknownTypeChar

Thrown when Torrent.parse encounters unexpected character. that character was not on the guest list πŸ™ˆ

🫢 torrentinfo.basic(config, torrent)

Prints out basic information about a Torrent instance.

  • Parameters
    • 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.

  • Parameters
    • 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

πŸ’– torrentinfo.dump(item, config, depth, newline=True, as_utf_repr=False)

Printing method.

  • Parameters
    • 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.

  • Parameters
    • 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.

  • Parameters
    • n (int) β€” number to format
    • config (Config) β€” configuration object to use in this method
    • depth (int) β€” indentation depth

πŸ’… torrentinfo.get_arg_parser()

Parses command-line arguments.

  • Returns β€” ArgumentParser

πŸ”₯ torrentinfo.get_line(config, prefix, key, torrent, is_date=False)

Print lines from a torrent instance.

  • Parameters
    • 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.

  • Parameters
    • 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

(yes, detailed is listed twice there β€” once describing it, once giving its type. that's how the original rolls, we don't fix what isn't asked to be fixed πŸ’€)

🌟 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. the whole operation lives here 🫢

✨ torrentinfo.start_line(config, prefix, depth, postfix='', format_spec=1)

Print the first line during information output.

  • Parameters
    • 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.

  • Parameters
    • config (Config) β€” configuration object to use in this method
    • torrent (Torrent) β€” torrent instance to use for information

πŸŽ€ AUTHOR πŸŽ€

Mateusz Kowalczyk

Okay bestie, here's the legal bit β€” short and sweet, just how we like it:

2013, Mateusz Kowalczyk

That's it. That's the whole thing. 2013, Mateusz Kowalczyk β€” the copyright line, copied exactly, no cap. πŸŽ€ Like, respect the author's year and name, fr fr. Don't be weird about it.


And that's a wrap on TORRENTINFO(1), bestie!! πŸ¦‹ You just read the whole thing β€” this is version 1.8 of the page, dated __DATE__ (yes, the date's a placeholder, the build fills it in, don't come for me 😭). Go forth, check your torrents, and slay. πŸ’…βœ¨ periodt. πŸ‘‘

πŸ“¦ where this page comes from