mirror of
https://github.com/jellyfin/jellyfin-kodi.git
synced 2024-12-26 02:36:10 +00:00
self.item
This commit is contained in:
parent
3c9c758bdd
commit
047189b31b
1 changed files with 23 additions and 35 deletions
|
@ -35,17 +35,16 @@ class PlayUtils():
|
||||||
|
|
||||||
window = utils.window
|
window = utils.window
|
||||||
|
|
||||||
item = self.item
|
|
||||||
playurl = None
|
playurl = None
|
||||||
|
|
||||||
if (item.get('Type') in ("Recording", "TvChannel") and
|
if (self.item.get('Type') in ("Recording", "TvChannel") and
|
||||||
item.get('MediaSources') and item['MediaSources'][0]['Protocol'] == "Http"):
|
self.item.get('MediaSources') and self.item['MediaSources'][0]['Protocol'] == "Http"):
|
||||||
# Play LiveTV or recordings
|
# Play LiveTV or recordings
|
||||||
self.logMsg("File protocol is http (livetv).", 1)
|
self.logMsg("File protocol is http (livetv).", 1)
|
||||||
playurl = "%s/emby/Videos/%s/live.m3u8?static=true" % (self.server, item['Id'])
|
playurl = "%s/emby/Videos/%s/live.m3u8?static=true" % (self.server, self.item['Id'])
|
||||||
window('emby_%s.playmethod' % playurl, value="Transcode")
|
window('emby_%s.playmethod' % playurl, value="Transcode")
|
||||||
|
|
||||||
elif item.get('MediaSources') and item['MediaSources'][0]['Protocol'] == "Http":
|
elif self.item.get('MediaSources') and self.item['MediaSources'][0]['Protocol'] == "Http":
|
||||||
# Only play as http, used for channels, or online hosting of content
|
# Only play as http, used for channels, or online hosting of content
|
||||||
self.logMsg("File protocol is http.", 1)
|
self.logMsg("File protocol is http.", 1)
|
||||||
playurl = self.httpPlay()
|
playurl = self.httpPlay()
|
||||||
|
@ -77,11 +76,10 @@ class PlayUtils():
|
||||||
|
|
||||||
def httpPlay(self):
|
def httpPlay(self):
|
||||||
# Audio, Video, Photo
|
# Audio, Video, Photo
|
||||||
item = self.item
|
|
||||||
server = self.server
|
server = self.server
|
||||||
|
|
||||||
itemid = item['Id']
|
itemid = self.item['Id']
|
||||||
mediatype = item['MediaType']
|
mediatype = self.item['MediaType']
|
||||||
|
|
||||||
if mediatype == "Audio":
|
if mediatype == "Audio":
|
||||||
playurl = "%s/emby/Audio/%s/stream" % (server, itemid)
|
playurl = "%s/emby/Audio/%s/stream" % (server, itemid)
|
||||||
|
@ -96,7 +94,6 @@ class PlayUtils():
|
||||||
settings = utils.settings
|
settings = utils.settings
|
||||||
dialog = xbmcgui.Dialog()
|
dialog = xbmcgui.Dialog()
|
||||||
|
|
||||||
item = self.item
|
|
||||||
|
|
||||||
# Requirement: Filesystem, Accessible path
|
# Requirement: Filesystem, Accessible path
|
||||||
if settings('playFromStream') == "true":
|
if settings('playFromStream') == "true":
|
||||||
|
@ -104,7 +101,7 @@ class PlayUtils():
|
||||||
self.logMsg("Can't direct play, play from HTTP enabled.", 1)
|
self.logMsg("Can't direct play, play from HTTP enabled.", 1)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
videotrack = item['MediaSources'][0]['Name']
|
videotrack = self.item['MediaSources'][0]['Name']
|
||||||
transcodeH265 = settings('transcodeH265')
|
transcodeH265 = settings('transcodeH265')
|
||||||
|
|
||||||
if transcodeH265 in ("1", "2", "3") and ("HEVC" in videotrack or "H265" in videotrack):
|
if transcodeH265 in ("1", "2", "3") and ("HEVC" in videotrack or "H265" in videotrack):
|
||||||
|
@ -121,13 +118,13 @@ class PlayUtils():
|
||||||
if res[transcodeH265] <= resolution:
|
if res[transcodeH265] <= resolution:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
canDirectPlay = item['MediaSources'][0]['SupportsDirectPlay']
|
canDirectPlay = self.item['MediaSources'][0]['SupportsDirectPlay']
|
||||||
# Make sure direct play is supported by the server
|
# Make sure direct play is supported by the server
|
||||||
if not canDirectPlay:
|
if not canDirectPlay:
|
||||||
self.logMsg("Can't direct play, server doesn't allow/support it.", 1)
|
self.logMsg("Can't direct play, server doesn't allow/support it.", 1)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
location = item['LocationType']
|
location = self.item['LocationType']
|
||||||
if location == "FileSystem":
|
if location == "FileSystem":
|
||||||
# Verify the path
|
# Verify the path
|
||||||
if not self.fileExists():
|
if not self.fileExists():
|
||||||
|
@ -161,16 +158,14 @@ class PlayUtils():
|
||||||
|
|
||||||
def directPlay(self):
|
def directPlay(self):
|
||||||
|
|
||||||
item = self.item
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
playurl = item['MediaSources'][0]['Path']
|
playurl = self.item['MediaSources'][0]['Path']
|
||||||
except (IndexError, KeyError):
|
except (IndexError, KeyError):
|
||||||
playurl = item['Path']
|
playurl = self.item['Path']
|
||||||
|
|
||||||
if item.get('VideoType'):
|
if self.item.get('VideoType'):
|
||||||
# Specific format modification
|
# Specific format modification
|
||||||
type = item['VideoType']
|
type = self.item['VideoType']
|
||||||
|
|
||||||
if type == "Dvd":
|
if type == "Dvd":
|
||||||
playurl = "%s/VIDEO_TS/VIDEO_TS.IFO" % playurl
|
playurl = "%s/VIDEO_TS/VIDEO_TS.IFO" % playurl
|
||||||
|
@ -212,9 +207,8 @@ class PlayUtils():
|
||||||
|
|
||||||
def isDirectStream(self):
|
def isDirectStream(self):
|
||||||
|
|
||||||
item = self.item
|
|
||||||
|
|
||||||
videotrack = item['MediaSources'][0]['Name']
|
videotrack = self.item['MediaSources'][0]['Name']
|
||||||
transcodeH265 = utils.settings('transcodeH265')
|
transcodeH265 = utils.settings('transcodeH265')
|
||||||
|
|
||||||
if transcodeH265 in ("1", "2", "3") and ("HEVC" in videotrack or "H265" in videotrack):
|
if transcodeH265 in ("1", "2", "3") and ("HEVC" in videotrack or "H265" in videotrack):
|
||||||
|
@ -232,7 +226,7 @@ class PlayUtils():
|
||||||
return False
|
return False
|
||||||
|
|
||||||
# Requirement: BitRate, supported encoding
|
# Requirement: BitRate, supported encoding
|
||||||
canDirectStream = item['MediaSources'][0]['SupportsDirectStream']
|
canDirectStream = self.item['MediaSources'][0]['SupportsDirectStream']
|
||||||
# Make sure the server supports it
|
# Make sure the server supports it
|
||||||
if not canDirectStream:
|
if not canDirectStream:
|
||||||
return False
|
return False
|
||||||
|
@ -246,13 +240,12 @@ class PlayUtils():
|
||||||
|
|
||||||
def directStream(self):
|
def directStream(self):
|
||||||
|
|
||||||
item = self.item
|
|
||||||
server = self.server
|
server = self.server
|
||||||
|
|
||||||
itemid = item['Id']
|
itemid = self.item['Id']
|
||||||
itemtype = item['Type']
|
itemtype = self.item['Type']
|
||||||
|
|
||||||
if 'Path' in item and item['Path'].endswith('.strm'):
|
if 'Path' in self.item and self.item['Path'].endswith('.strm'):
|
||||||
# Allow strm loading when direct streaming
|
# Allow strm loading when direct streaming
|
||||||
playurl = self.directPlay()
|
playurl = self.directPlay()
|
||||||
elif itemtype == "Audio":
|
elif itemtype == "Audio":
|
||||||
|
@ -281,9 +274,7 @@ class PlayUtils():
|
||||||
|
|
||||||
def isTranscoding(self):
|
def isTranscoding(self):
|
||||||
|
|
||||||
item = self.item
|
canTranscode = self.item['MediaSources'][0]['SupportsTranscoding']
|
||||||
|
|
||||||
canTranscode = item['MediaSources'][0]['SupportsTranscoding']
|
|
||||||
# Make sure the server supports it
|
# Make sure the server supports it
|
||||||
if not canTranscode:
|
if not canTranscode:
|
||||||
return False
|
return False
|
||||||
|
@ -292,13 +283,11 @@ class PlayUtils():
|
||||||
|
|
||||||
def transcoding(self):
|
def transcoding(self):
|
||||||
|
|
||||||
item = self.item
|
if 'Path' in self.item and self.item['Path'].endswith('.strm'):
|
||||||
|
|
||||||
if 'Path' in item and item['Path'].endswith('.strm'):
|
|
||||||
# Allow strm loading when transcoding
|
# Allow strm loading when transcoding
|
||||||
playurl = self.directPlay()
|
playurl = self.directPlay()
|
||||||
else:
|
else:
|
||||||
itemid = item['Id']
|
itemid = self.item['Id']
|
||||||
deviceId = self.clientInfo.getDeviceId()
|
deviceId = self.clientInfo.getDeviceId()
|
||||||
playurl = (
|
playurl = (
|
||||||
"%s/emby/Videos/%s/master.m3u8?MediaSourceId=%s"
|
"%s/emby/Videos/%s/master.m3u8?MediaSourceId=%s"
|
||||||
|
@ -356,9 +345,8 @@ class PlayUtils():
|
||||||
selectSubsIndex = ""
|
selectSubsIndex = ""
|
||||||
playurlprefs = "%s" % url
|
playurlprefs = "%s" % url
|
||||||
|
|
||||||
item = self.item
|
|
||||||
try:
|
try:
|
||||||
mediasources = item['MediaSources'][0]
|
mediasources = self.item['MediaSources'][0]
|
||||||
mediastreams = mediasources['MediaStreams']
|
mediastreams = mediasources['MediaStreams']
|
||||||
except (TypeError, KeyError, IndexError):
|
except (TypeError, KeyError, IndexError):
|
||||||
return
|
return
|
||||||
|
@ -428,7 +416,7 @@ class PlayUtils():
|
||||||
# Load subtitles in the listitem if downloadable
|
# Load subtitles in the listitem if downloadable
|
||||||
if selectSubsIndex in downloadableStreams:
|
if selectSubsIndex in downloadableStreams:
|
||||||
|
|
||||||
itemid = item['Id']
|
itemid = self.item['Id']
|
||||||
url = [("%s/Videos/%s/%s/Subtitles/%s/Stream.srt"
|
url = [("%s/Videos/%s/%s/Subtitles/%s/Stream.srt"
|
||||||
% (self.server, itemid, itemid, selectSubsIndex))]
|
% (self.server, itemid, itemid, selectSubsIndex))]
|
||||||
self.logMsg("Set up subtitles: %s %s" % (selectSubsIndex, url), 1)
|
self.logMsg("Set up subtitles: %s %s" % (selectSubsIndex, url), 1)
|
||||||
|
|
Loading…
Reference in a new issue