Sync plexapi.sync

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)[source]

Bases: plexapi.base.PlexObject

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 (Status) – current status of the sync.
  • mediaSettings (MediaSettings) – media transcoding settings used for the item.
  • policy (Policy) – the policy of which media to sync.
  • location (str) – plex-style library url with all required filters / sorting.

Returns MyPlexResource with server of current item.


Returns list of Playable which belong to this sync item.


Mark the file as downloaded (by the nature of Plex it will be marked as downloaded within any SyncItem where it presented).

Parameters:media (base.Playable) – the media to be marked as downloaded.

Removes current SyncItem

class plexapi.sync.SyncList(server, data, initpath=None, parent=None)[source]

Bases: plexapi.base.PlexObject

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.
  • items (List<SyncItem>) – list of registered items to sync.
class plexapi.sync.Status(itemsCount, itemsCompleteCount, state, totalSize, itemsDownloadedCount, itemsReadyCount, itemsSuccessfulCount, failureCode, failure)[source]

Bases: future.types.newobject.newobject

Represents a current status of specific SyncItem.

  • 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)[source]

Bases: future.types.newobject.newobject

Transcoding settings used for all media within SyncItem.

  • 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)[source]

Returns a MediaSettings object, based on provided video quality value.

Parameters:videoQuality (int) – idx of quality of the video, one of VIDEO_QUALITY_* values defined in this module.
Raises:BadRequest – When provided unknown video quality.
static createMusic(bitrate)[source]

Returns a MediaSettings object, based on provided music quality value

Parameters:bitrate (int) – maximum bitrate for synchronized music, better use one of MUSIC_BITRATE_* values from the module
static createPhoto(resolution)[source]

Returns a MediaSettings object, based on provided photo quality value.

Parameters:resolution (str) – maximum allowed resolution for synchronized photos, see PHOTO_QUALITY_* values in the module.
Raises:BadRequest – When provided unknown video quality.
class plexapi.sync.Policy(scope, unwatched, value=0)[source]

Bases: future.types.newobject.newobject

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.
static create(limit=None, unwatched=False)[source]

Creates a Policy object for provided options and automatically sets proper scope value.

  • limit (int) – limit items by count.
  • unwatched (bool) – if True then watched items wouldn’t be synced.