You can work with Mobile Sync on other devices straight away, but if you’d like to use your app as a sync-target (when you can set items to be synced to your app) you need to init some variables.
def init_sync(): import plexapi plexapi.X_PLEX_PROVIDES = 'sync-target' plexapi.BASE_HEADERS['X-Plex-Sync-Version'] = '2' plexapi.BASE_HEADERS['X-Plex-Provides'] = plexapi.X_PLEX_PROVIDES # mimic iPhone SE plexapi.X_PLEX_PLATFORM = 'iOS' plexapi.X_PLEX_PLATFORM_VERSION = '11.4.1' plexapi.X_PLEX_DEVICE = 'iPhone' plexapi.BASE_HEADERS['X-Plex-Platform'] = plexapi.X_PLEX_PLATFORM plexapi.BASE_HEADERS['X-Plex-Platform-Version'] = plexapi.X_PLEX_PLATFORM_VERSION plexapi.BASE_HEADERS['X-Plex-Device'] = plexapi.X_PLEX_DEVICE
You have to fake platform/device/model because transcoding profiles are hardcoded in Plex, and you obviously have to explicitly specify that your app supports sync-target.
- class plexapi.sync.SyncItem(server, data, initpath=None, clientIdentifier=None)¶
Represents single sync item, for specified server and client. When you saying in the UI to sync “this” to “that” you’re basically creating a sync item.
id (int) – unique id of the item.
clientIdentifier (str) – an identifier of Plex Client device, to which the item is belongs.
machineIdentifier (str) – the id of server which holds all this content.
version (int) – current version of the item. Each time you modify the item (e.g. by changing amount if media to sync) the new version is created.
rootTitle (str) –
the title of library/media from which the sync item was created. E.g.:
when you create an item for an episode 3 of season 3 of show Example, the value would be Title of Episode 3
when you create an item for a season 3 of show Example, the value would be Season 3
when you set to sync all your movies in library named “My Movies” to value would be My Movies.
title (str) – the title which you’ve set when created the sync item.
metadataType (str) – the type of media which hides inside, can be episode, movie, etc.
contentType (str) – basic type of the content: video or audio.
Status) – current status of the sync.
MediaSettings) – media transcoding settings used for the item.
Policy) – the policy of which media to sync.
location (str) – plex-style library url with all required filters / sorting.
Mark the file as downloaded (by the nature of Plex it will be marked as downloaded within any SyncItem where it presented).
media (base.Playable) – the media to be marked as downloaded.
Removes current SyncItem
- class plexapi.sync.SyncList(server, data, initpath=None, parent=None)¶
Represents a Mobile Sync state, specific for single client, within one SyncList may be presented items from different servers.
clientId (str) – an identifier of the client.
SyncItem>) – list of registered items to sync.
- class plexapi.sync.Status(itemsCount, itemsCompleteCount, state, totalSize, itemsDownloadedCount, itemsReadyCount, itemsSuccessfulCount, failureCode, failure)¶
Represents a current status of specific
failureCode – unknown, never got one yet.
failure – unknown.
state (str) – server-side status of the item, can be completed, pending, empty, and probably something else.
itemsCount (int) – total items count.
itemsCompleteCount (int) – count of transcoded and/or downloaded items.
itemsDownloadedCount (int) – count of downloaded items.
itemsReadyCount (int) – count of transcoded items, which can be downloaded.
totalSize (int) – total size in bytes of complete items.
itemsSuccessfulCount (int) – unknown, in my experience it always was equal to itemsCompleteCount.
- class plexapi.sync.MediaSettings(maxVideoBitrate=4000, videoQuality=100, videoResolution='1280x720', audioBoost=100, musicBitrate=192, photoQuality=74, photoResolution='1920x1080', subtitleSize=100)¶
Transcoding settings used for all media within
audioBoost (int) – unknown.
maxVideoBitrate (int|str) – maximum bitrate for video, may be empty string.
musicBitrate (int|str) – maximum bitrate for music, may be an empty string.
photoQuality (int) – photo quality on scale 0 to 100.
photoResolution (str) – maximum photo resolution, formatted as WxH (e.g. 1920x1080).
videoResolution (str) – maximum video resolution, formatted as WxH (e.g. 1280x720, may be empty).
subtitleSize (int) – subtitle size on scale 0 to 100.
videoQuality (int) – video quality on scale 0 to 100.
- static createVideo(videoQuality)¶
MediaSettingsobject, based on provided video quality value.
videoQuality (int) – idx of quality of the video, one of VIDEO_QUALITY_* values defined in this module.
BadRequest – When provided unknown video quality.
- static createMusic(bitrate)¶
MediaSettingsobject, based on provided music quality value
bitrate (int) – maximum bitrate for synchronized music, better use one of MUSIC_BITRATE_* values from the module
- class plexapi.sync.Policy(scope, unwatched, value=0)¶
Policy of syncing the media (how many items to sync and process watched media or not).
scope (str) – type of limitation policy, can be count or all.
value (int) – amount of media to sync, valid only when scope=count.
unwatched (bool) – True means disallow to sync watched media.