[31] update playlist fixes

pull/1894/head
meisnate12 10 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"]
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
plex_users = _plex_users.copy()
plex_users.append(plex_admin)
plex_users = self.library.users + [self.library.account.username]
self.exclude_users = util.get_list(self.exclude_users) if self.exclude_users else []
for user in self.exclude_users:
@ -556,8 +553,7 @@ class CollectionBuilder:
logger.debug("Validating Method: 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):
playlist_getters = [self.library.get_playlist, self.library.get_playlist_from_users]
for getter in playlist_getters:
for getter in [self.library.get_playlist, self.library.get_playlist_from_users]:
try:
self.obj = getter(self.name)
break
@ -2130,7 +2126,7 @@ class CollectionBuilder:
final_method = "trakt_chart"
if method_name != final_method:
logger.warning(f"{self.Type} Warning: {method_name} will run as {final_method}")
for trakt_dict in self.config.Trakt.validate_chart(self.Type, final_method, trakt_dicts, self.library.is_movie):
for trakt_dict in self.config.Trakt.validate_chart(self.Type, final_method, trakt_dicts, self.library.is_movie):
self.builders.append((final_method, trakt_dict))
def _tvdb(self, method_name, method_data):
@ -3544,19 +3540,15 @@ class CollectionBuilder:
if self.playlist:
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.delete(self.obj)
output += f"\nPlaylist deleted on {user}"
except Failed:
output += f"\nPlaylist not found on {user}"
else:
try:
else:
self.library.delete_user_playlist(title, user)
output += f"\nPlaylist deleted on User {user}"
except Failed:
output += f"\nPlaylist not found on User {user}"
output += f"\nPlaylist deleted on User {user}"
except Failed:
output += f"\nPlaylist not found on User {user}"
elif self.obj:
self.library.delete(self.obj)
return output
@ -3572,8 +3564,7 @@ class CollectionBuilder:
except Failed:
pass
if user != self.library.account.username:
new_playlist = self.obj.copyToUser(user)
new_playlist = new_playlist.editSummary(summary=self.summaries["summary"]).reload()
self.obj.copyToUser(user).editSummary(summary=self.obj.summary).reload()
logger.info(f"Playlist: {self.name} synced to {user}")
def exclude_admin_from_playlist(self):
@ -3583,9 +3574,9 @@ class CollectionBuilder:
logger.info("")
try:
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:
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):
if self.obj and self.details["changes_webhooks"] and \

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

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

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