mirror of
https://github.com/jellyfin/jellyfin-kodi.git
synced 2024-11-10 04:06:11 +00:00
Default to play from HTTP
Add download external subs option. With testing, we can determine if we even need a second option or if it should be downloading by default as a workaround to not being able to label external tracks when using url in Kodi.
This commit is contained in:
parent
00c0556300
commit
a331f7d43d
3 changed files with 51 additions and 2 deletions
|
@ -4,11 +4,15 @@
|
|||
|
||||
import json
|
||||
import logging
|
||||
import requests
|
||||
import os
|
||||
import shutil
|
||||
import sys
|
||||
|
||||
import xbmc
|
||||
import xbmcgui
|
||||
import xbmcplugin
|
||||
import xbmcvfs
|
||||
|
||||
import api
|
||||
import artwork
|
||||
|
@ -246,6 +250,9 @@ class PlaybackUtils():
|
|||
except (TypeError, KeyError, IndexError):
|
||||
return
|
||||
|
||||
temp = xbmc.translatePath(
|
||||
"special://profile/addon_data/plugin.video.emby/temp/").decode('utf-8')
|
||||
|
||||
kodiindex = 0
|
||||
for stream in mediastreams:
|
||||
|
||||
|
@ -258,10 +265,21 @@ class PlaybackUtils():
|
|||
# Direct stream
|
||||
url = ("%s/Videos/%s/%s/Subtitles/%s/Stream.srt"
|
||||
% (self.server, itemid, itemid, index))
|
||||
|
||||
if settings('downloadExternalSubs') == "true":
|
||||
|
||||
filename = "Stream.%s.srt" % stream['Language']
|
||||
try:
|
||||
path = self._download_external_subs(url, temp, filename)
|
||||
externalsubs.append(path)
|
||||
except Exception as e:
|
||||
log.error(e)
|
||||
continue
|
||||
else:
|
||||
externalsubs.append(url)
|
||||
|
||||
# map external subtitles for mapping
|
||||
mapping[kodiindex] = index
|
||||
externalsubs.append(url)
|
||||
kodiindex += 1
|
||||
|
||||
mapping = json.dumps(mapping)
|
||||
|
@ -269,6 +287,27 @@ class PlaybackUtils():
|
|||
|
||||
return externalsubs
|
||||
|
||||
def _download_external_subs(self, src, dst, filename):
|
||||
|
||||
if not xbmcvfs.exists(dst):
|
||||
xbmcvfs.mkdir(dst)
|
||||
|
||||
path = os.path.join(dst, filename)
|
||||
|
||||
try:
|
||||
response = requests.get(src, stream=True)
|
||||
response.raise_for_status()
|
||||
except Exception as e:
|
||||
del response
|
||||
raise
|
||||
else:
|
||||
f = open(path, 'wb')
|
||||
f.write(response.content)
|
||||
f.close()
|
||||
del response
|
||||
|
||||
return path
|
||||
|
||||
def setArtwork(self, listItem):
|
||||
# Set up item and item info
|
||||
allartwork = self.artwork.getAllArtwork(self.item, parentInfo=True)
|
||||
|
|
|
@ -6,6 +6,7 @@ import json
|
|||
import logging
|
||||
|
||||
import xbmc
|
||||
import xbmcvfs
|
||||
import xbmcgui
|
||||
|
||||
import clientinfo
|
||||
|
@ -473,6 +474,7 @@ class Player(xbmc.Player):
|
|||
else:
|
||||
log.info("User skipped deletion.")
|
||||
|
||||
|
||||
self.stopPlayback(data)
|
||||
|
||||
# Stop transcoding
|
||||
|
@ -481,6 +483,13 @@ class Player(xbmc.Player):
|
|||
deviceId = self.clientInfo.getDeviceId()
|
||||
url = "{server}/emby/Videos/ActiveEncodings?DeviceId=%s" % deviceId
|
||||
self.doUtils(url, action_type="DELETE")
|
||||
|
||||
path = xbmc.translatePath(
|
||||
"special://profile/addon_data/plugin.video.emby/temp/").decode('utf-8')
|
||||
|
||||
dirs, files = xbmcvfs.listdir(path)
|
||||
for file in files:
|
||||
xbmcvfs.delete("%s%s" % (path, file))
|
||||
|
||||
self.played_info.clear()
|
||||
|
||||
|
|
|
@ -52,9 +52,10 @@
|
|||
<setting id="deleteMovies" type="bool" label="30116" visible="eq(-2,true)" default="false" subsetting="true" />
|
||||
<setting id="resumeJumpBack" type="slider" label="30521" default="10" range="0,1,120" option="int" />
|
||||
<setting type="sep" />
|
||||
<setting id="playFromStream" type="bool" label="30002" default="false" />
|
||||
<setting id="playFromStream" type="bool" label="30002" default="true" />
|
||||
<setting id="videoBitrate" type="enum" label="30160" values="664 Kbps SD|996 Kbps HD|1.3 Mbps HD|2.0 Mbps HD|3.2 Mbps HD|4.7 Mbps HD|6.2 Mbps HD|7.7 Mbps HD|9.2 Mbps HD|10.7 Mbps HD|12.2 Mbps HD|13.7 Mbps HD|15.2 Mbps HD|16.7 Mbps HD|18.2 Mbps HD|20.0 Mbps HD|40.0 Mbps HD|100.0 Mbps HD [default]|1000.0 Mbps HD" visible="true" default="17" subsetting="true" />
|
||||
<setting id="enableExternalSubs" type="bool" label="Enable external subs for direct stream" default="true" />
|
||||
<setting id="downloadExternalSubs" type="bool" label="Download external subs" visible="eq(-1,true)" default="true" subsetting="true" />
|
||||
<setting id="transcodeH265" type="enum" label="30522" default="0" values="Disabled|480p(and higher)|720p(and higher)|1080p" />
|
||||
<setting id="transcodeHi10P" type="bool" label="30537" default="false"/>
|
||||
<setting id="markPlayed" type="number" visible="false" default="90" />
|
||||
|
|
Loading…
Reference in a new issue