mirror of
https://github.com/jellyfin/jellyfin-kodi.git
synced 2024-11-13 21:56:11 +00:00
parent
53fbbffa75
commit
afa582057a
4 changed files with 21 additions and 74 deletions
|
@ -132,7 +132,7 @@ def getThemeMedia():
|
||||||
server = WINDOW.getProperty('server%s' % currUser)
|
server = WINDOW.getProperty('server%s' % currUser)
|
||||||
playback = None
|
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
|
# Choose playback method
|
||||||
resp = xbmcgui.Dialog().select("Choose playback method for your themes", ["Direct Play", "Direct Stream"])
|
resp = xbmcgui.Dialog().select("Choose playback method for your themes", ["Direct Play", "Direct Stream"])
|
||||||
|
@ -160,7 +160,7 @@ def getThemeMedia():
|
||||||
|
|
||||||
# Create library directory
|
# Create library directory
|
||||||
if not xbmcvfs.exists(library):
|
if not xbmcvfs.exists(library):
|
||||||
xbmcvfs.mkdirs(library)
|
xbmcvfs.mkdir(library)
|
||||||
|
|
||||||
# Get every user view Id
|
# Get every user view Id
|
||||||
userViews = []
|
userViews = []
|
||||||
|
@ -186,7 +186,7 @@ def getThemeMedia():
|
||||||
|
|
||||||
# Get paths for theme videos
|
# Get paths for theme videos
|
||||||
for itemId in itemIds:
|
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
|
# Create folders for each content
|
||||||
if not xbmcvfs.exists(nfo_path):
|
if not xbmcvfs.exists(nfo_path):
|
||||||
xbmcvfs.mkdir(nfo_path)
|
xbmcvfs.mkdir(nfo_path)
|
||||||
|
@ -244,7 +244,7 @@ def getThemeMedia():
|
||||||
if itemId in itemIds:
|
if itemId in itemIds:
|
||||||
continue
|
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
|
# Create folders for each content
|
||||||
if not xbmcvfs.exists(nfo_path):
|
if not xbmcvfs.exists(nfo_path):
|
||||||
xbmcvfs.mkdir(nfo_path)
|
xbmcvfs.mkdir(nfo_path)
|
||||||
|
|
|
@ -164,9 +164,6 @@ class LibrarySync(threading.Thread):
|
||||||
try:
|
try:
|
||||||
cursor.execute("ALTER TABLE emby ADD COLUMN kodi_file_id INTEGER")
|
cursor.execute("ALTER TABLE emby ADD COLUMN kodi_file_id INTEGER")
|
||||||
except: pass
|
except: pass
|
||||||
try:
|
|
||||||
cursor.execute("ALTER TABLE emby ADD COLUMN fullpath TEXT")
|
|
||||||
except: pass
|
|
||||||
connection.commit()
|
connection.commit()
|
||||||
|
|
||||||
self.MusicFullSync(connection,cursor,pDialog)
|
self.MusicFullSync(connection,cursor,pDialog)
|
||||||
|
|
|
@ -310,12 +310,6 @@ def reset():
|
||||||
connection.commit()
|
connection.commit()
|
||||||
cursor.close()
|
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
|
# reset the install run flag
|
||||||
#settings('SyncInstallRunDone', "false")
|
#settings('SyncInstallRunDone', "false")
|
||||||
|
|
|
@ -11,7 +11,6 @@ from ntpath import split as ntsplit
|
||||||
import xbmc
|
import xbmc
|
||||||
import xbmcgui
|
import xbmcgui
|
||||||
import xbmcaddon
|
import xbmcaddon
|
||||||
import xbmcvfs
|
|
||||||
|
|
||||||
from ClientInformation import ClientInformation
|
from ClientInformation import ClientInformation
|
||||||
import Utils as utils
|
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(?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"
|
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))
|
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
|
# Create the reference in emby table
|
||||||
query = "INSERT INTO emby(emby_id, kodi_id, media_type, checksum, fullpath) values(?, ?, ?, ?, ?)"
|
query = "INSERT INTO emby(emby_id, kodi_id, media_type, checksum) values(?, ?, ?, ?)"
|
||||||
cursor.execute(query, (embyId, albumid, "album", checksum, fullpath))
|
cursor.execute(query, (embyId, albumid, "album", checksum))
|
||||||
|
|
||||||
|
|
||||||
# Add genres
|
# Add genres
|
||||||
|
@ -276,41 +270,20 @@ class WriteKodiMusicDB():
|
||||||
year = MBitem.get('ProductionYear')
|
year = MBitem.get('ProductionYear')
|
||||||
bio = API().getOverview(MBitem)
|
bio = API().getOverview(MBitem)
|
||||||
duration = timeInfo.get('TotalTime')
|
duration = timeInfo.get('TotalTime')
|
||||||
albumId = MBitem.get('AlbumId')
|
|
||||||
|
|
||||||
fullpath = ""
|
# Get the path and filename
|
||||||
if self.directpath:
|
playurl = PlayUtils().directPlay(MBitem)
|
||||||
# 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')
|
|
||||||
|
|
||||||
# Create the music library
|
try:
|
||||||
if not xbmcvfs.exists(library):
|
path, filename = ntsplit(playurl)
|
||||||
xbmcvfs.mkdirs(library)
|
if "/" in playurl:
|
||||||
|
path = "%s/" % path
|
||||||
path = xbmc.translatePath("special://profile/addon_data/plugin.video.emby/library/music/%s/" % albumId).decode('utf-8')
|
elif "\\" in playurl:
|
||||||
|
path = "%s\\" % path
|
||||||
# Create the album folder
|
except: # playurl returned false - using server streaming path, because could not figure out plugin paths for music DB
|
||||||
if not xbmcvfs.exists(path):
|
playurl = PlayUtils().directstream(MBitem, self.server, embyId, "Audio")
|
||||||
xbmcvfs.mkdir(path)
|
filename = "stream.mp3"
|
||||||
|
path = playurl.replace(filename, "")
|
||||||
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()
|
|
||||||
|
|
||||||
|
|
||||||
# Validate the path in database
|
# Validate the path in database
|
||||||
|
@ -324,7 +297,7 @@ class WriteKodiMusicDB():
|
||||||
cursor.execute(query, (pathid, path))
|
cursor.execute(query, (pathid, path))
|
||||||
|
|
||||||
# Get the album
|
# 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:
|
try:
|
||||||
albumid = cursor.fetchone()[0]
|
albumid = cursor.fetchone()[0]
|
||||||
except:
|
except:
|
||||||
|
@ -373,8 +346,8 @@ class WriteKodiMusicDB():
|
||||||
cursor.execute(query, (songid, albumid, pathid, artists, genre, name, track, duration, year, filename, musicBrainzId, playcount, lastplayed))
|
cursor.execute(query, (songid, albumid, pathid, artists, genre, name, track, duration, year, filename, musicBrainzId, playcount, lastplayed))
|
||||||
|
|
||||||
# Create the reference in emby table
|
# Create the reference in emby table
|
||||||
query = "INSERT INTO emby(emby_id, kodi_id, media_type, checksum, fullpath) values(?, ?, ?, ?, ?)"
|
query = "INSERT INTO emby(emby_id, kodi_id, media_type, checksum) values(?, ?, ?, ?)"
|
||||||
cursor.execute(query, (embyId, songid, "song", checksum, fullpath))
|
cursor.execute(query, (embyId, songid, "song", checksum))
|
||||||
|
|
||||||
|
|
||||||
# Add genres
|
# Add genres
|
||||||
|
@ -420,27 +393,10 @@ class WriteKodiMusicDB():
|
||||||
elif "song" in media_type:
|
elif "song" in media_type:
|
||||||
self.logMsg("Deleting song from Kodi library, Id: %s" % id, 1)
|
self.logMsg("Deleting song from Kodi library, Id: %s" % id, 1)
|
||||||
cursor.execute("DELETE FROM song WHERE idSong = ?", (kodi_id,))
|
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:
|
elif "album" in media_type:
|
||||||
self.logMsg("Deleting album from Kodi library, Id: %s" % id, 1)
|
self.logMsg("Deleting album from Kodi library, Id: %s" % id, 1)
|
||||||
cursor.execute("DELETE FROM album WHERE idAlbum = ?", (kodi_id,))
|
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
|
# Delete the record in emby table
|
||||||
cursor.execute("DELETE FROM emby WHERE emby_id = ?", (id,))
|
cursor.execute("DELETE FROM emby WHERE emby_id = ?", (id,))
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue