From 353cb04532d2a7ee97e01d029805db9ed8bd5399 Mon Sep 17 00:00:00 2001 From: croneter Date: Sat, 4 May 2019 14:29:18 +0200 Subject: [PATCH] New functions --- resources/lib/playqueue.py | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/resources/lib/playqueue.py b/resources/lib/playqueue.py index dde6921b..ccd0fa9f 100644 --- a/resources/lib/playqueue.py +++ b/resources/lib/playqueue.py @@ -64,8 +64,31 @@ def get_playqueue_from_type(kodi_playlist_type): if playqueue.type == kodi_playlist_type: break else: - raise ValueError('Wrong playlist type passed in: %s', - kodi_playlist_type) + raise ValueError('Wrong playlist type passed in: %s' + % kodi_playlist_type) + return playqueue + + +def playqueue_from_plextype(plex_type): + if plex_type in v.PLEX_VIDEOTYPES: + plex_type = v.PLEX_TYPE_VIDEO_PLAYLIST + elif plex_type in v.PLEX_AUDIOTYPES: + plex_type = v.PLEX_TYPE_AUDIO_PLAYLIST + else: + plex_type = v.PLEX_TYPE_VIDEO_PLAYLIST + for playqueue in PLAYQUEUES: + if playqueue.type == plex_type: + break + return playqueue + + +def playqueue_from_id(kodi_playlist_id): + for playqueue in PLAYQUEUES: + if playqueue.playlistid == kodi_playlist_id: + break + else: + raise ValueError('Wrong playlist id passed in: %s of type %s' + % (kodi_playlist_id, type(kodi_playlist_id))) return playqueue