unidown.plugin.a_plugin

Functions

get_plugins()

Get all available plugins for unidown.

Classes

APlugin(settings[, options])

Abstract class of a plugin.

class APlugin(settings, options=None)[source]

Bases: ABC

Abstract class of a plugin. Provides all needed variables and methods.

Parameters
Raises

PluginError – Can not create default plugin paths.

_SAVESTATE_CLS

Savestate class to use.

Parameters

alias of SaveState

abstract _create_download_data()[source]

Get the download links in a specific format.

Note

Has to be implemented inside Plugins.

Raises

NotImplementedError – Abstract method.

Return type

LinkItemDict

abstract _create_last_update_time()[source]

Get the newest update time from the referencing data.

Note

Has to be implemented inside Plugin.

Raises

NotImplementedError – Abstract method.

Return type

datetime

_load_default_options()[source]

Load default options if they were not passed at creation.

Return type

None

check_download(link_item_dict, folder, log=False)[source]

Check if the download of the given dict was successful. No proving if the content of the file is correct too.

Parameters
  • link_item_dict (LinkItemDict) – Items to check.

  • folder (Path) – Folder where the downloads are saved.

  • log (bool) – Log lost items.

Return type

tuple[LinkItemDict, LinkItemDict]

Returns

Succeed.

clean_up()[source]

Clean up for a module. Is deleting _temp_dir.

Return type

None

download(link_items, folder, desc, unit)[source]

Download the given LinkItem dict from the plugins host, to the given path. Proceeded with multiple connections. _simul_downloads. After check_download() is recommended.

This function don’t use an internal link_item_dict, delay or folder directly set in options or instance vars, because it can be used aside of the normal download routine inside the plugin itself for own things. As of this it still needs access to the logger, so a staticmethod is not possible.

Warning

The parameters may change in future versions. (e.g. change order and accept another host)

Parameters
  • link_items (LinkItemDict) – Data which gets downloaded.

  • folder (Path) – Target download folder.

  • desc (str) – Description of the progressbar.

  • unit (str) – Unit of the download, shown in the progressbar.

Return type

None

download_as_file(url, target_file, delay=0)[source]

Download the given url to the given target folder.

Parameters
  • url (str) – Link.

  • target_file (Path) – Target file.

  • delay (float) – Delay after each download. Delay is in seconds.

Return type

str

Returns

Url.

Raises

HTTPError – Connection had an error.

load_savestate()[source]

Load the save of the plugin.

Raises
Return type

None

save_savestate()[source]

Save meta data about the downloaded things and the plugin to a file.

Return type

None

update_download_data()[source]

Update the download links. Calls _create_download_data().

Return type

None

update_last_update()[source]

Call this to update the latest update time. Calls _create_last_update_time().

Return type

None

update_savestate(new_items)[source]

Update savestate.

Parameters

new_items (LinkItemDict) – New items.

Return type

None

_INFO: PluginInfo = <unidown.plugin.plugin_info.PluginInfo object>

Meta information about the plugin.

_abc_impl = <_abc._abc_data object>
_disable_tqdm: bool

If the tqdm progressbar should be disabled.

_download_data: LinkItemDict

Referencing data.

_download_dir: Path

General download path of the plugin.

_downloader: HTTPSConnectionPool

Downloader which will download the data.

_last_update: datetime

Latest update time of the referencing data.

_log: Logger

Use this for logging.

_options: dict[str, Any]

Options which the plugin uses internally, should be used for the given options at initialization.

_savestate: SaveState

Savestate of the plugin.

_savestate_file: Path

File which contains the latest savestate of the plugin.

_simul_downloads: int

Number of simultaneous downloads.

_temp_dir: Path

Path where the plugin can place all temporary data.

_unit: str

The unit which will be displayed in the progress bar.

property download_data: LinkItemDict

Plain getter.

Return type

LinkItemDict

property download_dir: Path

Plain getter.

Return type

Path

property host: str

Plain getter.

Return type

str

property info: PluginInfo

Plain getter.

Return type

PluginInfo

property last_update: datetime

Plain getter.

Return type

datetime

property log: Logger

Plain getter.

Return type

Logger

property name: str

Plain getter.

Return type

str

property options: dict[str, Any]

Plain getter.

Return type

dict[str, Any]

property savestate: SaveState

Plain getter.

Return type

SaveState

property simul_downloads: int

Plain getter.

Return type

int

property temp_dir: Path

Plain getter.

Return type

Path

property unit: str

Plain getter.

Return type

str

property version: Version

Plain getter.

Return type

Version

get_plugins()[source]

Get all available plugins for unidown.

Return type

dict[str, EntryPoint]

Returns

Plugin name list.