mirror of
https://github.com/jellyfin/jellyfin-kodi.git
synced 2024-11-10 04:06: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)
|
||||
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)
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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,))
|
||||
|
||||
|
|
Loading…
Reference in a new issue