mirror of
https://github.com/jellyfin/jellyfin-kodi.git
synced 2024-11-30 08:40:48 +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
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' ) )
|
||||
sys.path.append(BASE_RESOURCE_PATH)
|
||||
|
||||
WINDOW = xbmcgui.Window( 10000 )
|
||||
WINDOW = xbmcgui.Window(10000)
|
||||
|
||||
import Utils as utils
|
||||
from PlaybackUtils import PlaybackUtils
|
||||
from DownloadUtils import DownloadUtils
|
||||
|
||||
try:
|
||||
params=utils.get_params(sys.argv[2])
|
||||
mode = params.get('mode',"")
|
||||
id = params.get('id',"")
|
||||
params = utils.get_params(sys.argv[2])
|
||||
mode = params['mode']
|
||||
id = params['id']
|
||||
except:
|
||||
params={}
|
||||
mode=None
|
||||
id=None
|
||||
params = {}
|
||||
mode = 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":
|
||||
utils.reset()
|
||||
else:
|
||||
|
@ -99,9 +99,12 @@ class DownloadUtils():
|
||||
header = self.getHeader()
|
||||
|
||||
# If user enabled host certificate verification
|
||||
if self.sslverify:
|
||||
verify = True
|
||||
try:
|
||||
verify = self.sslverify
|
||||
cert = self.sslclient
|
||||
except:
|
||||
self.logMsg("Could not load SSL settings.", 1)
|
||||
pass
|
||||
|
||||
# Start session
|
||||
self.s = requests.Session()
|
||||
@ -149,31 +152,62 @@ class DownloadUtils():
|
||||
|
||||
self.logMsg("=== ENTER downloadUrl ===", 2)
|
||||
|
||||
WINDOW = xbmcgui.Window( 10000 )
|
||||
WINDOW = self.WINDOW
|
||||
timeout = self.timeout
|
||||
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 (authenticate):
|
||||
# Get requests session
|
||||
s = self.s
|
||||
# Replace for the real values and append api_key
|
||||
try:
|
||||
s = self.s
|
||||
# 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)
|
||||
# Prepare request
|
||||
if type == "GET":
|
||||
r = s.get(url, json=postBody, timeout=timeout)
|
||||
elif type == "POST":
|
||||
r = s.post(url, json=postBody, timeout=timeout)
|
||||
elif type == "DELETE":
|
||||
r = s.delete(url, json=postBody, timeout=timeout)
|
||||
self.logMsg("URL: %s" % url, 2)
|
||||
# Prepare request
|
||||
if type == "GET":
|
||||
r = s.get(url, json=postBody, timeout=timeout)
|
||||
elif type == "POST":
|
||||
r = s.post(url, json=postBody, timeout=timeout)
|
||||
elif type == "DELETE":
|
||||
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
|
||||
elif not authenticate:
|
||||
|
@ -35,7 +35,7 @@ class PlaybackUtils():
|
||||
def __init__(self, *args):
|
||||
pass
|
||||
|
||||
def PLAY(self, result):
|
||||
def PLAY(self, result, setup="service"):
|
||||
xbmc.log("PLAY Called")
|
||||
WINDOW = xbmcgui.Window(10000)
|
||||
|
||||
@ -73,7 +73,7 @@ class PlaybackUtils():
|
||||
WINDOW.setProperty(playurl+"deleteurl", "")
|
||||
WINDOW.setProperty(playurl+"deleteurl", deleteurl)
|
||||
|
||||
if seekTime != 0:
|
||||
'''if seekTime != 0:
|
||||
displayTime = str(datetime.timedelta(seconds=seekTime))
|
||||
display_list = [ self.language(30106) + ' ' + displayTime, self.language(30107)]
|
||||
resumeScreen = xbmcgui.Dialog()
|
||||
@ -83,7 +83,7 @@ class PlaybackUtils():
|
||||
else:
|
||||
WINDOW.clearProperty(playurl+"seektime")
|
||||
else:
|
||||
WINDOW.clearProperty(playurl+"seektime")
|
||||
WINDOW.clearProperty(playurl+"seektime")'''
|
||||
|
||||
if result.get("Type")=="Episode":
|
||||
WINDOW.setProperty(playurl+"refresh_id", result.get("SeriesId"))
|
||||
@ -109,7 +109,11 @@ class PlaybackUtils():
|
||||
WINDOW.setProperty(playurl+"SubtitleStreamIndex", str(mediaSources[0].get('DefaultSubtitleStreamIndex')))
|
||||
|
||||
#launch the playback
|
||||
xbmc.Player().play(playurl,listItem)
|
||||
if setup == "service":
|
||||
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):
|
||||
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 New Issue
Block a user