From b11e9c290292516a59ebb1e6f238b7630481102e Mon Sep 17 00:00:00 2001 From: angelblue05 Date: Fri, 8 Jan 2016 12:25:22 -0600 Subject: [PATCH 1/7] Fix grouped view --- resources/lib/librarysync.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/lib/librarysync.py b/resources/lib/librarysync.py index aba8e875..617aef5c 100644 --- a/resources/lib/librarysync.py +++ b/resources/lib/librarysync.py @@ -360,7 +360,7 @@ class LibrarySync(threading.Thread): # This is only reserved for the detection of grouped views if (grouped_view['Type'] == "UserView" and grouped_view.get('CollectionType') == mediatype and - grouped_view['Id'] not in grouped_view['Path']): + grouped_view['Id'] not in grouped_view.get('Path', "")): # Take the name of the userview foldername = grouped_view['Name'] break From 222f6e06cbaca7f8bd66508df1e1401dc200befa Mon Sep 17 00:00:00 2001 From: angelblue05 Date: Fri, 8 Jan 2016 12:56:21 -0600 Subject: [PATCH 2/7] Open music cursor for albumartist --- resources/lib/itemtypes.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/lib/itemtypes.py b/resources/lib/itemtypes.py index ec831f12..1e79a368 100644 --- a/resources/lib/itemtypes.py +++ b/resources/lib/itemtypes.py @@ -98,7 +98,7 @@ class Items(object): musicconn = None - if itemtype in ('MusicAlbum', 'MusicArtist', 'Audio'): + if itemtype in ('MusicAlbum', 'MusicArtist', 'AlbumArtist', 'Audio'): if music_enabled: musicconn = utils.kodiSQL('music') musiccursor = musicconn.cursor() From a577f9ef9866d9e3eb179c78187b88515c9c8c67 Mon Sep 17 00:00:00 2001 From: angelblue05 Date: Fri, 8 Jan 2016 20:09:55 -0600 Subject: [PATCH 3/7] Version bump 1.1.72 --- addon.xml | 2 +- changelog.txt | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/addon.xml b/addon.xml index 4a22514e..69e48b98 100644 --- a/addon.xml +++ b/addon.xml @@ -1,7 +1,7 @@ diff --git a/changelog.txt b/changelog.txt index f1cc627c..34f9cb56 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,3 +1,8 @@ +version 1.1.72 +- Fix to extrafanart +- Fix for artists deletion +- Fix for views + version 1.1.70 - Include AirsAfterSeason for special episodes ordering - Cover art settings - label adjusted. A reset or repair will be required if you change the settings value. From 77dd006f21e45bb8a4f0cc0e47cb9dca7fac1893 Mon Sep 17 00:00:00 2001 From: angelblue05 Date: Fri, 8 Jan 2016 20:13:52 -0600 Subject: [PATCH 4/7] 1.1.72 - Fix typo --- resources/lib/playutils.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/resources/lib/playutils.py b/resources/lib/playutils.py index e2835929..b1b2fc5f 100644 --- a/resources/lib/playutils.py +++ b/resources/lib/playutils.py @@ -36,7 +36,7 @@ class PlayUtils(): item = self.item playurl = None - if item['MediaSources'][0]['Protocol'] == "Http": + if item.get('MediaSources') and item['MediaSources'][0]['Protocol'] == "Http": # Only play as http self.logMsg("File protocol is http.", 1) playurl = self.httpPlay() @@ -74,7 +74,7 @@ class PlayUtils(): itemid = item['Id'] mediatype = item['MediaType'] - if type == "Audio": + if mediatype == "Audio": playurl = "%s/emby/Audio/%s/stream" % (server, itemid) else: playurl = "%s/emby/Videos/%s/stream?static=true" % (server, itemid) From b61b8ae8942e1bed9e7205c291e436f31c501e19 Mon Sep 17 00:00:00 2001 From: angelblue05 Date: Sat, 9 Jan 2016 03:03:39 -0600 Subject: [PATCH 5/7] Failsafe incase view is named after existing tag After the initial sync already completed. --- resources/lib/kodidb_functions.py | 58 ++++++++++++++++++++++--------- 1 file changed, 42 insertions(+), 16 deletions(-) diff --git a/resources/lib/kodidb_functions.py b/resources/lib/kodidb_functions.py index 687c485e..47713e25 100644 --- a/resources/lib/kodidb_functions.py +++ b/resources/lib/kodidb_functions.py @@ -852,26 +852,52 @@ class Kodidb_Functions(): if self.kodiversion in (15, 16): # Kodi Isengard, Jarvis - query = ' '.join(( + try: + query = ' '.join(( - "UPDATE tag_link", - "SET tag_id = ?", - "WHERE media_id = ?", - "AND media_type = ?", - "AND tag_id = ?" - )) - cursor.execute(query, (newtag, kodiid, mediatype, oldtag,)) + "UPDATE tag_link", + "SET tag_id = ?", + "WHERE media_id = ?", + "AND media_type = ?", + "AND tag_id = ?" + )) + cursor.execute(query, (newtag, kodiid, mediatype, oldtag,)) + except Exception as e: + # The new tag we are going to apply already exists for this item + # delete current tag instead + self.logMsg("Exception: %s" % e, 1) + query = ' '.join(( + + "DELETE FROM tag_link", + "WHERE media_id = ?", + "AND media_type = ?", + "AND tag_id = ?" + )) + cursor.execute(query, (kodiid, mediatype, oldtag,)) else: # Kodi Helix - query = ' '.join(( + try: + query = ' '.join(( - "UPDATE taglinks", - "SET idTag = ?", - "WHERE idMedia = ?", - "AND media_type = ?", - "AND idTag = ?" - )) - cursor.execute(query, (newtag, kodiid, mediatype, oldtag,)) + "UPDATE taglinks", + "SET idTag = ?", + "WHERE idMedia = ?", + "AND media_type = ?", + "AND idTag = ?" + )) + cursor.execute(query, (newtag, kodiid, mediatype, oldtag,)) + except Exception as e: + # The new tag we are going to apply already exists for this item + # delete current tag instead + self.logMsg("Exception: %s" % e, 1) + query = ' '.join(( + + "DELETE FROM taglinks", + "WHERE idMedia = ?", + "AND media_type = ?", + "AND idTag = ?" + )) + cursor.execute(query, (kodiid, mediatype, oldtag,)) def removeTag(self, kodiid, tagname, mediatype): From f99efb2a8317f20f7b5bd8189ddb4ab442b27906 Mon Sep 17 00:00:00 2001 From: angelblue05 Date: Sat, 9 Jan 2016 04:53:04 -0600 Subject: [PATCH 6/7] Add settings monitor Prompt for reset if playback mode change is detected --- resources/lib/kodimonitor.py | 22 ++++++++++++++++++++++ resources/lib/userclient.py | 10 ---------- service.py | 1 + 3 files changed, 23 insertions(+), 10 deletions(-) diff --git a/resources/lib/kodimonitor.py b/resources/lib/kodimonitor.py index fe22a270..80e664f6 100644 --- a/resources/lib/kodimonitor.py +++ b/resources/lib/kodimonitor.py @@ -43,6 +43,28 @@ class KodiMonitor(xbmc.Monitor): if library == "video": utils.window('emby_kodiScan', clear=True) + def onSettingsChanged(self): + # Monitor emby settings + currentPath = utils.settings('useDirectPaths') + if utils.window('emby_pluginpath') != currentPath: + # Plugin path value changed. Offer to reset + self.logMsg("Changed to playback mode detected", 1) + utils.window('emby_pluginpath', value=currentPath) + resp = xbmcgui.Dialog().yesno( + heading="Playback mode change detected", + line1=( + "Detected the playback mode has changed. The database " + "needs to be recreated for the change to be applied. " + "Proceed?")) + if resp: + utils.reset() + + currentLog = utils.settings('logLevel') + if utils.window('emby_logLevel') != currentLog: + # The log level changed, set new prop + self.logMsg("New log level: %s" % currentLog, 1) + utils.window('emby_logLevel', value=currentLog) + def onNotification(self, sender, method, data): doUtils = self.doUtils diff --git a/resources/lib/userclient.py b/resources/lib/userclient.py index 035cf784..9b4bce17 100644 --- a/resources/lib/userclient.py +++ b/resources/lib/userclient.py @@ -44,7 +44,6 @@ class UserClient(threading.Thread): self.addonName = clientinfo.ClientInfo().getAddonName() self.doUtils = downloadutils.DownloadUtils() - self.logLevel = int(utils.settings('logLevel')) threading.Thread.__init__(self) @@ -411,15 +410,6 @@ class UserClient(threading.Thread): while not monitor.abortRequested(): - # Verify the log level - currLogLevel = self.getLogLevel() - if self.logLevel != currLogLevel: - # Set new log level - self.logLevel = currLogLevel - utils.window('emby_logLevel', value=str(currLogLevel)) - self.logMsg("New Log Level: %s" % currLogLevel, 0) - - status = utils.window('emby_serverStatus') if status: # Verify the connection status to server diff --git a/service.py b/service.py index 2c97d50e..cfd36fdb 100644 --- a/service.py +++ b/service.py @@ -55,6 +55,7 @@ class Service(): utils.window('emby_logLevel', value=str(logLevel)) utils.window('emby_kodiProfile', value=xbmc.translatePath("special://profile")) + utils.window('emby_pluginpath', value=utils.settings('useDirectPaths')) # Initial logging self.logMsg("======== START %s ========" % self.addonName, 0) From 950ae7493969a84279b182138d3962d307ace4a7 Mon Sep 17 00:00:00 2001 From: angelblue05 Date: Sat, 9 Jan 2016 05:13:17 -0600 Subject: [PATCH 7/7] Undo useless changes to music The problem was in Items class, not the Music class. --- resources/lib/itemtypes.py | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/resources/lib/itemtypes.py b/resources/lib/itemtypes.py index 1e79a368..e69c5b8c 100644 --- a/resources/lib/itemtypes.py +++ b/resources/lib/itemtypes.py @@ -1879,7 +1879,6 @@ class Music(Items): def __init__(self, embycursor, musiccursor): Items.__init__(self, embycursor, musiccursor) - self.musiccursor = musiccursor self.directstream = utils.settings('streamMusic') == "true" self.userid = utils.window('emby_currUser') @@ -1936,7 +1935,7 @@ class Music(Items): def add_updateArtist(self, item, artisttype="MusicArtist"): # Process a single artist kodiversion = self.kodiversion - kodicursor = self.musiccursor + kodicursor = self.kodicursor emby_db = self.emby_db kodi_db = self.kodi_db artwork = self.artwork @@ -2019,7 +2018,7 @@ class Music(Items): # Process a single artist emby = self.emby kodiversion = self.kodiversion - kodicursor = self.musiccursor + kodicursor = self.kodicursor emby_db = self.emby_db kodi_db = self.kodi_db artwork = self.artwork @@ -2177,7 +2176,7 @@ class Music(Items): def add_updateSong(self, item): # Process single song kodiversion = self.kodiversion - kodicursor = self.musiccursor + kodicursor = self.kodicursor emby_db = self.emby_db kodi_db = self.kodi_db artwork = self.artwork @@ -2426,7 +2425,7 @@ class Music(Items): def updateUserdata(self, item): # This updates: Favorite, LastPlayedDate, Playcount, PlaybackPositionTicks # Poster with progress bar - kodicursor = self.musiccursor + kodicursor = self.kodicursor emby_db = self.emby_db kodi_db = self.kodi_db API = api.API(item) @@ -2465,7 +2464,7 @@ class Music(Items): def remove(self, itemid): # Remove kodiid, fileid, pathid, emby reference emby_db = self.emby_db - kodicursor = self.musiccursor + kodicursor = self.kodicursor artwork = self.artwork emby_dbitem = emby_db.getItem_byId(itemid) @@ -2530,7 +2529,7 @@ class Music(Items): def removeSong(self, kodiid): - kodicursor = self.musiccursor + kodicursor = self.kodicursor artwork = self.artwork artwork.deleteArtwork(kodiid, "song", kodicursor) @@ -2538,7 +2537,7 @@ class Music(Items): def removeAlbum(self, kodiid): - kodicursor = self.musiccursor + kodicursor = self.kodicursor artwork = self.artwork artwork.deleteArtwork(kodiid, "album", kodicursor) @@ -2546,7 +2545,7 @@ class Music(Items): def removeArtist(self, kodiid): - kodicursor = self.musiccursor + kodicursor = self.kodicursor artwork = self.artwork artwork.deleteArtwork(kodiid, "artist", kodicursor)