2016-04-10 03:59:47 +00:00
|
|
|
# -*- coding: utf-8 -*-
|
2021-11-20 22:16:58 +00:00
|
|
|
import os
|
2023-08-27 19:59:53 +00:00
|
|
|
from pathlib import Path
|
2020-05-12 21:15:16 +00:00
|
|
|
from urllib.parse import quote_plus
|
|
|
|
|
2020-12-24 04:48:58 +00:00
|
|
|
from plexapi import media, utils, video
|
2022-07-21 03:03:20 +00:00
|
|
|
from plexapi.base import Playable, PlexPartialObject, PlexSession
|
2020-12-24 06:00:00 +00:00
|
|
|
from plexapi.exceptions import BadRequest
|
2022-02-27 05:40:51 +00:00
|
|
|
from plexapi.mixins import (
|
|
|
|
RatingMixin,
|
|
|
|
ArtUrlMixin, ArtMixin, PosterUrlMixin, PosterMixin,
|
2023-07-27 21:45:23 +00:00
|
|
|
PhotoalbumEditMixins, PhotoEditMixins
|
2022-02-27 05:40:51 +00:00
|
|
|
)
|
2016-04-10 03:59:47 +00:00
|
|
|
|
|
|
|
|
2017-02-13 02:55:55 +00:00
|
|
|
@utils.registerPlexObject
|
2022-02-27 05:40:51 +00:00
|
|
|
class Photoalbum(
|
|
|
|
PlexPartialObject,
|
|
|
|
RatingMixin,
|
|
|
|
ArtMixin, PosterMixin,
|
2023-07-27 21:45:23 +00:00
|
|
|
PhotoalbumEditMixins
|
2022-02-27 05:40:51 +00:00
|
|
|
):
|
2020-12-24 06:24:46 +00:00
|
|
|
""" Represents a single Photoalbum (collection of photos).
|
2017-01-31 04:44:03 +00:00
|
|
|
|
|
|
|
Attributes:
|
2017-02-14 04:32:27 +00:00
|
|
|
TAG (str): 'Directory'
|
|
|
|
TYPE (str): 'photo'
|
2020-12-24 00:16:08 +00:00
|
|
|
addedAt (datetime): Datetime the photo album was added to the library.
|
|
|
|
art (str): URL to artwork image (/library/metadata/<ratingKey>/art/<artid>).
|
|
|
|
composite (str): URL to composite image (/library/metadata/<ratingKey>/composite/<compositeid>)
|
|
|
|
fields (List<:class:`~plexapi.media.Field`>): List of field objects.
|
|
|
|
guid (str): Plex GUID for the photo album (local://229674).
|
|
|
|
index (sting): Plex index number for the photo album.
|
2017-01-31 04:44:03 +00:00
|
|
|
key (str): API URL (/library/metadata/<ratingkey>).
|
2021-05-30 22:47:53 +00:00
|
|
|
lastRatedAt (datetime): Datetime the photo album was last rated.
|
2017-01-31 04:44:03 +00:00
|
|
|
librarySectionID (int): :class:`~plexapi.library.LibrarySection` ID.
|
2020-12-24 00:16:08 +00:00
|
|
|
librarySectionKey (str): :class:`~plexapi.library.LibrarySection` key.
|
|
|
|
librarySectionTitle (str): :class:`~plexapi.library.LibrarySection` title.
|
2017-01-31 04:44:03 +00:00
|
|
|
listType (str): Hardcoded as 'photo' (useful for search filters).
|
2020-12-24 00:16:08 +00:00
|
|
|
ratingKey (int): Unique key identifying the photo album.
|
2017-01-31 04:44:03 +00:00
|
|
|
summary (str): Summary of the photoalbum.
|
2020-12-24 00:16:08 +00:00
|
|
|
thumb (str): URL to thumbnail image (/library/metadata/<ratingKey>/thumb/<thumbid>).
|
|
|
|
title (str): Name of the photo album. (Trip to Disney World)
|
|
|
|
titleSort (str): Title to use when sorting (defaults to title).
|
|
|
|
type (str): 'photo'
|
2022-02-27 03:26:08 +00:00
|
|
|
updatedAt (datetime): Datetime the photo album was updated.
|
2021-05-30 22:47:53 +00:00
|
|
|
userRating (float): Rating of the photo album (0.0 - 10.0) equaling (0 stars - 5 stars).
|
2017-01-02 21:06:40 +00:00
|
|
|
"""
|
2017-02-13 02:55:55 +00:00
|
|
|
TAG = 'Directory'
|
|
|
|
TYPE = 'photo'
|
2022-02-27 05:40:51 +00:00
|
|
|
_searchType = 'photoalbum'
|
2016-04-10 03:59:47 +00:00
|
|
|
|
|
|
|
def _loadData(self, data):
|
2017-01-31 04:44:03 +00:00
|
|
|
""" Load attribute values from Plex XML response. """
|
2017-02-04 17:43:50 +00:00
|
|
|
self.addedAt = utils.toDatetime(data.attrib.get('addedAt'))
|
|
|
|
self.art = data.attrib.get('art')
|
|
|
|
self.composite = data.attrib.get('composite')
|
2020-12-24 04:39:15 +00:00
|
|
|
self.fields = self.findItems(data, media.Field)
|
2017-02-04 17:43:50 +00:00
|
|
|
self.guid = data.attrib.get('guid')
|
|
|
|
self.index = utils.cast(int, data.attrib.get('index'))
|
2021-01-25 05:28:27 +00:00
|
|
|
self.key = data.attrib.get('key', '').replace('/children', '') # FIX_BUG_50
|
2021-05-30 22:47:53 +00:00
|
|
|
self.lastRatedAt = utils.toDatetime(data.attrib.get('lastRatedAt'))
|
2021-03-11 21:27:08 +00:00
|
|
|
self.librarySectionID = utils.cast(int, data.attrib.get('librarySectionID'))
|
2020-12-24 00:16:08 +00:00
|
|
|
self.librarySectionKey = data.attrib.get('librarySectionKey')
|
|
|
|
self.librarySectionTitle = data.attrib.get('librarySectionTitle')
|
|
|
|
self.listType = 'photo'
|
|
|
|
self.ratingKey = utils.cast(int, data.attrib.get('ratingKey'))
|
2017-02-04 17:43:50 +00:00
|
|
|
self.summary = data.attrib.get('summary')
|
|
|
|
self.thumb = data.attrib.get('thumb')
|
|
|
|
self.title = data.attrib.get('title')
|
2020-12-24 00:16:08 +00:00
|
|
|
self.titleSort = data.attrib.get('titleSort', self.title)
|
2017-02-04 17:43:50 +00:00
|
|
|
self.type = data.attrib.get('type')
|
|
|
|
self.updatedAt = utils.toDatetime(data.attrib.get('updatedAt'))
|
2021-05-30 22:47:53 +00:00
|
|
|
self.userRating = utils.cast(float, data.attrib.get('userRating'))
|
2017-01-02 21:06:40 +00:00
|
|
|
|
2020-12-24 05:38:48 +00:00
|
|
|
def album(self, title):
|
|
|
|
""" Returns the :class:`~plexapi.photo.Photoalbum` that matches the specified title.
|
|
|
|
|
|
|
|
Parameters:
|
|
|
|
title (str): Title of the photo album to return.
|
|
|
|
"""
|
2022-07-21 02:37:48 +00:00
|
|
|
key = f'{self.key}/children'
|
2020-12-24 05:38:48 +00:00
|
|
|
return self.fetchItem(key, Photoalbum, title__iexact=title)
|
|
|
|
|
2017-02-26 05:17:41 +00:00
|
|
|
def albums(self, **kwargs):
|
2020-12-24 00:16:08 +00:00
|
|
|
""" Returns a list of :class:`~plexapi.photo.Photoalbum` objects in the album. """
|
2022-07-21 02:37:48 +00:00
|
|
|
key = f'{self.key}/children'
|
2020-12-24 04:48:58 +00:00
|
|
|
return self.fetchItems(key, Photoalbum, **kwargs)
|
2017-02-26 05:17:41 +00:00
|
|
|
|
2020-12-24 05:38:48 +00:00
|
|
|
def photo(self, title):
|
|
|
|
""" Returns the :class:`~plexapi.photo.Photo` that matches the specified title.
|
|
|
|
|
|
|
|
Parameters:
|
|
|
|
title (str): Title of the photo to return.
|
|
|
|
"""
|
2022-07-21 02:37:48 +00:00
|
|
|
key = f'{self.key}/children'
|
2020-12-24 05:38:48 +00:00
|
|
|
return self.fetchItem(key, Photo, title__iexact=title)
|
2017-02-26 05:17:41 +00:00
|
|
|
|
2017-02-09 04:08:25 +00:00
|
|
|
def photos(self, **kwargs):
|
2020-12-24 00:16:08 +00:00
|
|
|
""" Returns a list of :class:`~plexapi.photo.Photo` objects in the album. """
|
2022-07-21 02:37:48 +00:00
|
|
|
key = f'{self.key}/children'
|
2020-12-24 04:48:58 +00:00
|
|
|
return self.fetchItems(key, Photo, **kwargs)
|
2016-04-10 03:59:47 +00:00
|
|
|
|
2020-12-24 05:38:48 +00:00
|
|
|
def clip(self, title):
|
|
|
|
""" Returns the :class:`~plexapi.video.Clip` that matches the specified title.
|
|
|
|
|
|
|
|
Parameters:
|
|
|
|
title (str): Title of the clip to return.
|
|
|
|
"""
|
2022-07-21 02:37:48 +00:00
|
|
|
key = f'{self.key}/children'
|
2020-12-24 05:38:48 +00:00
|
|
|
return self.fetchItem(key, video.Clip, title__iexact=title)
|
2017-01-02 21:06:40 +00:00
|
|
|
|
2020-12-24 00:16:08 +00:00
|
|
|
def clips(self, **kwargs):
|
|
|
|
""" Returns a list of :class:`~plexapi.video.Clip` objects in the album. """
|
2022-07-21 02:37:48 +00:00
|
|
|
key = f'{self.key}/children'
|
2020-12-24 04:48:58 +00:00
|
|
|
return self.fetchItems(key, video.Clip, **kwargs)
|
2020-12-24 00:16:08 +00:00
|
|
|
|
2020-12-24 05:38:48 +00:00
|
|
|
def get(self, title):
|
|
|
|
""" Alias to :func:`~plexapi.photo.Photoalbum.photo`. """
|
|
|
|
return self.episode(title)
|
2020-12-24 00:16:08 +00:00
|
|
|
|
2021-11-20 22:16:58 +00:00
|
|
|
def download(self, savepath=None, keep_original_name=False, subfolders=False):
|
2022-02-27 03:26:08 +00:00
|
|
|
""" Download all photos and clips from the photo album. See :func:`~plexapi.base.Playable.download` for details.
|
2020-10-10 19:00:19 +00:00
|
|
|
|
|
|
|
Parameters:
|
|
|
|
savepath (str): Defaults to current working dir.
|
2021-11-20 22:16:58 +00:00
|
|
|
keep_original_name (bool): True to keep the original filename otherwise
|
|
|
|
a friendlier filename is generated.
|
|
|
|
subfolders (bool): True to separate photos/clips in to photo album folders.
|
2020-10-10 19:00:19 +00:00
|
|
|
"""
|
|
|
|
filepaths = []
|
2021-11-20 22:16:58 +00:00
|
|
|
for album in self.albums():
|
|
|
|
_savepath = os.path.join(savepath, album.title) if subfolders else savepath
|
|
|
|
filepaths += album.download(_savepath, keep_original_name)
|
|
|
|
for photo in self.photos() + self.clips():
|
|
|
|
filepaths += photo.download(savepath, keep_original_name)
|
2020-10-10 19:00:19 +00:00
|
|
|
return filepaths
|
|
|
|
|
2021-09-26 22:23:09 +00:00
|
|
|
def _getWebURL(self, base=None):
|
|
|
|
""" Get the Plex Web URL with the correct parameters. """
|
|
|
|
return self._server._buildWebURL(base=base, endpoint='details', key=self.key, legacy=1)
|
2021-08-03 03:37:29 +00:00
|
|
|
|
2023-08-27 19:59:53 +00:00
|
|
|
@property
|
|
|
|
def metadataDirectory(self):
|
|
|
|
""" Returns the Plex Media Server data directory where the metadata is stored. """
|
|
|
|
guid_hash = utils.sha1hash(self.guid)
|
|
|
|
return str(Path('Metadata') / 'Photos' / guid_hash[0] / f'{guid_hash[1:]}.bundle')
|
|
|
|
|
2016-04-10 03:59:47 +00:00
|
|
|
|
2017-02-13 02:55:55 +00:00
|
|
|
@utils.registerPlexObject
|
2022-02-27 05:40:51 +00:00
|
|
|
class Photo(
|
|
|
|
PlexPartialObject, Playable,
|
|
|
|
RatingMixin,
|
|
|
|
ArtUrlMixin, PosterUrlMixin,
|
2023-07-27 21:45:23 +00:00
|
|
|
PhotoEditMixins
|
2022-02-27 05:40:51 +00:00
|
|
|
):
|
2020-12-24 06:24:46 +00:00
|
|
|
""" Represents a single Photo.
|
2017-01-31 04:44:03 +00:00
|
|
|
|
|
|
|
Attributes:
|
2017-02-14 04:32:27 +00:00
|
|
|
TAG (str): 'Photo'
|
|
|
|
TYPE (str): 'photo'
|
2020-12-24 00:16:08 +00:00
|
|
|
addedAt (datetime): Datetime the photo was added to the library.
|
|
|
|
createdAtAccuracy (str): Unknown (local).
|
|
|
|
createdAtTZOffset (int): Unknown (-25200).
|
2020-12-24 04:40:08 +00:00
|
|
|
fields (List<:class:`~plexapi.media.Field`>): List of field objects.
|
2020-12-24 00:16:08 +00:00
|
|
|
guid (str): Plex GUID for the photo (com.plexapp.agents.none://231714?lang=xn).
|
|
|
|
index (sting): Plex index number for the photo.
|
2017-01-31 04:44:03 +00:00
|
|
|
key (str): API URL (/library/metadata/<ratingkey>).
|
2021-05-30 22:47:53 +00:00
|
|
|
lastRatedAt (datetime): Datetime the photo was last rated.
|
2020-11-01 21:02:23 +00:00
|
|
|
librarySectionID (int): :class:`~plexapi.library.LibrarySection` ID.
|
2020-12-24 00:16:08 +00:00
|
|
|
librarySectionKey (str): :class:`~plexapi.library.LibrarySection` key.
|
|
|
|
librarySectionTitle (str): :class:`~plexapi.library.LibrarySection` title.
|
2017-01-31 04:44:03 +00:00
|
|
|
listType (str): Hardcoded as 'photo' (useful for search filters).
|
2020-12-24 00:16:08 +00:00
|
|
|
media (List<:class:`~plexapi.media.Media`>): List of media objects.
|
|
|
|
originallyAvailableAt (datetime): Datetime the photo was added to Plex.
|
|
|
|
parentGuid (str): Plex GUID for the photo album (local://229674).
|
|
|
|
parentIndex (int): Plex index number for the photo album.
|
|
|
|
parentKey (str): API URL of the photo album (/library/metadata/<parentRatingKey>).
|
|
|
|
parentRatingKey (int): Unique key identifying the photo album.
|
|
|
|
parentThumb (str): URL to photo album thumbnail image (/library/metadata/<parentRatingKey>/thumb/<thumbid>).
|
|
|
|
parentTitle (str): Name of the photo album for the photo.
|
|
|
|
ratingKey (int): Unique key identifying the photo.
|
2024-02-17 22:16:10 +00:00
|
|
|
sourceURI (str): Remote server URI (server://<machineIdentifier>/com.plexapp.plugins.library)
|
|
|
|
(remote playlist item only).
|
2017-01-31 04:44:03 +00:00
|
|
|
summary (str): Summary of the photo.
|
2021-01-24 22:32:02 +00:00
|
|
|
tags (List<:class:`~plexapi.media.Tag`>): List of tag objects.
|
2020-12-24 00:16:08 +00:00
|
|
|
thumb (str): URL to thumbnail image (/library/metadata/<ratingKey>/thumb/<thumbid>).
|
|
|
|
title (str): Name of the photo.
|
|
|
|
titleSort (str): Title to use when sorting (defaults to title).
|
|
|
|
type (str): 'photo'
|
2022-02-27 03:26:08 +00:00
|
|
|
updatedAt (datetime): Datetime the photo was updated.
|
2021-05-30 22:47:53 +00:00
|
|
|
userRating (float): Rating of the photo (0.0 - 10.0) equaling (0 stars - 5 stars).
|
2020-12-24 00:16:08 +00:00
|
|
|
year (int): Year the photo was taken.
|
2017-01-02 21:06:40 +00:00
|
|
|
"""
|
2017-02-13 02:55:55 +00:00
|
|
|
TAG = 'Photo'
|
2016-04-10 03:59:47 +00:00
|
|
|
TYPE = 'photo'
|
2018-09-08 15:25:16 +00:00
|
|
|
METADATA_TYPE = 'photo'
|
2016-04-10 03:59:47 +00:00
|
|
|
|
|
|
|
def _loadData(self, data):
|
2017-01-31 04:44:03 +00:00
|
|
|
""" Load attribute values from Plex XML response. """
|
2020-11-01 21:02:23 +00:00
|
|
|
Playable._loadData(self, data)
|
2017-02-04 17:43:50 +00:00
|
|
|
self.addedAt = utils.toDatetime(data.attrib.get('addedAt'))
|
2020-12-24 00:16:08 +00:00
|
|
|
self.createdAtAccuracy = data.attrib.get('createdAtAccuracy')
|
|
|
|
self.createdAtTZOffset = utils.cast(int, data.attrib.get('createdAtTZOffset'))
|
|
|
|
self.fields = self.findItems(data, media.Field)
|
|
|
|
self.guid = data.attrib.get('guid')
|
2017-02-04 17:43:50 +00:00
|
|
|
self.index = utils.cast(int, data.attrib.get('index'))
|
2020-12-24 06:17:43 +00:00
|
|
|
self.key = data.attrib.get('key', '')
|
2021-05-30 22:47:53 +00:00
|
|
|
self.lastRatedAt = utils.toDatetime(data.attrib.get('lastRatedAt'))
|
2021-03-11 21:27:08 +00:00
|
|
|
self.librarySectionID = utils.cast(int, data.attrib.get('librarySectionID'))
|
2020-12-24 00:16:08 +00:00
|
|
|
self.librarySectionKey = data.attrib.get('librarySectionKey')
|
|
|
|
self.librarySectionTitle = data.attrib.get('librarySectionTitle')
|
|
|
|
self.listType = 'photo'
|
|
|
|
self.media = self.findItems(data, media.Media)
|
|
|
|
self.originallyAvailableAt = utils.toDatetime(data.attrib.get('originallyAvailableAt'), '%Y-%m-%d')
|
|
|
|
self.parentGuid = data.attrib.get('parentGuid')
|
|
|
|
self.parentIndex = utils.cast(int, data.attrib.get('parentIndex'))
|
2017-02-04 17:43:50 +00:00
|
|
|
self.parentKey = data.attrib.get('parentKey')
|
2020-12-24 00:16:08 +00:00
|
|
|
self.parentRatingKey = utils.cast(int, data.attrib.get('parentRatingKey'))
|
|
|
|
self.parentThumb = data.attrib.get('parentThumb')
|
|
|
|
self.parentTitle = data.attrib.get('parentTitle')
|
|
|
|
self.ratingKey = utils.cast(int, data.attrib.get('ratingKey'))
|
2024-02-17 22:16:10 +00:00
|
|
|
self.sourceURI = data.attrib.get('source') # remote playlist item
|
2017-02-04 17:43:50 +00:00
|
|
|
self.summary = data.attrib.get('summary')
|
2021-01-24 22:32:02 +00:00
|
|
|
self.tags = self.findItems(data, media.Tag)
|
2017-02-04 17:43:50 +00:00
|
|
|
self.thumb = data.attrib.get('thumb')
|
|
|
|
self.title = data.attrib.get('title')
|
2020-12-24 00:16:08 +00:00
|
|
|
self.titleSort = data.attrib.get('titleSort', self.title)
|
2017-02-04 17:43:50 +00:00
|
|
|
self.type = data.attrib.get('type')
|
|
|
|
self.updatedAt = utils.toDatetime(data.attrib.get('updatedAt'))
|
2021-05-30 22:47:53 +00:00
|
|
|
self.userRating = utils.cast(float, data.attrib.get('userRating'))
|
2017-02-04 17:43:50 +00:00
|
|
|
self.year = utils.cast(int, data.attrib.get('year'))
|
2017-01-02 21:06:40 +00:00
|
|
|
|
2021-11-20 22:16:58 +00:00
|
|
|
def _prettyfilename(self):
|
|
|
|
""" Returns a filename for use in download. """
|
|
|
|
if self.parentTitle:
|
2022-08-28 05:56:01 +00:00
|
|
|
return f'{self.parentTitle} - {self.title}'
|
2021-11-20 22:16:58 +00:00
|
|
|
return self.title
|
|
|
|
|
2016-04-10 03:59:47 +00:00
|
|
|
def photoalbum(self):
|
2020-12-24 00:16:08 +00:00
|
|
|
""" Return the photo's :class:`~plexapi.photo.Photoalbum`. """
|
2017-02-07 06:20:49 +00:00
|
|
|
return self.fetchItem(self.parentKey)
|
2016-07-08 02:41:11 +00:00
|
|
|
|
|
|
|
def section(self):
|
2020-12-24 00:16:08 +00:00
|
|
|
""" Returns the :class:`~plexapi.library.LibrarySection` the item belongs to. """
|
2018-09-14 18:27:24 +00:00
|
|
|
if hasattr(self, 'librarySectionID'):
|
|
|
|
return self._server.library.sectionByID(self.librarySectionID)
|
|
|
|
elif self.parentKey:
|
|
|
|
return self._server.library.sectionByID(self.photoalbum().librarySectionID)
|
|
|
|
else:
|
2022-02-27 03:26:08 +00:00
|
|
|
raise BadRequest("Unable to get section for photo, can't find librarySectionID")
|
2018-09-08 15:25:16 +00:00
|
|
|
|
2020-12-24 00:16:08 +00:00
|
|
|
@property
|
|
|
|
def locations(self):
|
|
|
|
""" This does not exist in plex xml response but is added to have a common
|
|
|
|
interface to get the locations of the photo.
|
2020-12-24 04:40:08 +00:00
|
|
|
|
2021-06-06 21:54:15 +00:00
|
|
|
Returns:
|
2020-12-24 04:40:08 +00:00
|
|
|
List<str> of file paths where the photo is found on disk.
|
2020-12-24 00:16:08 +00:00
|
|
|
"""
|
|
|
|
return [part.file for item in self.media for part in item.parts if part]
|
2023-08-29 03:29:39 +00:00
|
|
|
|
2018-09-08 15:25:16 +00:00
|
|
|
def sync(self, resolution, client=None, clientId=None, limit=None, title=None):
|
|
|
|
""" Add current photo as sync item for specified device.
|
2020-11-23 03:06:30 +00:00
|
|
|
See :func:`~plexapi.myplex.MyPlexAccount.sync` for possible exceptions.
|
2018-09-08 15:25:16 +00:00
|
|
|
|
|
|
|
Parameters:
|
|
|
|
resolution (str): maximum allowed resolution for synchronized photos, see PHOTO_QUALITY_* values in the
|
2020-11-23 03:06:30 +00:00
|
|
|
module :mod:`~plexapi.sync`.
|
|
|
|
client (:class:`~plexapi.myplex.MyPlexDevice`): sync destination, see
|
|
|
|
:func:`~plexapi.myplex.MyPlexAccount.sync`.
|
|
|
|
clientId (str): sync destination, see :func:`~plexapi.myplex.MyPlexAccount.sync`.
|
2018-09-08 15:25:16 +00:00
|
|
|
limit (int): maximum count of items to sync, unlimited if `None`.
|
2020-11-23 03:06:30 +00:00
|
|
|
title (str): descriptive title for the new :class:`~plexapi.sync.SyncItem`, if empty the value would be
|
2018-09-08 15:25:16 +00:00
|
|
|
generated from metadata of current photo.
|
|
|
|
|
|
|
|
Returns:
|
2020-11-23 03:06:30 +00:00
|
|
|
:class:`~plexapi.sync.SyncItem`: an instance of created syncItem.
|
2018-09-08 15:25:16 +00:00
|
|
|
"""
|
|
|
|
|
|
|
|
from plexapi.sync import SyncItem, Policy, MediaSettings
|
|
|
|
|
|
|
|
myplex = self._server.myPlexAccount()
|
|
|
|
sync_item = SyncItem(self._server, None)
|
|
|
|
sync_item.title = title if title else self.title
|
|
|
|
sync_item.rootTitle = self.title
|
|
|
|
sync_item.contentType = self.listType
|
|
|
|
sync_item.metadataType = self.METADATA_TYPE
|
|
|
|
sync_item.machineIdentifier = self._server.machineIdentifier
|
|
|
|
|
2018-09-14 18:03:23 +00:00
|
|
|
section = self.section()
|
2018-09-08 15:25:16 +00:00
|
|
|
|
2022-08-28 05:56:01 +00:00
|
|
|
sync_item.location = f'library://{section.uuid}/item/{quote_plus(self.key)}'
|
2018-09-08 15:25:16 +00:00
|
|
|
sync_item.policy = Policy.create(limit)
|
|
|
|
sync_item.mediaSettings = MediaSettings.createPhoto(resolution)
|
|
|
|
|
2020-06-06 18:14:38 +00:00
|
|
|
return myplex.sync(sync_item, client=client, clientId=clientId)
|
2020-10-10 18:55:49 +00:00
|
|
|
|
2021-09-26 22:23:09 +00:00
|
|
|
def _getWebURL(self, base=None):
|
|
|
|
""" Get the Plex Web URL with the correct parameters. """
|
|
|
|
return self._server._buildWebURL(base=base, endpoint='details', key=self.parentKey, legacy=1)
|
2022-07-21 03:03:20 +00:00
|
|
|
|
2023-08-27 19:59:53 +00:00
|
|
|
@property
|
|
|
|
def metadataDirectory(self):
|
|
|
|
""" Returns the Plex Media Server data directory where the metadata is stored. """
|
|
|
|
guid_hash = utils.sha1hash(self.parentGuid)
|
|
|
|
return str(Path('Metadata') / 'Photos' / guid_hash[0] / f'{guid_hash[1:]}.bundle')
|
|
|
|
|
2022-07-21 03:03:20 +00:00
|
|
|
|
|
|
|
@utils.registerPlexObject
|
|
|
|
class PhotoSession(PlexSession, Photo):
|
|
|
|
""" Represents a single Photo session
|
|
|
|
loaded from :func:`~plexapi.server.PlexServer.sessions`.
|
|
|
|
"""
|
|
|
|
_SESSIONTYPE = True
|
|
|
|
|
|
|
|
def _loadData(self, data):
|
|
|
|
""" Load attribute values from Plex XML response. """
|
|
|
|
Photo._loadData(self, data)
|
|
|
|
PlexSession._loadData(self, data)
|