updated plexapi to 4.6.1

pull/309/head
meisnate12 4 years ago
parent 63b48e928d
commit 35b4a53c46

@ -1042,8 +1042,7 @@ class CollectionBuilder:
if self.build_collection: if self.build_collection:
try: try:
self.obj = self.library.get_collection(self.name) self.obj = self.library.get_collection(self.name)
collection_smart = self.library.smart(self.obj) if (self.smart and not self.obj.smart) or (not self.smart and self.obj.smart):
if (self.smart and not collection_smart) or (not self.smart and collection_smart):
logger.info("") logger.info("")
logger.error(f"Collection Error: Converting {self.obj.title} to a {'smart' if self.smart else 'normal'} collection") logger.error(f"Collection Error: Converting {self.obj.title} to a {'smart' if self.smart else 'normal'} collection")
self.library.query(self.obj.delete) self.library.query(self.obj.delete)

@ -5,7 +5,7 @@ from modules.util import Failed, Image
import plexapi import plexapi
from plexapi import utils from plexapi import utils
from plexapi.exceptions import BadRequest, NotFound, Unauthorized from plexapi.exceptions import BadRequest, NotFound, Unauthorized
from plexapi.collection import Collections from plexapi.collection import Collection
from plexapi.server import PlexServer from plexapi.server import PlexServer
from retrying import retry from retrying import retry
from ruamel import yaml from ruamel import yaml
@ -376,10 +376,6 @@ class Plex:
def fetchItems(self, key, container_start, container_size): def fetchItems(self, key, container_start, container_size):
return self.Plex.fetchItems(key, container_start=container_start, container_size=container_size) return self.Plex.fetchItems(key, container_start=container_start, container_size=container_size)
@retry(stop_max_attempt_number=6, wait_fixed=10000, retry_on_exception=util.retry_if_not_plex)
def server_search(self, data):
return self.PlexServer.search(data)
@retry(stop_max_attempt_number=6, wait_fixed=10000, retry_on_exception=util.retry_if_not_plex) @retry(stop_max_attempt_number=6, wait_fixed=10000, retry_on_exception=util.retry_if_not_plex)
def query(self, method): def query(self, method):
return method() return method()
@ -532,23 +528,19 @@ class Plex:
self.test_smart_filter(uri_args) self.test_smart_filter(uri_args)
self._query(f"/library/collections/{collection.ratingKey}/items{utils.joinArgs({'uri': self.build_smart_filter(uri_args)})}", put=True) self._query(f"/library/collections/{collection.ratingKey}/items{utils.joinArgs({'uri': self.build_smart_filter(uri_args)})}", put=True)
def smart(self, collection):
return utils.cast(bool, self.get_collection(collection)._data.attrib.get('smart', '0'))
def smart_filter(self, collection): def smart_filter(self, collection):
smart_filter = self.get_collection(collection)._data.attrib.get('content') smart_filter = self.get_collection(collection).content
return smart_filter[smart_filter.index("?"):] return smart_filter[smart_filter.index("?"):]
def get_collection(self, data): def get_collection(self, data):
if isinstance(data, int): if isinstance(data, int):
collection = self.fetchItem(data) collection = self.fetchItem(data)
elif isinstance(data, Collections): elif isinstance(data, Collection):
collection = data collection = data
else: else:
collection = util.choose_from_list(self.search(title=str(data), libtype="collection"), "collection", str(data), exact=True) collection = util.choose_from_list(self.search(title=str(data), libtype="collection"), "collection", str(data), exact=True)
if collection: if collection:
return collection return collection
else:
raise Failed(f"Plex Error: Collection {data} not found") raise Failed(f"Plex Error: Collection {data} not found")
def validate_collections(self, collections): def validate_collections(self, collections):
@ -630,9 +622,9 @@ class Plex:
def get_collection_items(self, collection, smart_label_collection): def get_collection_items(self, collection, smart_label_collection):
if smart_label_collection: if smart_label_collection:
return self.get_labeled_items(collection.title if isinstance(collection, Collections) else str(collection)) return self.get_labeled_items(collection.title if isinstance(collection, Collection) else str(collection))
elif isinstance(collection, Collections): elif isinstance(collection, Collection):
if self.smart(collection): if collection.smart:
return self.get_filter_items(self.smart_filter(collection)) return self.get_filter_items(self.smart_filter(collection))
else: else:
return self.query(collection.items) return self.query(collection.items)
@ -644,7 +636,7 @@ class Plex:
return self.Plex._search(key, None, 0, plexapi.X_PLEX_CONTAINER_SIZE) return self.Plex._search(key, None, 0, plexapi.X_PLEX_CONTAINER_SIZE)
def get_collection_name_and_items(self, collection, smart_label_collection): def get_collection_name_and_items(self, collection, smart_label_collection):
name = collection.title if isinstance(collection, Collections) else str(collection) name = collection.title if isinstance(collection, Collection) else str(collection)
return name, self.get_collection_items(collection, smart_label_collection) return name, self.get_collection_items(collection, smart_label_collection)
def map_guids(self): def map_guids(self):

@ -1,6 +1,6 @@
# Remove # Remove
# Less common, pinned # Less common, pinned
PlexAPI==4.5.2 PlexAPI==4.6.1
tmdbv3api==1.7.5 tmdbv3api==1.7.5
trakt.py==4.3.0 trakt.py==4.3.0
arrapi==1.0.0 arrapi==1.0.0

Loading…
Cancel
Save