- Add Force Transcode to context menu

- Add max width to transcode
- Add force 8 bit to transcode
- Add playback type to begining of overview text
This commit is contained in:
Shaun
2017-06-10 13:01:04 +10:00
parent 2b646ddc46
commit 9ade9c6047
8 changed files with 96 additions and 44 deletions

View File

@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<addon id="plugin.video.embycon"
name="EmbyCon"
version="1.2.5"
version="1.2.6"
provider-name="null_pointer">
<requires>
<import addon="xbmc.python" version="2.1.0"/>

View File

@@ -259,7 +259,7 @@ msgid "Playback"
msgstr ""
msgctxt "#30208"
msgid "Playback Bitrate (Kbits)"
msgid "Transcode Bitrate (Kbits)"
msgstr ""
msgctxt "#30209"
@@ -274,6 +274,14 @@ msgctxt "#30211"
msgid "HTTP Transcode"
msgstr ""
msgctxt "#30212"
msgid "Transcode Max Width"
msgstr ""
msgctxt "#30213"
msgid "Transcode Force 8 Bit"
msgstr ""
msgctxt "#30230"
msgid "Default View"
msgstr ""
@@ -422,6 +430,10 @@ msgctxt "#30274"
msgid "Emby: Delete"
msgstr ""
msgctxt "#30275"
msgid "Emby: Force Transcode"
msgstr ""
msgctxt "#30280"
msgid "Missing Title"
msgstr ""

View File

@@ -453,6 +453,9 @@ def addContextMenu(details, extraData, folder):
if item_id != None:
scriptToRun = PLUGINPATH + "/default.py"
argsToPass = "?mode=PLAY&item_id=" + extraData.get("id") + "&force_transcode=true"
commands.append((i18n('emby_force_transcode'), "RunPlugin(plugin://plugin.video.embycon" + argsToPass + ")"))
# watched/unwatched
if extraData.get("playcount") == "0":
argsToPass = 'markWatched,' + extraData.get('id')
@@ -1112,16 +1115,25 @@ def checkService():
def PLAY(params, handle):
log.info("== ENTER: PLAY ==")
log.info("PLAY ACTION PARAMS : " + str(params))
log.info("PLAY ACTION PARAMS: " + str(params))
item_id = params.get("item_id")
auto_resume = int(params.get("auto_resume", "-1"))
log.info("AUTO_RESUME: " + str(auto_resume))
forceTranscode = params.get("force_transcode", None) is not None
log.info("FORCE_TRANSCODE: " + str(forceTranscode))
# set the current playing item id
# set all the playback info, this will be picked up by the service
# the service will then start the playback
play_info = {}
play_info["item_id"] = item_id
play_info["auto_resume"] = str(auto_resume)
play_info["force_transcode"] = forceTranscode
play_data = json.dumps(play_info)
home_window = HomeWindow()
home_window.setProperty("item_id", item_id)
home_window.setProperty("play_item_id", item_id)
home_window.setProperty("play_item_resume", str(auto_resume))
home_window.setProperty("play_item_message", play_data)

View File

@@ -19,8 +19,13 @@ log = SimpleLogging(__name__)
downloadUtils = DownloadUtils()
def playFile(id, auto_resume):
log.info("playFile id(" + str(id) + ") resume(" + str(auto_resume) + ")")
def playFile(play_info):
id = play_info.get("item_id")
auto_resume = play_info.get("auto_resume")
force_transcode = play_info.get("force_transcode")
log.info("playFile id(%s) resume(%s) force_transcode(%s)" % (id, auto_resume, force_transcode))
userid = downloadUtils.getUserId()
@@ -71,26 +76,29 @@ def playFile(id, auto_resume):
playurl, listitem_props = PlayUtils().getStrmDetails(result)
if not playurl:
playurl = PlayUtils().getPlayUrl(id, result)
playurl = PlayUtils().getPlayUrl(id, result, force_transcode)
log.info("Play URL: " + playurl + " ListItem Properties: " + str(listitem_props))
playback_type_string = "DirectPlay"
if playback_type == "1":
playback_type_string = "DirectStream"
elif playback_type == "2":
if playback_type == "2" or force_transcode:
playback_type_string = "Transcode"
elif playback_type == "1":
playback_type_string = "DirectStream"
home_window = HomeWindow()
home_window.setProperty("PlaybackType_" + id, playback_type_string)
listItem = xbmcgui.ListItem(label=result.get("Name", i18n('missing_title')), path=playurl)
# add the playback type into the overview
result["Overview"] = playback_type_string + "\n" + result.get("Overview")
listItem = setListItemProps(id, listItem, result, server, listitem_props)
list_item = xbmcgui.ListItem(label=result.get("Name", i18n('missing_title')), path=playurl)
list_item = setListItemProps(id, list_item, result, server, listitem_props)
playlist = xbmc.PlayList(xbmc.PLAYLIST_VIDEO)
playlist.clear()
playlist.add(playurl, listItem)
playlist.add(playurl, list_item)
xbmc.Player().play(playlist)
if seekTime == 0:

View File

@@ -77,5 +77,6 @@ STRINGS = {
'emby_set_favorite': 30272,
'emby_unset_favorite': 30273,
'emby_delete': 30274,
'missing_title': 30280
'missing_title': 30280,
'emby_force_transcode': 30275,
}

View File

@@ -14,19 +14,44 @@ log = SimpleLogging(__name__)
###########################################################################
class PlayUtils():
def getPlayUrl(self, id, result):
def getPlayUrl(self, id, result, force_transcode):
log.info("getPlayUrl")
addonSettings = xbmcaddon.Addon(id='plugin.video.embycon')
playback_type = addonSettings.getSetting("playback_type")
playback_bitrate = addonSettings.getSetting("playback_bitrate")
server = addonSettings.getSetting('ipaddress') + ":" + addonSettings.getSetting('port')
smb_username = addonSettings.getSetting('smbusername')
smb_password = addonSettings.getSetting('smbpassword')
log.info("playback_type: " + playback_type)
if force_transcode:
log.info("playback_type: FORCED_TRANSCODE")
playurl = None
# transcode
if playback_type == "2" or force_transcode:
playback_bitrate = addonSettings.getSetting("playback_bitrate")
log.info("playback_bitrate: " + playback_bitrate)
width_options = ["640", "720", "1024", "1280", "1440", "1600", "1920", "2600", "4096"]
playback_max_width = width_options[int(addonSettings.getSetting("playback_max_width"))]
playback_video_force_8 = addonSettings.getSetting("playback_video_force_8") == "true"
clientInfo = ClientInformation()
deviceId = clientInfo.getDeviceId()
bitrate = int(playback_bitrate) * 1000
user_token = downloadUtils.authenticate()
playurl = (
"http://%s/emby/Videos/%s/master.m3u8?MediaSourceId=%s&VideoCodec=h264&AudioCodec=ac3&MaxAudioChannels=6&deviceId=%s&VideoBitrate=%s"
% (server, id, id, deviceId, bitrate))
playurl = playurl + "&maxWidth=" + playback_max_width
if playback_video_force_8:
playurl = playurl + "&MaxVideoBitDepth=8"
playurl = playurl + "&api_key=" + user_token
# do direct path playback
if playback_type == "0":
elif playback_type == "0":
playurl = result.get("Path")
# handle DVD structure
@@ -35,6 +60,9 @@ class PlayUtils():
elif (result.get("VideoType") == "BluRay"):
playurl = playurl + "/BDMV/index.bdmv"
smb_username = addonSettings.getSetting('smbusername')
smb_password = addonSettings.getSetting('smbpassword')
# add smb creds
if smb_username == '':
playurl = playurl.replace("\\\\", "smb://")
@@ -49,21 +77,6 @@ class PlayUtils():
user_token = downloadUtils.authenticate()
playurl = playurl + "&api_key=" + user_token
# do transcode http streaming playback
elif playback_type == "2":
log.info("playback_bitrate: " + playback_bitrate)
clientInfo = ClientInformation()
deviceId = clientInfo.getDeviceId()
bitrate = int(playback_bitrate) * 1000
user_token = downloadUtils.authenticate()
playurl = (
"http://%s/emby/Videos/%s/master.m3u8?MediaSourceId=%s&VideoCodec=h264&AudioCodec=ac3&MaxAudioChannels=6&deviceId=%s&VideoBitrate=%s"
% (server, id, id, deviceId, bitrate))
playurl = playurl + "&api_key=" + user_token
log.info("Playback URL: " + playurl)
return playurl.encode('utf-8')

View File

@@ -12,9 +12,15 @@
</category>
<category label="30207">
<setting id="playback_type" type="enum" label="30206" lvalues="30209|30210|30211" default="1" />
<setting id="playback_bitrate" type="slider" label="30208" default="6000" range="400,100,10000" option="int" visible="eq(-1,2)"/>
<setting id="smbusername" type="text" label="30007" default="" enable="true" visible="eq(-2,0)"/>
<setting id="smbpassword" type="text" label="30008" default="" option="hidden" enable="true" visible="eq(-3,0)"/>
<setting label="30209" type="lsep"/>
<setting type="sep" />
<setting id="smbusername" type="text" label="30007" default="" enable="true" visible="true"/>
<setting id="smbpassword" type="text" label="30008" default="" option="hidden" enable="true" visible="true"/>
<setting label="30211" type="lsep"/>
<setting type="sep" />
<setting id="playback_bitrate" type="slider" label="30208" default="6000" range="400,100,10000" option="int" visible="true"/>
<setting id="playback_max_width" type="enum" label="30212" lvalues="640x|720x|1024x|1280x|1440x|1600x|1920x|2600x|4096x" default="6" visible="true"/>
<setting id="playback_video_force_8" type="bool" label="30213" default="false" visible="true" enable="true"/>
</category>
<category label="30110">
<setting id="showLoadProgress" type="bool" label="30120" default="false" visible="true" enable="true" />

View File

@@ -4,6 +4,7 @@
import xbmc
import xbmcaddon
import time
import json
from datetime import datetime
from resources.lib.downloadutils import DownloadUtils
@@ -222,12 +223,11 @@ while not xbmc.abortRequested:
pass
else:
emby_item_id = home_window.getProperty("play_item_id")
emby_item_resume = home_window.getProperty("play_item_resume")
if emby_item_id and emby_item_resume:
home_window.clearProperty("play_item_id")
home_window.clearProperty("play_item_resume")
playFile(emby_item_id, emby_item_resume)
play_data = home_window.getProperty("play_item_message")
if play_data:
home_window.clearProperty("play_item_message")
play_info = json.loads(play_data)
playFile(play_info)
xbmc.sleep(1000)
HomeWindow().setProperty("Service_Timestamp", str(int(time.time())))