wyvern.abstract

Abstract Classes Module.

Contains the abstract classes used by the project.

class wyvern.abstract.Artisan

Artisan Base Class.

This class creates a singular job based off of a request (eg downloading a specific video from a site)

plugin_id: str

ID of the plugin to use

Should be in kebab-case. Will be the name of the folder files are output into. The name may be shared with Artisans, but should only be shared with one Factory.

abstract request_job(manager: Manager, job_str: str) Job | None

Request a Job from the job_str (often a URL or an ID).

If the job cannot be found, return None.

class wyvern.abstract.DataStore(plugin_id: str, config_str: str)

Data Store Class.

Parameters:
  • plugin_id – The ID of the Factory or Artisan providing jobs.

  • config_str – The configuration string (meaning defined by inheriting constructor.)

This class is mainly for type hinting with the following defined.

  • __getitem__() Get the stored value.

  • __setitem__() Set the stored value

These functions should call to the store directly (without caching). This avoids the case where there are multiple nodes downloading causing a race condition.

class wyvern.abstract.Factory

Factory Base Class.

This class creates a number of jobs (eg downloading all owned products on a site)

abstract load_jobs(manager: Manager) None

Load the jobs.

This is the main function of the downloader. It loads in jobs from the source and adds them to the queue with add_job(). These jobs can be jobs to load in more jobs, but this practice should be avoided if at all possible. Adding jobs should be designed in such a way that a job can be starting to be downloaded while later jobs are being added (eg loading in later pages of results).

plugin_id: str

ID of the plugin to use

Should be in kebab-case. Will be the name of the folder files are output into. The name should be unique per-Factory, but may be shared with one (or more) Artisan.

class wyvern.abstract.Job

Job Base Class.

This class represents a job’s data.

abstract do_download(manager: Manager) None

Run the download.

This function will execute the download of the job, updating status and progress as appropriate.

name: str

The Name of the job (should be displayed in the UI)

progress: float = 0.0

The progress through the download. Valid values are between 0 and 1

abstract should_skip(manager: Manager) bool

Work out if the job should be skipped.

This should check if the file already exists in the destination folder.

status: str | Exception

Status during the Download (eg Downloading, Extracting etc), or if the job failed, the exception it raised.

sub_jobs: Queue[Job] | None

Sub Jobs Created as part of the job processing.

Jobs may be added to the queue before the current job has completed. Care should be taken to avoid race conditions on secrets or filesand depth-first themed non-terminations.

updated: Event = <threading.Event at 0x7fe0c4ecccd0: unset>

Event to be called when the externally visible members are updated.

url: str | None

URL of the job.

class wyvern.abstract.Manager

Manager Class.

The configuration and secrets variables are specific to the Factory or Artisan which created the job.

abstract add_job(job: Job | None) None

Add a job object to the queue.

This will add to the queue of jobs to be executed directly after this.

configuration: DataStore

Variables affecting how download jobs are processed.

These are straightforward nonsensitive variables. Examples include:

  • Bitrate to download at

  • URL to site

plugin_id: str

The calling Artisan or Factory’s plugin_id

secrets: DataStore

More sensitive variables.

These should be obfuscated in any UI and stored more securely. Examples include:

  • API Keys

  • Passwords

  • Cookie Values