From 205587945831013a5f463126138249c3ae82b459 Mon Sep 17 00:00:00 2001 From: tomkat83 Date: Wed, 1 Feb 2017 12:33:37 +0100 Subject: [PATCH] Store Plex library in our database for reference --- resources/lib/itemtypes.py | 12 ++++++++---- resources/lib/librarysync.py | 8 ++++---- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/resources/lib/itemtypes.py b/resources/lib/itemtypes.py index 0caef8c8..cc217b90 100644 --- a/resources/lib/itemtypes.py +++ b/resources/lib/itemtypes.py @@ -727,7 +727,6 @@ class TVShows(Items): @CatchExceptions(warnuser=True) def add_updateEpisode(self, item, viewtag=None, viewid=None): """ - viewtag and viewid are irrelevant! """ # Process single episode kodicursor = self.kodicursor @@ -1227,6 +1226,7 @@ class Music(Items): v.PLEX_TYPE_ARTIST, artistid, v.KODI_TYPE_ARTIST, + view_id=viewid, checksum=checksum) # Process the artist @@ -1323,6 +1323,7 @@ class Music(Items): v.PLEX_TYPE_ALBUM, albumid, v.KODI_TYPE_ALBUM, + view_id=viewid, checksum=checksum) # Process the album info @@ -1396,7 +1397,8 @@ class Music(Items): plex_db.addReference(parentId, v.PLEX_TYPE_ARTIST, parentId, - v.KODI_TYPE_ARTIST) + v.KODI_TYPE_ARTIST, + view_id=viewid) plex_db.updateParentId(itemid, parentId) else: # Update plex reference with the artistid @@ -1574,7 +1576,8 @@ class Music(Items): plex_db.addReference("%salbum%s" % (itemid, albumid), v.PLEX_TYPE_ALBUM, albumid, - v.KODI_TYPE_ALBUM) + v.KODI_TYPE_ALBUM, + view_id=viewid) else: # No album Id associated to the song. log.error("Song itemid: %s has no albumId associated." @@ -1653,7 +1656,8 @@ class Music(Items): v.KODI_TYPE_SONG, kodi_pathid=pathid, parent_id=albumid, - checksum=checksum) + checksum=checksum, + view_id=viewid) # Link song to album query = ( diff --git a/resources/lib/librarysync.py b/resources/lib/librarysync.py index 1416bb98..f3cc3ad1 100644 --- a/resources/lib/librarysync.py +++ b/resources/lib/librarysync.py @@ -1230,8 +1230,8 @@ class LibrarySync(Thread): self.GetUpdatelist(seasons, itemType, 'add_updateSeason', - None, - tvShowId) # send showId instead of viewid + viewName, + viewId) log.debug("Analyzed all seasons of TV show with Plex Id %s" % tvShowId) @@ -1257,8 +1257,8 @@ class LibrarySync(Thread): self.GetUpdatelist(episodes, itemType, 'add_updateEpisode', - None, - None) + viewName, + viewId) log.debug("Analyzed all episodes of TV show with Plex Id %s" % view['id'])