From afa582057aa0b339f8c13d0ee9ed8a8fc0336c78 Mon Sep 17 00:00:00 2001 From: angelblue05 Date: Thu, 20 Aug 2015 20:51:47 -0500 Subject: [PATCH] Revert "Music library - remote" This reverts commit 88632dad60fbb56446e82c10c629488a52d8629c. --- resources/lib/Entrypoint.py | 8 ++-- resources/lib/LibrarySync.py | 3 -- resources/lib/Utils.py | 6 --- resources/lib/WriteKodiMusicDB.py | 78 +++++++------------------------ 4 files changed, 21 insertions(+), 74 deletions(-) diff --git a/resources/lib/Entrypoint.py b/resources/lib/Entrypoint.py index 55c0ec48..ed038f4c 100644 --- a/resources/lib/Entrypoint.py +++ b/resources/lib/Entrypoint.py @@ -132,7 +132,7 @@ def getThemeMedia(): server = WINDOW.getProperty('server%s' % currUser) playback = None - library = xbmc.translatePath("special://profile/addon_data/plugin.video.emby/library/themes/").decode('utf-8') + library = xbmc.translatePath("special://profile/addon_data/plugin.video.emby/library/").decode('utf-8') # Choose playback method resp = xbmcgui.Dialog().select("Choose playback method for your themes", ["Direct Play", "Direct Stream"]) @@ -160,7 +160,7 @@ def getThemeMedia(): # Create library directory if not xbmcvfs.exists(library): - xbmcvfs.mkdirs(library) + xbmcvfs.mkdir(library) # Get every user view Id userViews = [] @@ -186,7 +186,7 @@ def getThemeMedia(): # Get paths for theme videos for itemId in itemIds: - nfo_path = xbmc.translatePath("special://profile/addon_data/plugin.video.emby/library/themes/%s/" % itemIds[itemId]) + nfo_path = xbmc.translatePath("special://profile/addon_data/plugin.video.emby/library/%s/" % itemIds[itemId]) # Create folders for each content if not xbmcvfs.exists(nfo_path): xbmcvfs.mkdir(nfo_path) @@ -244,7 +244,7 @@ def getThemeMedia(): if itemId in itemIds: continue - nfo_path = xbmc.translatePath("special://profile/addon_data/plugin.video.emby/library/themes/%s/" % musicitemIds[itemId]) + nfo_path = xbmc.translatePath("special://profile/addon_data/plugin.video.emby/library/%s/" % musicitemIds[itemId]) # Create folders for each content if not xbmcvfs.exists(nfo_path): xbmcvfs.mkdir(nfo_path) diff --git a/resources/lib/LibrarySync.py b/resources/lib/LibrarySync.py index 34147b32..b5957afb 100644 --- a/resources/lib/LibrarySync.py +++ b/resources/lib/LibrarySync.py @@ -164,9 +164,6 @@ class LibrarySync(threading.Thread): try: cursor.execute("ALTER TABLE emby ADD COLUMN kodi_file_id INTEGER") except: pass - try: - cursor.execute("ALTER TABLE emby ADD COLUMN fullpath TEXT") - except: pass connection.commit() self.MusicFullSync(connection,cursor,pDialog) diff --git a/resources/lib/Utils.py b/resources/lib/Utils.py index a6fa5947..37886706 100644 --- a/resources/lib/Utils.py +++ b/resources/lib/Utils.py @@ -309,12 +309,6 @@ def reset(): cursor.execute("DELETE FROM " + tableName) connection.commit() cursor.close() - - # Remove the strm and nfo - path = xbmc.translatePath("special://profile/addon_data/plugin.video.emby/library/").decode('utf-8') - if xbmcvfs.exists(path): - xbmc.log("Removing %s." % path) - shutil.rmtree(path) # reset the install run flag diff --git a/resources/lib/WriteKodiMusicDB.py b/resources/lib/WriteKodiMusicDB.py index c8c0bd12..67450501 100644 --- a/resources/lib/WriteKodiMusicDB.py +++ b/resources/lib/WriteKodiMusicDB.py @@ -11,7 +11,6 @@ from ntpath import split as ntsplit import xbmc import xbmcgui import xbmcaddon -import xbmcvfs from ClientInformation import ClientInformation import Utils as utils @@ -202,14 +201,9 @@ class WriteKodiMusicDB(): query = "INSERT INTO album(idAlbum, strAlbum, strMusicBrainzAlbumID, strArtists, iYear, strGenres, strReview, strImage, lastScraped, dateAdded) values(?, ?, ?, ?, ?, ?, ?, ?, ?, ?)" cursor.execute(query, (albumid, name, musicBrainzId, artists, year, genre, bio, thumb, lastScraped, dateadded)) - fullpath = xbmc.translatePath("special://profile/addon_data/plugin.video.emby/library/music/%s/" % embyId).decode('utf-8') - # Create the album folder - if not xbmcvfs.exists(fullpath): - xbmcvfs.mkdir(fullpath) - # Create the reference in emby table - query = "INSERT INTO emby(emby_id, kodi_id, media_type, checksum, fullpath) values(?, ?, ?, ?, ?)" - cursor.execute(query, (embyId, albumid, "album", checksum, fullpath)) + query = "INSERT INTO emby(emby_id, kodi_id, media_type, checksum) values(?, ?, ?, ?)" + cursor.execute(query, (embyId, albumid, "album", checksum)) # Add genres @@ -276,41 +270,20 @@ class WriteKodiMusicDB(): year = MBitem.get('ProductionYear') bio = API().getOverview(MBitem) duration = timeInfo.get('TotalTime') - albumId = MBitem.get('AlbumId') - fullpath = "" - if self.directpath: - # Get the path and filename - playurl = PlayUtils().directPlay(MBitem) - try: - path, filename = ntsplit(playurl) - if "/" in playurl: - path = "%s/" % path - elif "\\" in playurl: - path = "%s\\" % path - except: return # playurl returned False - else: - # Plugin path via strm file. We need the album Id for directory and itemId for filename. To maintain, we'll add the path to the emby database. - library = xbmc.translatePath("special://profile/addon_data/plugin.video.emby/library/music/").decode('utf-8') + # Get the path and filename + playurl = PlayUtils().directPlay(MBitem) - # Create the music library - if not xbmcvfs.exists(library): - xbmcvfs.mkdirs(library) - - path = xbmc.translatePath("special://profile/addon_data/plugin.video.emby/library/music/%s/" % albumId).decode('utf-8') - - # Create the album folder - if not xbmcvfs.exists(path): - xbmcvfs.mkdir(path) - - filename = "%s.strm" % embyId - fullpath = "%s%s" % (path, filename) - - # Create the strm file - strm = open(fullpath, 'w') - pluginpath = "plugin://plugin.video.emby/music/%s/?id=%s&mode=play" % (albumId, embyId) - strm.write(pluginpath) - strm.close() + try: + path, filename = ntsplit(playurl) + if "/" in playurl: + path = "%s/" % path + elif "\\" in playurl: + path = "%s\\" % path + except: # playurl returned false - using server streaming path, because could not figure out plugin paths for music DB + playurl = PlayUtils().directstream(MBitem, self.server, embyId, "Audio") + filename = "stream.mp3" + path = playurl.replace(filename, "") # Validate the path in database @@ -324,7 +297,7 @@ class WriteKodiMusicDB(): cursor.execute(query, (pathid, path)) # Get the album - cursor.execute("SELECT kodi_id FROM emby WHERE emby_id = ?", (albumId,)) + cursor.execute("SELECT kodi_id FROM emby WHERE emby_id = ?", (MBitem.get("AlbumId"),)) try: albumid = cursor.fetchone()[0] except: @@ -373,8 +346,8 @@ class WriteKodiMusicDB(): cursor.execute(query, (songid, albumid, pathid, artists, genre, name, track, duration, year, filename, musicBrainzId, playcount, lastplayed)) # Create the reference in emby table - query = "INSERT INTO emby(emby_id, kodi_id, media_type, checksum, fullpath) values(?, ?, ?, ?, ?)" - cursor.execute(query, (embyId, songid, "song", checksum, fullpath)) + query = "INSERT INTO emby(emby_id, kodi_id, media_type, checksum) values(?, ?, ?, ?)" + cursor.execute(query, (embyId, songid, "song", checksum)) # Add genres @@ -420,27 +393,10 @@ class WriteKodiMusicDB(): elif "song" in media_type: self.logMsg("Deleting song from Kodi library, Id: %s" % id, 1) cursor.execute("DELETE FROM song WHERE idSong = ?", (kodi_id,)) - - cursor.execute("SELECT fullpath FROM emby WHERE emby_id = ?", (id,)) - try: # Delete the strm file - fullpath = cursor.fetchone()[0] - except: pass - else: - self.logMsg("Delete the strm %s." % fullpath) - xbmcvfs.delete(fullpath) - elif "album" in media_type: self.logMsg("Deleting album from Kodi library, Id: %s" % id, 1) cursor.execute("DELETE FROM album WHERE idAlbum = ?", (kodi_id,)) - cursor.execute("SELECT fullpath FROM emby WHERE emby_id = ?", (id,)) - try: # Delete the folder - fullpath = cursor.fetchone()[0] - except: pass - else: - self.logMsg("Delete the album folder %s." % fullpath) - xbmcvfs.rmdir(fullpath) - # Delete the record in emby table cursor.execute("DELETE FROM emby WHERE emby_id = ?", (id,))