xdcc_dl.entities package¶
Submodules¶
xdcc_dl.entities.IrcServer module¶
- class xdcc_dl.entities.IrcServer.IrcServer(server_address: str, server_port: int = 6667)¶
Bases:
object
Class that models an IRC server
- __init__(server_address: str, server_port: int = 6667)¶
Initializes the Server’s information
- Parameters
server_address – the address of the IRC Server
server_port – the port of the server, which defaults to 6667 and can usually safely stay that way
- get_address() str ¶
- Returns
the server address
- get_port() int ¶
- Returns
the server port
xdcc_dl.entities.User module¶
- class xdcc_dl.entities.User.User(username: str = 'random')¶
Bases:
object
Models an IRC user
- __init__(username: str = 'random')¶
Initializes the User
- Parameters
username – the user’s username. If left empty, or the string ‘random’ is passed, a random username is generated using the names package. An empty string will also result in a random username
- get_name() str ¶
- Returns
The user’s username
xdcc_dl.entities.XDCCPack module¶
- class xdcc_dl.entities.XDCCPack.XDCCPack(server: xdcc_dl.entities.IrcServer.IrcServer, bot: str, packnumber: int)¶
Bases:
object
Class that models an XDCC Pack
- __init__(server: xdcc_dl.entities.IrcServer.IrcServer, bot: str, packnumber: int)¶
Initializes an XDCC object. It contains all the necessary information for joining the correct IRC server and channel and sending the download request to the correct bot, then storing the received file in the predetermined location. If the destination is a directory, the file will be stored in the directory with the default file name, if not the file will be saved at the destination exactly. The file extension will stay as in the original filename
- Parameters
server – The Sever to be used by the XDCC Bot
bot – The bot serving the file
packnumber – The packnumber of the desired file
- classmethod from_xdcc_message(xdcc_message: str, destination_directory: str = '/builds/namibsun/python/xdcc-dl/doc/sphinx', server: str = 'irc.rizon.net') list ¶
Generates XDCC Packs from an xdcc message of the form “/msg <bot> xdcc send #<packnumber>[-<packnumber>]”
- Parameters
xdcc_message – the XDCC message to parse
destination_directory – the destination directory of the file
server – the server to use, defaults to irc.rizon.net for simplicity’s sake
- Returns
The generated XDCC Packs in a list
- get_bot() str ¶
- Returns
The bot
- get_filename() str ¶
- Returns
The currently set filename
- get_filepath() str ¶
- Returns
The full destination file path
- get_packnumber() int ¶
- Returns
the pack number
- get_request_message(full: bool = False) str ¶
Generates an xdcc send message to be sent to the bot to initiate the XDCC connection
- Parameters
full – Returns the entire message string, including the bot’s name, as seen on packlist sites
- Returns
The generated message string
- get_server() xdcc_dl.entities.IrcServer.IrcServer ¶
- Returns
The server
- get_size() int ¶
- Returns
The currently set file size
- is_filename_valid(filename: str) bool ¶
Checks if a filename is the same as the original filename, if one was set previously. This is used internally by the IRC Bot to check if a file that was offered to the bot actually matches the file we want to download.
- Parameters
filename – The file name to check
- Returns
True, if the names match, or no original filename was set, otherwise False
- set_directory(directory: str)¶
Sets the target directory of the XDCC PAck
- Parameters
directory – the target directory
- Returns
None
- set_filename(filename: str, override: bool = False)¶
Sets the filename (or only the file extension) of the target file
- Parameters
filename – the filename as provided by the XDCC bot
override – Overrides the current filename
- Returns
None
- set_original_filename(filename: str)¶
Sets the ‘original’ filename, a.k.a the name of the actual file to download. This is a method that should only be used by the pack searchers to add filename checks during the download.
- Parameters
filename – The original filename as found by the PackSearcher
- Returns
None
- set_size(size: int)¶
Sets the file size of the XDCC pack in Bytes
- Parameters
size – the size of the pack
- Returns
None