Support playback of .strm files
This commit is contained in:
parent
345a24f896
commit
f1c784d458
1 changed files with 9 additions and 9 deletions
|
@ -1,7 +1,6 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
###############################################################################
|
###############################################################################
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
from downloadutils import DownloadUtils
|
from downloadutils import DownloadUtils
|
||||||
|
|
||||||
|
@ -19,11 +18,9 @@ log = logging.getLogger("PLEX."+__name__)
|
||||||
class PlayUtils():
|
class PlayUtils():
|
||||||
|
|
||||||
def __init__(self, item):
|
def __init__(self, item):
|
||||||
|
|
||||||
self.item = item
|
self.item = item
|
||||||
self.API = PlexAPI.API(item)
|
self.API = PlexAPI.API(item)
|
||||||
self.doUtils = DownloadUtils().downloadUrl
|
self.doUtils = DownloadUtils().downloadUrl
|
||||||
|
|
||||||
self.machineIdentifier = window('plex_machineIdentifier')
|
self.machineIdentifier = window('plex_machineIdentifier')
|
||||||
|
|
||||||
def getPlayUrl(self, partNumber=None):
|
def getPlayUrl(self, partNumber=None):
|
||||||
|
@ -74,6 +71,14 @@ class PlayUtils():
|
||||||
if self.API.shouldStream() is True:
|
if self.API.shouldStream() is True:
|
||||||
log.info("Plex item optimized for direct streaming")
|
log.info("Plex item optimized for direct streaming")
|
||||||
return
|
return
|
||||||
|
# Check whether we have a strm file that we need to throw at Kodi 1:1
|
||||||
|
path = self.API.getFilePath()
|
||||||
|
if path is not None and path.endswith('.strm'):
|
||||||
|
log.info('.strm file detected')
|
||||||
|
playurl = self.API.validatePlayurl(path,
|
||||||
|
self.API.getType(),
|
||||||
|
forceCheck=True)
|
||||||
|
return tryEncode(playurl)
|
||||||
# set to either 'Direct Stream=1' or 'Transcode=2'
|
# set to either 'Direct Stream=1' or 'Transcode=2'
|
||||||
# and NOT to 'Direct Play=0'
|
# and NOT to 'Direct Play=0'
|
||||||
if settings('playType') != "0":
|
if settings('playType') != "0":
|
||||||
|
@ -82,33 +87,28 @@ class PlayUtils():
|
||||||
return
|
return
|
||||||
if self.mustTranscode():
|
if self.mustTranscode():
|
||||||
return
|
return
|
||||||
return self.API.validatePlayurl(self.API.getFilePath(),
|
return self.API.validatePlayurl(path,
|
||||||
self.API.getType(),
|
self.API.getType(),
|
||||||
forceCheck=True)
|
forceCheck=True)
|
||||||
|
|
||||||
def directPlay(self):
|
def directPlay(self):
|
||||||
|
|
||||||
try:
|
try:
|
||||||
playurl = self.item['MediaSources'][0]['Path']
|
playurl = self.item['MediaSources'][0]['Path']
|
||||||
except (IndexError, KeyError):
|
except (IndexError, KeyError):
|
||||||
playurl = self.item['Path']
|
playurl = self.item['Path']
|
||||||
|
|
||||||
if self.item.get('VideoType'):
|
if self.item.get('VideoType'):
|
||||||
# Specific format modification
|
# Specific format modification
|
||||||
if self.item['VideoType'] == "Dvd":
|
if self.item['VideoType'] == "Dvd":
|
||||||
playurl = "%s/VIDEO_TS/VIDEO_TS.IFO" % playurl
|
playurl = "%s/VIDEO_TS/VIDEO_TS.IFO" % playurl
|
||||||
elif self.item['VideoType'] == "BluRay":
|
elif self.item['VideoType'] == "BluRay":
|
||||||
playurl = "%s/BDMV/index.bdmv" % playurl
|
playurl = "%s/BDMV/index.bdmv" % playurl
|
||||||
|
|
||||||
# Assign network protocol
|
# Assign network protocol
|
||||||
if playurl.startswith('\\\\'):
|
if playurl.startswith('\\\\'):
|
||||||
playurl = playurl.replace("\\\\", "smb://")
|
playurl = playurl.replace("\\\\", "smb://")
|
||||||
playurl = playurl.replace("\\", "/")
|
playurl = playurl.replace("\\", "/")
|
||||||
|
|
||||||
if "apple.com" in playurl:
|
if "apple.com" in playurl:
|
||||||
USER_AGENT = "QuickTime/7.7.4"
|
USER_AGENT = "QuickTime/7.7.4"
|
||||||
playurl += "?|User-Agent=%s" % USER_AGENT
|
playurl += "?|User-Agent=%s" % USER_AGENT
|
||||||
|
|
||||||
return playurl
|
return playurl
|
||||||
|
|
||||||
def mustTranscode(self):
|
def mustTranscode(self):
|
||||||
|
|
Loading…
Reference in a new issue