upsies.jobs.poster

Find, download and re-upload poster for movie, series or season

Classes

class upsies.jobs.poster.PosterJob(*, home_directory=None, cache_directory=None, cache_id='', ignore_cache=False, no_output_is_ok=False, hidden=False, autostart=True, guaranteed=False, precondition=None, prejobs=(), callbacks={}, **kwargs)[source]

Bases: JobBase

Get poster and optionally resize and reupload it

This job adds the following signals to signal:

obtaining

Emitted when getting a poster is attempted. Registered callbacks get no arguments.

obtained

Emitted when a poster was successfully obtained. Registered callbacks get the poster file path or URL as a positional argument.

downloading

Emitted when downloading a poster is attempted. Registered callbacks get the poster URL as a positional argument.

downloaded

Emitted when a poster was successfully downloaded. Registered callbacks get the poster URL as a positional argument.

resizing

Emitted when resizing a poster is attempted. Registered callbacks get the original poster file path as a positional argument.

resized

Emitted when a poster was successfully resized. Registered callbacks get the resized poster file path as a positional argument.

uploading

Emitted when uploading a poster to an image hosting service is attempted. Registered callbacks get the relevant ImagehostBase subclass as a positional argument.

uploaded

Emitted when a poster was successfully uploaded to an image hosting service. Registered callbacks get the URL of the uploaded poster as a positional argument.

cache_id = None
initialize(*, getter, width=None, height=None, write_to=None, imagehosts=())[source]

Set internal state

Parameters:
  • getter – Coroutine function that returns a poster file or poster URL (e.g. WebDbApiBase.poster_url()). May raise RequestError, which is passed to error().

  • width – Resize poster to this many pixels wide (aspect ratio is maintained)

  • height – Resize poster to this many pixels high (aspect ratio is maintained)

  • imagehosts

    Sequence of ImagehostBase subclass instances

    Upload poster to the first, try the next one if it fails and so on. RequestError from uploading is passed to warn(). If all uploads fail, error() is called. Any failed image host is considered broken and will not be used for subsequent images.

  • write_to – Write poster to this file path (may be None or empty string)

async run()[source]

Do the work

This method is called by start(). Its coroutine is passed to add_task().

Any keyword arguments passed to initialize() are available via kwargs.

The job is_finished when all added tasks are done or cancelled. (See also finalize() and finalization().)

This method may call add_task() if more tasks are required.