upsies.trackers.ptp.tracker
Concrete TrackerBase subclass for PTP
Classes
- class upsies.trackers.ptp.tracker.PtpTracker(options=None)[source]
Bases:
TrackerBase- setup_howto_template = '{howto.introduction}\n\n{howto.next_section}. Login Credentials\n\n {howto.current_section}.1 $ upsies set trackers.{tracker.name}.username USERNAME\n {howto.current_section}.2 $ upsies set trackers.{tracker.name}.password PASSWORD\n {howto.current_section}.3 Store the login session cookie. (optional)\n $ upsies set trackers.{tracker.name}.cookies_filepath "~/.cache/upsies/{tracker.name}.cookies"\n WARNING: Anyone with acces to that file has full control over your {tracker.label} account.\n\n{howto.next_section}. Announce URL\n\n The announce URL is required because the passkey is used as another authentication factor.\n $ upsies set trackers.{tracker.name}.announce_url ANNOUNCE_URL\n\n{howto.next_section}. Screenshots\n\n {howto.current_section}.1 Configure ptpimg.me API key.\n $ upsies upload-images ptpimg --help\n\n {howto.current_section}.2 Specify how many screenshots to make. (optional)\n $ upsies set trackers.{tracker.name}.screenshots_from_movie NUMBER_OF_MOVIE_SCREENSHOTS\n $ upsies set trackers.{tracker.name}.screenshots_from_episode NUMBER_OF_EPISODE_SCREENSHOTS\n\n{howto.autoseed}\n\n{howto.reuse_torrents}\n\n{howto.upload}\n'
Step-by-step guide that explains how to make your first upload
Note
This MUST be a class attribute and not a property.
The following placeholders can be used in f-string format:
howto-Howtoinstancetracker-TrackerBasesubclassexecutable- Name of the executable that runs the application
- TrackerJobs
alias of
PtpTrackerJobs
- TrackerConfig
alias of
PtpTrackerConfig
- cli_arguments = {'submit': {('--hardcoded-subtitles', '--hs'): {'action': 'store_true', 'help': 'Release is trumpable because of hardcoded subtitles'}, ('--imdb', '--im'): {'help': 'IMDb ID or URL', 'type': <function webdb_id.<locals>.webdb_id>}, ('--nfo',): {'help': 'Path to NFO file (supersedes any *.nfo file found in the release directory)'}, ('--no-english-subtitles', '--nes'): {'help': 'Whether release contains no English audio and no English subtitles.\nThis is autodetected reliably if all audio and subtitle tracks have a correct language tag. If not, you are asked interactively.\nSubtitle languages are detected in *.idx/sub, VIDEO_TS trees, BDMV trees and *.srt/ssa/ass/vtt by language code in the file name, e.g. "Foo.en.srt".', 'metavar': 'BOOL', 'type': <function bool_or_none>}, ('--not-main-movie', '--nmm'): {'action': 'store_true', 'help': 'Upload ONLY contains extras, Rifftrax, Workprints'}, ('--only-description', '--od'): {'action': 'store_true', 'group': 'generate-metadata', 'help': 'Only generate description (do not submit)'}, ('--personal-rip', '--pr'): {'action': 'store_true', 'help': 'Tag submission as your own encode'}, ('--poster', '--po'): {'help': 'Path or URL to movie poster'}, ('--screenshots', '--ss'): {'action': 'extend', 'help': 'Path(s) to existing screenshot file(s)\nDirectories are searched recursively.\nMore screenshots are created if necessary.', 'metavar': 'SCREENSHOT', 'nargs': '+', 'type': <function files_with_extension.<locals>.files_with_extension>}, ('--screenshots-count', '--ssc'): {'help': 'How many screenshots to make per video file', 'type': functools.partial(<function integer>, min=1, max=10)}, ('--source', '--so'): {'help': 'Original source of this release\nShould vaguely match: Blu-ray, DVD, WEB, HD-DVD, HDTV, TV, VHS'}, ('--subtitles', '--su'): {'help': 'Comma-separated list of subtitle language codes.\nUse this if subtitles are hardcoded or missing language tags.', 'metavar': 'LANGUAGES', 'type': <class 'upsies.utils.types.ListOfSubtitle'>}, ('--trailer', '--tr'): {'help': 'YouTube trailer URL'}, ('--type', '--ty'): {'help': 'General category of this release\nMust vaguely match: Feature Film, Short Film, Miniseries, Stand-up Comedy, Live Performance, Movie Collection', 'type': <class 'upsies.trackers.ptp.config.PtpReleaseType'>}, ('--upload-token', '--ut'): {'help': 'Upload token from staff'}}}
CLI argument definitions (see
CommandBase.cli_arguments)
- rules = (<class 'upsies.trackers.ptp.rules.PtpBannedContainer'>, <class 'upsies.trackers.ptp.rules.PtpBannedGroup'>)
Sequence of
TrackerRuleBasesubclasses or NoneFor convenience, this may also be a
ModuleTypethat providesTrackerRuleBasesubclasses.
- async confirm_logged_in()[source]
Check if we are logged in by doing a website request
This method is called by
login()to make sure_login()succeeded. It is also called bystill_logged_in(), which is used check if a stored user session is still working or if a new session must be started (e.g. because the cookie expired).- Raises:
errors.RequestError – if we are not logged in
- async get_announce_url()[source]
Get announce URL from
optionsor tracker websiteWarning
You should expect that
login()was called first when implementing this method and raiseRuntimeErrorifis_logged_inis False.- Raises:
errors.RequestError – on any kind of failure
- async upload(tracker_jobs)[source]
Upload torrent and other metadata from jobs
- Parameters:
tracker_jobs (TrackerJobsBase) –
TrackerJobsinstance
- normalize_imdb_id(imdb_id)[source]
Format IMDb ID for PTP
PTP expects 7-characters, right-padded with “0” and without the leading “tt”.
If imdb_id is falsy (e.g. None, empty string, etc), or if it isn’t an IMDb ID, return “0”.
- async get_ptp_group_id_by_imdb_id(imdb_id)[source]
Convert IMDb ID to PTP group ID
Any
RequestErroris caught and passed toTrackerBase.error().- Returns:
PTP group ID or None if PTP doesn’t have a group for imdb_id
- Raises:
RequestError – if the request fails.
- async get_movie_metadata(imdb_id)[source]
Get metadata about movie as
dictfrom PTP website- Parameters:
imdb_id – IMDb ID (e.g.
tt123456)
The returned
dictalways has the following keys:- Raises:
RequestedNotFoundError – if no metadata is found.
RequestError – if the request fails.
- async get_artist_metadata(artist)[source]
Get metadata about artist as
dictfrom PTP website- Parameters:
artist – Name, IMDb URL/ID (e.g.
nm123456) or PTP URL/ID- Raises:
RequestedNotFoundError – if artist is unknown on both PTP and IMDb.
RequestError – if the metadata request fails.
- async create_artist(name)[source]
Create artist on PTP
Warning
This must only be called if the artist doesn’t exist on IMDb or PTP.
- Parameters:
name – Complete canonical name of the artist
- Returns:
dictwith the keys:name,id,url- Raises:
RequestError – if the metadata request fails.
- static calculate_piece_size(bytes)[source]
Return the recommended piece size for a given content size
- Parameters:
bytes – Torrent’s content size without any excluded files
- static calculate_piece_size_min_max(bytes)[source]
Return the allowed minimum and maximum piece size for a given content size
- Parameters:
bytes – torrent’s content size without any excluded files
- Raises:
ValueError – if bytes is negative or otherwise unexpected