mirror of
https://github.com/jellyfin/jellyfin-kodi.git
synced 2024-12-27 03:06:10 +00:00
self.log
This commit is contained in:
parent
753f267fde
commit
3c9c758bdd
1 changed files with 449 additions and 457 deletions
|
@ -33,7 +33,6 @@ class PlayUtils():
|
||||||
|
|
||||||
def getPlayUrl(self):
|
def getPlayUrl(self):
|
||||||
|
|
||||||
log = self.logMsg
|
|
||||||
window = utils.window
|
window = utils.window
|
||||||
|
|
||||||
item = self.item
|
item = self.item
|
||||||
|
@ -42,19 +41,19 @@ class PlayUtils():
|
||||||
if (item.get('Type') in ("Recording", "TvChannel") and
|
if (item.get('Type') in ("Recording", "TvChannel") and
|
||||||
item.get('MediaSources') and item['MediaSources'][0]['Protocol'] == "Http"):
|
item.get('MediaSources') and item['MediaSources'][0]['Protocol'] == "Http"):
|
||||||
# Play LiveTV or recordings
|
# Play LiveTV or recordings
|
||||||
log("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, 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 item.get('MediaSources') and 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
|
||||||
log("File protocol is http.", 1)
|
self.logMsg("File protocol is http.", 1)
|
||||||
playurl = self.httpPlay()
|
playurl = self.httpPlay()
|
||||||
window('emby_%s.playmethod' % playurl, value="DirectStream")
|
window('emby_%s.playmethod' % playurl, value="DirectStream")
|
||||||
|
|
||||||
elif self.isDirectPlay():
|
elif self.isDirectPlay():
|
||||||
|
|
||||||
log("File is direct playing.", 1)
|
self.logMsg("File is direct playing.", 1)
|
||||||
playurl = self.directPlay()
|
playurl = self.directPlay()
|
||||||
playurl = playurl.encode('utf-8')
|
playurl = playurl.encode('utf-8')
|
||||||
# Set playmethod property
|
# Set playmethod property
|
||||||
|
@ -62,14 +61,14 @@ class PlayUtils():
|
||||||
|
|
||||||
elif self.isDirectStream():
|
elif self.isDirectStream():
|
||||||
|
|
||||||
log("File is direct streaming.", 1)
|
self.logMsg("File is direct streaming.", 1)
|
||||||
playurl = self.directStream()
|
playurl = self.directStream()
|
||||||
# Set playmethod property
|
# Set playmethod property
|
||||||
window('emby_%s.playmethod' % playurl, value="DirectStream")
|
window('emby_%s.playmethod' % playurl, value="DirectStream")
|
||||||
|
|
||||||
elif self.isTranscoding():
|
elif self.isTranscoding():
|
||||||
|
|
||||||
log("File is transcoding.", 1)
|
self.logMsg("File is transcoding.", 1)
|
||||||
playurl = self.transcoding()
|
playurl = self.transcoding()
|
||||||
# Set playmethod property
|
# Set playmethod property
|
||||||
window('emby_%s.playmethod' % playurl, value="Transcode")
|
window('emby_%s.playmethod' % playurl, value="Transcode")
|
||||||
|
@ -93,7 +92,6 @@ class PlayUtils():
|
||||||
|
|
||||||
def isDirectPlay(self):
|
def isDirectPlay(self):
|
||||||
|
|
||||||
log = self.logMsg
|
|
||||||
lang = utils.language
|
lang = utils.language
|
||||||
settings = utils.settings
|
settings = utils.settings
|
||||||
dialog = xbmcgui.Dialog()
|
dialog = xbmcgui.Dialog()
|
||||||
|
@ -103,7 +101,7 @@ class PlayUtils():
|
||||||
# Requirement: Filesystem, Accessible path
|
# Requirement: Filesystem, Accessible path
|
||||||
if settings('playFromStream') == "true":
|
if settings('playFromStream') == "true":
|
||||||
# User forcing to play via HTTP
|
# User forcing to play via HTTP
|
||||||
log("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 = item['MediaSources'][0]['Name']
|
||||||
|
@ -118,7 +116,7 @@ class PlayUtils():
|
||||||
'2': 720,
|
'2': 720,
|
||||||
'3': 1080
|
'3': 1080
|
||||||
}
|
}
|
||||||
log("Resolution is: %sP, transcode for resolution: %sP+"
|
self.logMsg("Resolution is: %sP, transcode for resolution: %sP+"
|
||||||
% (resolution, res[transcodeH265]), 1)
|
% (resolution, res[transcodeH265]), 1)
|
||||||
if res[transcodeH265] <= resolution:
|
if res[transcodeH265] <= resolution:
|
||||||
return False
|
return False
|
||||||
|
@ -126,19 +124,19 @@ class PlayUtils():
|
||||||
canDirectPlay = item['MediaSources'][0]['SupportsDirectPlay']
|
canDirectPlay = 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:
|
||||||
log("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 = item['LocationType']
|
||||||
if location == "FileSystem":
|
if location == "FileSystem":
|
||||||
# Verify the path
|
# Verify the path
|
||||||
if not self.fileExists():
|
if not self.fileExists():
|
||||||
log("Unable to direct play.")
|
self.logMsg("Unable to direct play.")
|
||||||
try:
|
try:
|
||||||
count = int(settings('failCount'))
|
count = int(settings('failCount'))
|
||||||
except ValueError:
|
except ValueError:
|
||||||
count = 0
|
count = 0
|
||||||
log("Direct play failed: %s times." % count, 1)
|
self.logMsg("Direct play failed: %s times." % count, 1)
|
||||||
|
|
||||||
if count < 2:
|
if count < 2:
|
||||||
# Let the user know that direct play failed
|
# Let the user know that direct play failed
|
||||||
|
@ -192,32 +190,28 @@ class PlayUtils():
|
||||||
|
|
||||||
def fileExists(self):
|
def fileExists(self):
|
||||||
|
|
||||||
log = self.logMsg
|
|
||||||
|
|
||||||
if 'Path' not in self.item:
|
if 'Path' not in self.item:
|
||||||
# File has no path defined in server
|
# File has no path defined in server
|
||||||
return False
|
return False
|
||||||
|
|
||||||
# Convert path to direct play
|
# Convert path to direct play
|
||||||
path = self.directPlay()
|
path = self.directPlay()
|
||||||
log("Verifying path: %s" % path, 1)
|
self.logMsg("Verifying path: %s" % path, 1)
|
||||||
|
|
||||||
if xbmcvfs.exists(path):
|
if xbmcvfs.exists(path):
|
||||||
log("Path exists.", 1)
|
self.logMsg("Path exists.", 1)
|
||||||
return True
|
return True
|
||||||
|
|
||||||
elif ":" not in path:
|
elif ":" not in path:
|
||||||
log("Can't verify path, assumed linux. Still try to direct play.", 1)
|
self.logMsg("Can't verify path, assumed linux. Still try to direct play.", 1)
|
||||||
return True
|
return True
|
||||||
|
|
||||||
else:
|
else:
|
||||||
log("Failed to find file.", 1)
|
self.logMsg("Failed to find file.", 1)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def isDirectStream(self):
|
def isDirectStream(self):
|
||||||
|
|
||||||
log = self.logMsg
|
|
||||||
|
|
||||||
item = self.item
|
item = self.item
|
||||||
|
|
||||||
videotrack = item['MediaSources'][0]['Name']
|
videotrack = item['MediaSources'][0]['Name']
|
||||||
|
@ -232,7 +226,7 @@ class PlayUtils():
|
||||||
'2': 720,
|
'2': 720,
|
||||||
'3': 1080
|
'3': 1080
|
||||||
}
|
}
|
||||||
log("Resolution is: %sP, transcode for resolution: %sP+"
|
self.logMsg("Resolution is: %sP, transcode for resolution: %sP+"
|
||||||
% (resolution, res[transcodeH265]), 1)
|
% (resolution, res[transcodeH265]), 1)
|
||||||
if res[transcodeH265] <= resolution:
|
if res[transcodeH265] <= resolution:
|
||||||
return False
|
return False
|
||||||
|
@ -245,7 +239,7 @@ class PlayUtils():
|
||||||
|
|
||||||
# Verify the bitrate
|
# Verify the bitrate
|
||||||
if not self.isNetworkSufficient():
|
if not self.isNetworkSufficient():
|
||||||
log("The network speed is insufficient to direct stream file.", 1)
|
self.logMsg("The network speed is insufficient to direct stream file.", 1)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
@ -270,16 +264,15 @@ class PlayUtils():
|
||||||
|
|
||||||
def isNetworkSufficient(self):
|
def isNetworkSufficient(self):
|
||||||
|
|
||||||
log = self.logMsg
|
|
||||||
|
|
||||||
settings = self.getBitrate()*1000
|
settings = self.getBitrate()*1000
|
||||||
|
|
||||||
try:
|
try:
|
||||||
sourceBitrate = int(self.item['MediaSources'][0]['Bitrate'])
|
sourceBitrate = int(self.item['MediaSources'][0]['Bitrate'])
|
||||||
except (KeyError, TypeError):
|
except (KeyError, TypeError):
|
||||||
log("Bitrate value is missing.", 1)
|
self.logMsg("Bitrate value is missing.", 1)
|
||||||
else:
|
else:
|
||||||
log("The add-on settings bitrate is: %s, the video bitrate required is: %s"
|
self.logMsg("The add-on settings bitrate is: %s, the video bitrate required is: %s"
|
||||||
% (settings, sourceBitrate), 1)
|
% (settings, sourceBitrate), 1)
|
||||||
if settings < sourceBitrate:
|
if settings < sourceBitrate:
|
||||||
return False
|
return False
|
||||||
|
@ -349,7 +342,6 @@ class PlayUtils():
|
||||||
|
|
||||||
def audioSubsPref(self, url, listitem):
|
def audioSubsPref(self, url, listitem):
|
||||||
|
|
||||||
log = self.logMsg
|
|
||||||
lang = utils.language
|
lang = utils.language
|
||||||
dialog = xbmcgui.Dialog()
|
dialog = xbmcgui.Dialog()
|
||||||
# For transcoding only
|
# For transcoding only
|
||||||
|
@ -439,7 +431,7 @@ class PlayUtils():
|
||||||
itemid = item['Id']
|
itemid = 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))]
|
||||||
log("Set up subtitles: %s %s" % (selectSubsIndex, url), 1)
|
self.logMsg("Set up subtitles: %s %s" % (selectSubsIndex, url), 1)
|
||||||
listitem.setSubtitles(url)
|
listitem.setSubtitles(url)
|
||||||
else:
|
else:
|
||||||
# Burn subtitles
|
# Burn subtitles
|
||||||
|
|
Loading…
Reference in a new issue