diff --git a/resources/lib/embydb_functions.py b/resources/lib/embydb_functions.py index 4a1090f0..8c2d8b65 100644 --- a/resources/lib/embydb_functions.py +++ b/resources/lib/embydb_functions.py @@ -159,7 +159,7 @@ class Embydb_Functions(): query = ' '.join(( - "SELECT emby_id, parent_id", + "SELECT emby_id, parent_id, media_folder", "FROM emby", "WHERE kodi_id = ?", "AND media_type = ?" diff --git a/resources/lib/itemtypes.py b/resources/lib/itemtypes.py index 9be93f0a..3844e692 100644 --- a/resources/lib/itemtypes.py +++ b/resources/lib/itemtypes.py @@ -1052,6 +1052,28 @@ class TVShows(Items): studios = API.get_studios() studio = " / ".join(studios) + # Verify series pooling + if tvdb: + query = "SELECT idShow FROM tvshow WHERE C12 = ?" + kodicursor.execute(query, (tvdb,)) + try: + showid = kodicursor.fetchone()[0] + except TypeError: + pass + else: + emby_other = emby_db.getItem_byKodiId(showid, "tvshow") + if viewid == emby_other[2]: + log.info("Applying series pooling for %s", title) + + emby_other_item = emby_db.getItem_byId(emby_other[0]) + showid = emby_other_item[0] + pathid = emby_other_item[2] + log.info("showid: %s pathid: %s" % (showid, pathid)) + # Create the reference in emby table + emby_db.addReference(itemid, showid, "Series", "tvshow", pathid=pathid, + checksum=checksum, mediafolderid=viewid) + update_item = True + ##### GET THE FILE AND PATH ##### playurl = API.get_file_path()