mirror of
https://github.com/jellyfin/jellyfin-kodi.git
synced 2024-12-25 02:06:09 +00:00
Launch playback via default.py
I've commented out the resume dialog. If we actually need it then it can be readded.
This commit is contained in:
parent
210b0831c7
commit
8e3a22e0e8
3 changed files with 75 additions and 35 deletions
24
default.py
24
default.py
|
@ -12,24 +12,26 @@ cwd = addonSettings.getAddonInfo('path')
|
||||||
BASE_RESOURCE_PATH = xbmc.translatePath( os.path.join( cwd, 'resources', 'lib' ) )
|
BASE_RESOURCE_PATH = xbmc.translatePath( os.path.join( cwd, 'resources', 'lib' ) )
|
||||||
sys.path.append(BASE_RESOURCE_PATH)
|
sys.path.append(BASE_RESOURCE_PATH)
|
||||||
|
|
||||||
WINDOW = xbmcgui.Window( 10000 )
|
WINDOW = xbmcgui.Window(10000)
|
||||||
|
|
||||||
import Utils as utils
|
import Utils as utils
|
||||||
from PlaybackUtils import PlaybackUtils
|
from PlaybackUtils import PlaybackUtils
|
||||||
|
from DownloadUtils import DownloadUtils
|
||||||
|
|
||||||
try:
|
try:
|
||||||
params=utils.get_params(sys.argv[2])
|
params = utils.get_params(sys.argv[2])
|
||||||
mode = params.get('mode',"")
|
mode = params['mode']
|
||||||
id = params.get('id',"")
|
id = params['id']
|
||||||
except:
|
except:
|
||||||
params={}
|
params = {}
|
||||||
mode=None
|
mode = None
|
||||||
id=None
|
|
||||||
|
if mode == "play":
|
||||||
|
# Play items via plugin://plugin.video.emby/
|
||||||
|
url = "{server}/mediabrowser/Users/{UserId}/Items/%s?format=json&ImageTypeLimit=1" % id
|
||||||
|
result = DownloadUtils().downloadUrl(url)
|
||||||
|
item = PlaybackUtils().PLAY(result, setup="default")
|
||||||
|
|
||||||
if mode != None and mode == "play":
|
|
||||||
listItem = xbmcgui.ListItem(path="")
|
|
||||||
xbmcplugin.setResolvedUrl (int(sys.argv[1]), True, listItem)
|
|
||||||
WINDOW.setProperty('GUIPLAY', str(id)) # set window prop
|
|
||||||
elif sys.argv[1] == "reset":
|
elif sys.argv[1] == "reset":
|
||||||
utils.reset()
|
utils.reset()
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -99,9 +99,12 @@ class DownloadUtils():
|
||||||
header = self.getHeader()
|
header = self.getHeader()
|
||||||
|
|
||||||
# If user enabled host certificate verification
|
# If user enabled host certificate verification
|
||||||
if self.sslverify:
|
try:
|
||||||
verify = True
|
verify = self.sslverify
|
||||||
cert = self.sslclient
|
cert = self.sslclient
|
||||||
|
except:
|
||||||
|
self.logMsg("Could not load SSL settings.", 1)
|
||||||
|
pass
|
||||||
|
|
||||||
# Start session
|
# Start session
|
||||||
self.s = requests.Session()
|
self.s = requests.Session()
|
||||||
|
@ -149,22 +152,19 @@ class DownloadUtils():
|
||||||
|
|
||||||
self.logMsg("=== ENTER downloadUrl ===", 2)
|
self.logMsg("=== ENTER downloadUrl ===", 2)
|
||||||
|
|
||||||
WINDOW = xbmcgui.Window( 10000 )
|
WINDOW = self.WINDOW
|
||||||
timeout = self.timeout
|
timeout = self.timeout
|
||||||
default_link = ""
|
default_link = ""
|
||||||
|
|
||||||
username = WINDOW.getProperty('currUser')
|
|
||||||
userId = WINDOW.getProperty('userId%s' % username)
|
|
||||||
server = WINDOW.getProperty('server%s' % username)
|
|
||||||
url = url.replace("{server}", server, 1)
|
|
||||||
url = url.replace("{UserId}", userId, 1)
|
|
||||||
#url = "%s&api_key=%s" % (url, self.token)
|
|
||||||
|
|
||||||
# If user is authenticated
|
# If user is authenticated
|
||||||
if (authenticate):
|
if (authenticate):
|
||||||
# Get requests session
|
# Get requests session
|
||||||
|
try:
|
||||||
s = self.s
|
s = self.s
|
||||||
# Replace for the real values and append api_key
|
# Replace for the real values and append api_key
|
||||||
|
url = url.replace("{server}", self.server, 1)
|
||||||
|
url = url.replace("{UserId}", self.userId, 1)
|
||||||
|
#url = "%s&api_key=%s" % (url, self.token)
|
||||||
|
|
||||||
self.logMsg("URL: %s" % url, 2)
|
self.logMsg("URL: %s" % url, 2)
|
||||||
# Prepare request
|
# Prepare request
|
||||||
|
@ -175,6 +175,40 @@ class DownloadUtils():
|
||||||
elif type == "DELETE":
|
elif type == "DELETE":
|
||||||
r = s.delete(url, json=postBody, timeout=timeout)
|
r = s.delete(url, json=postBody, timeout=timeout)
|
||||||
|
|
||||||
|
except AttributeError:
|
||||||
|
|
||||||
|
# Get user information
|
||||||
|
self.username = WINDOW.getProperty('currUser')
|
||||||
|
self.userId = WINDOW.getProperty('userId%s' % self.username)
|
||||||
|
self.server = WINDOW.getProperty('server%s' % self.username)
|
||||||
|
self.token = WINDOW.getProperty('accessToken%s' % self.username)
|
||||||
|
header = self.getHeader()
|
||||||
|
verifyssl = False
|
||||||
|
cert = None
|
||||||
|
|
||||||
|
# IF user enables ssl verification
|
||||||
|
try:
|
||||||
|
if self.addon.getSetting('sslverify') == "true":
|
||||||
|
verifyssl = True
|
||||||
|
if self.addon.getSetting('sslcert') != "None":
|
||||||
|
cert = self.addon.getSetting('sslcert')
|
||||||
|
except:
|
||||||
|
self.logMsg("Could not load SSL settings.", 1)
|
||||||
|
pass
|
||||||
|
|
||||||
|
# Replace for the real values and append api_key
|
||||||
|
url = url.replace("{server}", self.server, 1)
|
||||||
|
url = url.replace("{UserId}", self.userId, 1)
|
||||||
|
|
||||||
|
self.logMsg("URL: %s" % url, 2)
|
||||||
|
# Prepare request
|
||||||
|
if type == "GET":
|
||||||
|
r = requests.get(url, json=postBody, headers=header, timeout=timeout, cert=cert, verify=verifyssl)
|
||||||
|
elif type == "POST":
|
||||||
|
r = requests.post(url, json=postBody, headers=header, timeout=timeout, cert=cert, verify=verifyssl)
|
||||||
|
elif type == "DELETE":
|
||||||
|
r = requests.delete(url, json=postBody, headers=header, timeout=timeout, cert=cert, verify=verifyssl)
|
||||||
|
|
||||||
# If user is not authenticated
|
# If user is not authenticated
|
||||||
elif not authenticate:
|
elif not authenticate:
|
||||||
|
|
||||||
|
|
|
@ -35,7 +35,7 @@ class PlaybackUtils():
|
||||||
def __init__(self, *args):
|
def __init__(self, *args):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def PLAY(self, result):
|
def PLAY(self, result, setup="service"):
|
||||||
xbmc.log("PLAY Called")
|
xbmc.log("PLAY Called")
|
||||||
WINDOW = xbmcgui.Window(10000)
|
WINDOW = xbmcgui.Window(10000)
|
||||||
|
|
||||||
|
@ -73,7 +73,7 @@ class PlaybackUtils():
|
||||||
WINDOW.setProperty(playurl+"deleteurl", "")
|
WINDOW.setProperty(playurl+"deleteurl", "")
|
||||||
WINDOW.setProperty(playurl+"deleteurl", deleteurl)
|
WINDOW.setProperty(playurl+"deleteurl", deleteurl)
|
||||||
|
|
||||||
if seekTime != 0:
|
'''if seekTime != 0:
|
||||||
displayTime = str(datetime.timedelta(seconds=seekTime))
|
displayTime = str(datetime.timedelta(seconds=seekTime))
|
||||||
display_list = [ self.language(30106) + ' ' + displayTime, self.language(30107)]
|
display_list = [ self.language(30106) + ' ' + displayTime, self.language(30107)]
|
||||||
resumeScreen = xbmcgui.Dialog()
|
resumeScreen = xbmcgui.Dialog()
|
||||||
|
@ -83,7 +83,7 @@ class PlaybackUtils():
|
||||||
else:
|
else:
|
||||||
WINDOW.clearProperty(playurl+"seektime")
|
WINDOW.clearProperty(playurl+"seektime")
|
||||||
else:
|
else:
|
||||||
WINDOW.clearProperty(playurl+"seektime")
|
WINDOW.clearProperty(playurl+"seektime")'''
|
||||||
|
|
||||||
if result.get("Type")=="Episode":
|
if result.get("Type")=="Episode":
|
||||||
WINDOW.setProperty(playurl+"refresh_id", result.get("SeriesId"))
|
WINDOW.setProperty(playurl+"refresh_id", result.get("SeriesId"))
|
||||||
|
@ -109,7 +109,11 @@ class PlaybackUtils():
|
||||||
WINDOW.setProperty(playurl+"SubtitleStreamIndex", str(mediaSources[0].get('DefaultSubtitleStreamIndex')))
|
WINDOW.setProperty(playurl+"SubtitleStreamIndex", str(mediaSources[0].get('DefaultSubtitleStreamIndex')))
|
||||||
|
|
||||||
#launch the playback
|
#launch the playback
|
||||||
|
if setup == "service":
|
||||||
xbmc.Player().play(playurl,listItem)
|
xbmc.Player().play(playurl,listItem)
|
||||||
|
elif setup == "default":
|
||||||
|
listItem = xbmcgui.ListItem(path=playurl)
|
||||||
|
xbmcplugin.setResolvedUrl(int(sys.argv[1]), True, listItem)
|
||||||
|
|
||||||
def setArt(self, list,name,path):
|
def setArt(self, list,name,path):
|
||||||
if name=='thumb' or name=='fanart_image' or name=='small_poster' or name=='tiny_poster' or name == "medium_landscape" or name=='medium_poster' or name=='small_fanartimage' or name=='medium_fanartimage' or name=='fanart_noindicators':
|
if name=='thumb' or name=='fanart_image' or name=='small_poster' or name=='tiny_poster' or name == "medium_landscape" or name=='medium_poster' or name=='small_fanartimage' or name=='medium_fanartimage' or name=='fanart_noindicators':
|
||||||
|
|
Loading…
Reference in a new issue