From 41342b4f7b0125dd2b1dd7b6c06b51c2bbd64870 Mon Sep 17 00:00:00 2001 From: JonnyWong16 <9099342+JonnyWong16@users.noreply.github.com> Date: Wed, 23 Dec 2020 20:39:15 -0800 Subject: [PATCH] Replace use of etag with class --- plexapi/audio.py | 2 +- plexapi/library.py | 11 +++++------ plexapi/photo.py | 2 +- plexapi/video.py | 6 +++--- 4 files changed, 10 insertions(+), 11 deletions(-) diff --git a/plexapi/audio.py b/plexapi/audio.py index 0b0e7512..98b92686 100644 --- a/plexapi/audio.py +++ b/plexapi/audio.py @@ -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') diff --git a/plexapi/library.py b/plexapi/library.py index 9ed90c64..64619436 100644 --- a/plexapi/library.py +++ b/plexapi/library.py @@ -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') diff --git a/plexapi/photo.py b/plexapi/photo.py index 0898d479..fbc0ee22 100644 --- a/plexapi/photo.py +++ b/plexapi/photo.py @@ -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') diff --git a/plexapi/video.py b/plexapi/video.py index ab1ed7aa..e8977751 100644 --- a/plexapi/video.py +++ b/plexapi/video.py @@ -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. """