[31] update playlist fixes

pull/1894/head
meisnate12 9 months ago
parent 9fc99d3302
commit 428dbe6ba2

@ -1 +1 @@
1.20.0-develop30 1.20.0-develop31

@ -530,10 +530,7 @@ class CollectionBuilder:
self.exclude_users = config.general["playlist_exclude_users"] self.exclude_users = config.general["playlist_exclude_users"]
logger.warning(f"Playlist Warning: exclude_users attribute not found defaulting to playlist_exclude_users: {self.exclude_users}") logger.warning(f"Playlist Warning: exclude_users attribute not found defaulting to playlist_exclude_users: {self.exclude_users}")
plex_admin = self.library.account.username plex_users = self.library.users + [self.library.account.username]
_plex_users = self.library.users
plex_users = _plex_users.copy()
plex_users.append(plex_admin)
self.exclude_users = util.get_list(self.exclude_users) if self.exclude_users else [] self.exclude_users = util.get_list(self.exclude_users) if self.exclude_users else []
for user in self.exclude_users: for user in self.exclude_users:
@ -556,8 +553,7 @@ class CollectionBuilder:
logger.debug("Validating Method: delete_playlist") logger.debug("Validating Method: delete_playlist")
logger.debug(f"Value: {data[methods['delete_playlist']]}") logger.debug(f"Value: {data[methods['delete_playlist']]}")
if util.parse(self.Type, "delete_playlist", self.data, datatype="bool", methods=methods, default=False): if util.parse(self.Type, "delete_playlist", self.data, datatype="bool", methods=methods, default=False):
playlist_getters = [self.library.get_playlist, self.library.get_playlist_from_users] for getter in [self.library.get_playlist, self.library.get_playlist_from_users]:
for getter in playlist_getters:
try: try:
self.obj = getter(self.name) self.obj = getter(self.name)
break break
@ -3544,15 +3540,11 @@ class CollectionBuilder:
if self.playlist: if self.playlist:
for user in self.valid_users: for user in self.valid_users:
if user == self.library.account.username:
try: try:
if user == self.library.account.username:
_ = self.library.get_playlist(title) # Verify if this playlist exists in Admin to avoid log confusion _ = self.library.get_playlist(title) # Verify if this playlist exists in Admin to avoid log confusion
self.library.delete(self.obj) self.library.delete(self.obj)
output += f"\nPlaylist deleted on {user}"
except Failed:
output += f"\nPlaylist not found on {user}"
else: else:
try:
self.library.delete_user_playlist(title, user) self.library.delete_user_playlist(title, user)
output += f"\nPlaylist deleted on User {user}" output += f"\nPlaylist deleted on User {user}"
except Failed: except Failed:
@ -3572,8 +3564,7 @@ class CollectionBuilder:
except Failed: except Failed:
pass pass
if user != self.library.account.username: if user != self.library.account.username:
new_playlist = self.obj.copyToUser(user) self.obj.copyToUser(user).editSummary(summary=self.obj.summary).reload()
new_playlist = new_playlist.editSummary(summary=self.summaries["summary"]).reload()
logger.info(f"Playlist: {self.name} synced to {user}") logger.info(f"Playlist: {self.name} synced to {user}")
def exclude_admin_from_playlist(self): def exclude_admin_from_playlist(self):
@ -3583,9 +3574,9 @@ class CollectionBuilder:
logger.info("") logger.info("")
try: try:
self.library.delete(self.obj) self.library.delete(self.obj)
logger.info(f"Playlist: {self.name} deleted on {self.library.account.username}") logger.info(f"Playlist: {self.name} deleted on User {self.library.account.username}")
except Failed: except Failed:
logger.info(f"Playlist: {self.name} not found on {self.library.account.username}") logger.info(f"Playlist: {self.name} not found on User {self.library.account.username}")
def send_notifications(self, playlist=False): def send_notifications(self, playlist=False):
if self.obj and self.details["changes_webhooks"] and \ if self.obj and self.details["changes_webhooks"] and \

@ -1004,20 +1004,15 @@ class Plex(Library):
except NotFound: except NotFound:
raise Failed(f"Plex Error: Playlist {title} not found") raise Failed(f"Plex Error: Playlist {title} not found")
def get_playlist_from_users(self, title): def get_playlist_from_users(self, playlist_title):
def scan_user(server, title): for user in self.users:
try: try:
for playlist in server.playlists(): for playlist in self.PlexServer.switchUser(user).playlists():
if isinstance(playlist, Playlist): if isinstance(playlist, Playlist) and playlist.title == playlist_title:
if playlist.title == title:
return playlist return playlist
except requests.exceptions.ConnectionError: except requests.exceptions.ConnectionError:
pass pass
for user in self.users: raise Failed(f"Plex Error: Playlist {playlist_title} not found")
playlist_obj = scan_user(self.PlexServer.switchUser(user), title)
if playlist_obj:
return playlist_obj
raise Failed(f"Plex Error: Playlist {title} not found")
def get_collection(self, data, force_search=False, debug=True): def get_collection(self, data, force_search=False, debug=True):
if isinstance(data, Collection): if isinstance(data, Collection):

@ -1043,12 +1043,10 @@ def run_playlists(config):
if valid: if valid:
builder.sync_playlist() builder.sync_playlist()
builder.exclude_admin_from_playlist()
builder.send_notifications(playlist=True) builder.send_notifications(playlist=True)
if valid:
builder.exclude_admin_from_playlist()
except Deleted as e: except Deleted as e:
logger.info(e) logger.info(e)
status[mapping_name]["status"] = "Deleted" status[mapping_name]["status"] = "Deleted"

@ -1,10 +1,10 @@
arrapi==1.4.7 arrapi==1.4.7
GitPython==3.1.41 GitPython==3.1.42
lxml==5.1.0 lxml==5.1.0
num2words==0.5.13 num2words==0.5.13
pathvalidate==3.2.0 pathvalidate==3.2.0
pillow==10.2.0 pillow==10.2.0
PlexAPI==4.15.9 PlexAPI==4.15.10
psutil==5.9.8 psutil==5.9.8
python-dotenv==1.0.1 python-dotenv==1.0.1
python-dateutil==2.8.2 python-dateutil==2.8.2
@ -12,5 +12,5 @@ requests==2.31.0
retrying==1.3.4 retrying==1.3.4
ruamel.yaml==0.18.6 ruamel.yaml==0.18.6
schedule==1.2.1 schedule==1.2.1
setuptools==69.1.0 setuptools==69.1.1
tmdbapis==1.2.6 tmdbapis==1.2.7
Loading…
Cancel
Save