mirror of
https://github.com/jellyfin/jellyfin-kodi.git
synced 2025-12-13 02:23:18 +00:00
Music library
make it seemless - dependant on alternate ip to be enabled to add pathsubstitution.
This commit is contained in:
parent
64e413b9d1
commit
e09c209a6b
5 changed files with 123 additions and 16 deletions
|
|
@ -101,13 +101,17 @@ class UserClient(threading.Thread):
|
|||
|
||||
def getServer(self, prefix=True):
|
||||
|
||||
alternate = utils.settings('altip') == "true"
|
||||
|
||||
# For https support
|
||||
HTTPS = utils.settings('https')
|
||||
host = utils.settings('ipaddress')
|
||||
port = utils.settings('port')
|
||||
# Alternate host
|
||||
if utils.settings('altip') == "true":
|
||||
if alternate:
|
||||
HTTPS = utils.settings('secondhttps')
|
||||
host = utils.settings('secondipaddress')
|
||||
port = utils.settings('secondport')
|
||||
|
||||
server = host + ":" + port
|
||||
|
||||
|
|
@ -149,6 +153,8 @@ class UserClient(threading.Thread):
|
|||
def getSSLverify(self):
|
||||
# Verify host certificate
|
||||
s_sslverify = utils.settings('sslverify')
|
||||
if utils.settings('altip') == "true":
|
||||
s_sslverify = utils.settings('secondsslverify')
|
||||
|
||||
if s_sslverify == "true":
|
||||
return True
|
||||
|
|
@ -158,6 +164,8 @@ class UserClient(threading.Thread):
|
|||
def getSSL(self):
|
||||
# Client side certificate
|
||||
s_cert = utils.settings('sslcert')
|
||||
if utils.settings('altip') == "true":
|
||||
s_cert = utils.settings('secondsslcert')
|
||||
|
||||
if s_cert == "None":
|
||||
return None
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ import inspect
|
|||
import sqlite3
|
||||
import string
|
||||
import unicodedata
|
||||
|
||||
import xml.etree.ElementTree as etree
|
||||
|
||||
from API import API
|
||||
from PlayUtils import PlayUtils
|
||||
|
|
@ -185,6 +185,82 @@ def createSources():
|
|||
'</sources>'
|
||||
)
|
||||
|
||||
def pathsubstitution(add=True):
|
||||
|
||||
path = xbmc.translatePath('special://userdata').decode('utf-8')
|
||||
xmlpath = "%sadvancedsettings.xml" % path
|
||||
xmlpathexists = xbmcvfs.exists(xmlpath)
|
||||
|
||||
# original address
|
||||
originalServer = settings('ipaddress')
|
||||
originalPort = settings('port')
|
||||
originalHttp = settings('https') == "true"
|
||||
|
||||
if originalHttp:
|
||||
originalHttp = "https"
|
||||
else:
|
||||
originalHttp = "http"
|
||||
|
||||
# Process add or deletion
|
||||
if add:
|
||||
# second address
|
||||
secondServer = settings('secondipaddress')
|
||||
secondPort = settings('secondport')
|
||||
secondHttp = settings('secondhttps') == "true"
|
||||
|
||||
if secondHttp:
|
||||
secondHttp = "https"
|
||||
else:
|
||||
secondHttp = "http"
|
||||
|
||||
logMsg("EMBY", "Original address: %s://%s:%s, alternate is: %s://%s:%s" % (originalHttp, originalServer, originalPort, secondHttp, secondServer, secondPort), 1)
|
||||
|
||||
if xmlpathexists:
|
||||
# we need to modify the file.
|
||||
try:
|
||||
xmlparse = etree.parse(xmlpath)
|
||||
except: # Document is blank
|
||||
root = etree.Element('advancedsettings')
|
||||
else:
|
||||
root = xmlparse.getroot()
|
||||
|
||||
pathsubs = root.find('pathsubstitution')
|
||||
if pathsubs is None:
|
||||
pathsubs = etree.SubElement(root, 'pathsubstitution')
|
||||
else:
|
||||
# we need to create the file.
|
||||
root = etree.Element('advancedsettings')
|
||||
pathsubs = etree.SubElement(root, 'pathsubstitution')
|
||||
|
||||
substitute = etree.SubElement(pathsubs, 'substitute')
|
||||
# From original address
|
||||
etree.SubElement(substitute, 'from').text = "%s://%s:%s" % (originalHttp, originalServer, originalPort)
|
||||
# To secondary address
|
||||
etree.SubElement(substitute, 'to').text = "%s://%s:%s" % (secondHttp, secondServer, secondPort)
|
||||
|
||||
etree.ElementTree(root).write(xmlpath)
|
||||
settings('pathsub', "true")
|
||||
|
||||
else: # delete the path substitution, we don't need it anymore.
|
||||
logMsg("EMBY", "Alternate address is disabled, removing path substitution for: %s://%s:%s" % (originalHttp, originalServer, originalPort), 1)
|
||||
|
||||
xmlparse = etree.parse(xmlpath)
|
||||
root = xmlparse.getroot()
|
||||
|
||||
iterator = root.getiterator("pathsubstitution")
|
||||
|
||||
for substitutes in iterator:
|
||||
for substitute in substitutes:
|
||||
frominsert = substitute.find(".//from").text == "%s://%s:%s" % (originalHttp, originalServer, originalPort)
|
||||
|
||||
if frominsert:
|
||||
# Found a match, in case there's more than one substitution.
|
||||
substitutes.remove(substitute)
|
||||
|
||||
etree.ElementTree(root).write(xmlpath)
|
||||
settings('pathsub', "false")
|
||||
|
||||
|
||||
def settings(setting, value = None):
|
||||
# Get or add addon setting
|
||||
addon = xbmcaddon.Addon()
|
||||
|
|
|
|||
|
|
@ -271,19 +271,23 @@ class WriteKodiMusicDB():
|
|||
bio = API().getOverview(MBitem)
|
||||
duration = timeInfo.get('TotalTime')
|
||||
|
||||
# Get the path and filename
|
||||
playurl = PlayUtils().directPlay(MBitem)
|
||||
|
||||
try:
|
||||
if utils.settings('directstreammusic') == "true":
|
||||
WINDOW = xbmcgui.Window(10000)
|
||||
username = WINDOW.getProperty('currUser')
|
||||
server = WINDOW.getProperty('server%s' % username)
|
||||
|
||||
playurl = PlayUtils().directStream(MBitem, server, embyId, "Audio")
|
||||
filename = "stream.mp3"
|
||||
path = playurl.replace(filename, "")
|
||||
else:
|
||||
# Get the path and filename
|
||||
playurl = PlayUtils().directPlay(MBitem)
|
||||
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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue