mirror of
https://github.com/meisnate12/Plex-Meta-Manager
synced 2024-11-10 06:54:21 +00:00
[31] update item delete
This commit is contained in:
parent
71465c3378
commit
5103a576db
6 changed files with 30 additions and 15 deletions
2
VERSION
2
VERSION
|
@ -1 +1 @@
|
|||
1.18.0-develop30
|
||||
1.18.0-develop31
|
||||
|
|
|
@ -804,13 +804,15 @@ class CollectionBuilder:
|
|||
if self.build_collection:
|
||||
try:
|
||||
self.obj = self.library.get_playlist(self.name) if self.playlist else self.library.get_collection(self.name, force_search=True)
|
||||
except Failed:
|
||||
self.obj = None
|
||||
else:
|
||||
if (self.smart and not self.obj.smart) or (not self.smart and self.obj.smart):
|
||||
logger.info("")
|
||||
logger.error(f"{self.Type} Error: Converting {self.obj.title} to a {'smart' if self.smart else 'normal'} collection")
|
||||
self.library.query(self.obj.delete)
|
||||
self.library.delete(self.obj)
|
||||
self.obj = None
|
||||
except Failed:
|
||||
self.obj = None
|
||||
|
||||
if self.smart:
|
||||
check_url = self.smart_url if self.smart_url else self.smart_label_url
|
||||
if self.obj and check_url != self.library.smart_filter(self.obj):
|
||||
|
@ -2780,14 +2782,14 @@ class CollectionBuilder:
|
|||
else:
|
||||
output = ""
|
||||
if self.obj:
|
||||
self.library.query(self.obj.delete)
|
||||
self.library.delete(self.obj)
|
||||
|
||||
if self.playlist and self.valid_users:
|
||||
for user in self.valid_users:
|
||||
try:
|
||||
self.library.delete_user_playlist(self.obj.title, user)
|
||||
output += f"\nPlaylist deleted on User {user}"
|
||||
except NotFound:
|
||||
except Failed:
|
||||
output += f"\nPlaylist not found on User {user}"
|
||||
return output
|
||||
|
||||
|
@ -2799,7 +2801,7 @@ class CollectionBuilder:
|
|||
for user in self.valid_users:
|
||||
try:
|
||||
self.library.delete_user_playlist(self.obj.title, user)
|
||||
except NotFound:
|
||||
except Failed:
|
||||
pass
|
||||
self.obj.copyToUser(user)
|
||||
logger.info(f"Playlist: {self.name} synced to {user}")
|
||||
|
|
|
@ -1005,8 +1005,11 @@ class MetadataFile(DataFile):
|
|||
sync.pop(other_name)
|
||||
self.collections[other_name] = col
|
||||
for col_title, col in sync.items():
|
||||
col.delete()
|
||||
logger.info(f"{map_name} Dynamic Collection: {col_title} Deleted")
|
||||
try:
|
||||
self.library.delete(col)
|
||||
logger.info(f"{map_name} Dynamic Collection: {col_title} Deleted")
|
||||
except Failed as e:
|
||||
logger.error(e)
|
||||
except Failed as e:
|
||||
logger.error(e)
|
||||
logger.error(f"{map_name} Dynamic Collection Failed")
|
||||
|
|
|
@ -731,8 +731,11 @@ class Operations:
|
|||
and (configured is None
|
||||
or (configured is True and col.title in self.library.collections)
|
||||
or (configured is False and col.title not in self.library.collections)):
|
||||
self.library.query(col.delete)
|
||||
logger.info(f"{col.title} Deleted")
|
||||
try:
|
||||
self.library.delete(col)
|
||||
logger.info(f"{col.title} Deleted")
|
||||
except Failed as e:
|
||||
logger.error(e)
|
||||
else:
|
||||
if "PMM" not in labels:
|
||||
unmanaged_collections.append(col)
|
||||
|
|
|
@ -555,6 +555,13 @@ class Plex(Library):
|
|||
def query(self, method):
|
||||
return method()
|
||||
|
||||
def delete(self, obj):
|
||||
try:
|
||||
return self.query(obj.delete)
|
||||
except Exception:
|
||||
logger.stacktrace()
|
||||
raise Failed(f"Plex Error: Failed to delete {obj.title}")
|
||||
|
||||
@retry(stop_max_attempt_number=6, wait_fixed=10000, retry_on_exception=util.retry_if_not_plex)
|
||||
def query_data(self, method, data):
|
||||
return method(data)
|
||||
|
@ -708,7 +715,7 @@ class Plex(Library):
|
|||
return self._users
|
||||
|
||||
def delete_user_playlist(self, title, user):
|
||||
self.PlexServer.switchUser(user).playlist(title).delete()
|
||||
self.delete(self.PlexServer.switchUser(user).playlist(title))
|
||||
|
||||
@property
|
||||
def account(self):
|
||||
|
|
|
@ -459,10 +459,10 @@ def run_libraries(config):
|
|||
logger.info("")
|
||||
for collection in library.get_all_collections():
|
||||
try:
|
||||
library.query(collection.delete)
|
||||
library.delete(collection)
|
||||
logger.info(f"Collection {collection.title} Deleted")
|
||||
except NotFound:
|
||||
logger.error(f"Collection {collection.title} Failed to Delete")
|
||||
except Failed as e:
|
||||
logger.error(e)
|
||||
library_status[library.name]["All Collections Deleted"] = str(datetime.now() - time_start).split('.')[0]
|
||||
|
||||
if delete_labels and not playlist_only:
|
||||
|
|
Loading…
Reference in a new issue