Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions plexapi/photo.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ class Photo(PlexPartialObject):
title (str): Photo title.
type (str): Unknown
updatedAt (datatime): Datetime this item was updated.
userRating (float): To mark photo as favorite (0.0, 10.0) 10.0 = favorite
year (int): Year this photo was taken.
"""
TAG = 'Photo'
Expand All @@ -115,9 +116,22 @@ def _loadData(self, data):
self.title = data.attrib.get('title')
self.type = data.attrib.get('type')
self.updatedAt = utils.toDatetime(data.attrib.get('updatedAt'))
self.userRating = utils.cast(float, data.attrib.get('userRating', 0))
self.year = utils.cast(int, data.attrib.get('year'))
self.media = self.findItems(data, media.Media)

def favorite(self):
""" Mark photo as favorite"""
key = '/:/rate?key=%s&rating=10.0&identifier=com.plexapp.plugins.library' % self.ratingKey
self._server.query(key)
self.reload()

def unfavorite(self):
""" Remove favorite mark from photo"""
key = '/:/rate?key=%s&rating=0&identifier=com.plexapp.plugins.library' % self.ratingKey
self._server.query(key)
self.reload()

def photoalbum(self):
""" Return this photo's :class:`~plexapi.photo.Photoalbum`. """
return self.fetchItem(self.parentKey)
Expand Down Expand Up @@ -158,6 +172,7 @@ def sync(self, resolution, client=None, clientId=None, limit=None, title=None):
sync_item.contentType = self.listType
sync_item.metadataType = self.METADATA_TYPE
sync_item.machineIdentifier = self._server.machineIdentifier
sync_item.userRating = self.userRating
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let me repeat my question: why are you assigning userRating to sync_item here? The SyncItem class knows nothing about this field and therefore it wouldn't be processed anyway. Have you misplaced the assignment and there is a place really waiting for it?

Maybe you could be polite yourself and answer the simple and not rude in any way question without throwing a tantrum? You're in the Internet, man, there are a lot of different cultures (in some of them being straightforward is the proper way of doing things, not the rude one) and not everybody here would like to offend you. Not marking conversation as resolved when it isn't seems for me like a good idea as well.


section = self.section()

Expand Down