Replace use of etag with class

This commit is contained in:
JonnyWong16 2020-12-23 20:39:15 -08:00
parent 22bfeb0820
commit 41342b4f7b
No known key found for this signature in database
GPG key ID: B1F1F9807184697A
4 changed files with 10 additions and 11 deletions

View file

@ -43,7 +43,7 @@ class Audio(PlexPartialObject):
self.addedAt = utils.toDatetime(data.attrib.get('addedAt'))
self.art = data.attrib.get('art')
self.artBlurHash = data.attrib.get('artBlurHash')
self.fields = self.findItems(data, etag='Field')
self.fields = self.findItems(data, media.Field)
self.guid = data.attrib.get('guid')
self.index = utils.cast(int, data.attrib.get('index'))
self.key = data.attrib.get('key')

View file

@ -1,10 +1,9 @@
# -*- coding: utf-8 -*-
from urllib.parse import quote, quote_plus, unquote, urlencode
from plexapi import X_PLEX_CONTAINER_SIZE, log, utils
from plexapi import X_PLEX_CONTAINER_SIZE, log, media, utils
from plexapi.base import PlexObject, PlexPartialObject
from plexapi.exceptions import BadRequest, NotFound
from plexapi.media import MediaTag
from plexapi.settings import Setting
from plexapi.utils import deprecated
@ -732,7 +731,7 @@ class LibrarySection(PlexObject):
lookup = {c.title.lower(): unquote(unquote(c.key)) for c in choices}
allowed = set(c.key for c in choices)
for item in value:
item = str((item.id or item.tag) if isinstance(item, MediaTag) else item).lower()
item = str((item.id or item.tag) if isinstance(item, media.MediaTag) else item).lower()
# find most logical choice(s) to use in url
if item in allowed: result.add(item); continue
if item in lookup: result.add(lookup[item]); continue
@ -757,7 +756,7 @@ class LibrarySection(PlexObject):
def _locations(self):
""" Returns a list of :class:`~plexapi.library.Location` objects
"""
return self.findItems(self._data, etag='Location')
return self.findItems(self._data, Location)
def sync(self, policy, mediaSettings, client=None, clientId=None, title=None, sort=None, libtype=None,
**kwargs):
@ -1453,11 +1452,11 @@ class Collections(PlexPartialObject):
self.collectionMode = data.attrib.get('collectionMode')
self.collectionSort = data.attrib.get('collectionSort')
self.contentRating = data.attrib.get('contentRating')
self.fields = self.findItems(data, etag='Field')
self.fields = self.findItems(data, media.Field)
self.guid = data.attrib.get('guid')
self.index = utils.cast(int, data.attrib.get('index'))
self.key = data.attrib.get('key').replace('/children', '') # FIX_BUG_50
self.labels = self.findItems(data, etag='Label')
self.labels = self.findItems(data, media.Label)
self.librarySectionID = data.attrib.get('librarySectionID')
self.librarySectionKey = data.attrib.get('librarySectionKey')
self.librarySectionTitle = data.attrib.get('librarySectionTitle')

View file

@ -41,7 +41,7 @@ class Photoalbum(PlexPartialObject):
self.addedAt = utils.toDatetime(data.attrib.get('addedAt'))
self.art = data.attrib.get('art')
self.composite = data.attrib.get('composite')
self.fields = self.findItems(data, etag='Field')
self.fields = self.findItems(data, media.Field)
self.guid = data.attrib.get('guid')
self.index = utils.cast(int, data.attrib.get('index'))
self.key = data.attrib.get('key')

View file

@ -41,7 +41,7 @@ class Video(PlexPartialObject):
self.addedAt = utils.toDatetime(data.attrib.get('addedAt'))
self.art = data.attrib.get('art')
self.artBlurHash = data.attrib.get('artBlurHash')
self.fields = self.findItems(data, etag='Field')
self.fields = self.findItems(data, media.Field)
self.guid = data.attrib.get('guid')
self.key = data.attrib.get('key')
self.lastViewedAt = utils.toDatetime(data.attrib.get('lastViewedAt'))
@ -499,8 +499,8 @@ class Show(Video):
"""
key = '/library/metadata/%s/children' % self.ratingKey
if isinstance(title, int):
return self.fetchItem(key, etag='Directory', index__iexact=str(title))
return self.fetchItem(key, etag='Directory', title__iexact=title)
return self.fetchItem(key, index__iexact=str(title))
return self.fetchItem(key, title__iexact=title)
def episodes(self, **kwargs):
""" Returns a list of :class:`~plexapi.video.Episode` objects in the show. """