Fix transcoding for HTTP, HTTPs still shaky

This commit is contained in:
tomkat83 2016-03-24 10:24:11 +01:00
parent 5d2dbaaf1e
commit eca710f2a9
3 changed files with 21 additions and 24 deletions

View file

@ -29,17 +29,6 @@ http://stackoverflow.com/questions/2407126/python-urllib2-basic-auth-problem
http://stackoverflow.com/questions/111945/is-there-any-way-to-do-http-put-in-python http://stackoverflow.com/questions/111945/is-there-any-way-to-do-http-put-in-python
(and others...) (and others...)
""" """
# Specific to PlexDB:
import clientinfo
import utils
import downloadutils
import xbmcaddon
import xbmcgui
import xbmc
import xbmcvfs
import struct import struct
import time import time
import urllib2 import urllib2
@ -52,13 +41,21 @@ import Queue
import traceback import traceback
import requests import requests
import xml.etree.ElementTree as etree import xml.etree.ElementTree as etree
from uuid import uuid4
import re import re
import json import json
from urllib import urlencode, quote_plus, unquote from urllib import urlencode, quote_plus, unquote
from PlexFunctions import PlexToKodiTimefactor, PMSHttpsEnabled import clientinfo
import utils
import downloadutils
import xbmcaddon
import xbmcgui
import xbmc
import xbmcvfs
from PlexFunctions import PlexToKodiTimefactor, PMSHttpsEnabled
# Disable requests logging # Disable requests logging
from requests.packages.urllib3.exceptions import InsecureRequestWarning from requests.packages.urllib3.exceptions import InsecureRequestWarning
@ -835,8 +832,6 @@ class PlexAPI():
'X-Plex-Version': self.plexversion, 'X-Plex-Version': self.plexversion,
'X-Plex-Client-Identifier': self.clientId, 'X-Plex-Client-Identifier': self.clientId,
'X-Plex-Provides': 'player', 'X-Plex-Provides': 'player',
'X-Plex-Client-Capabilities': 'protocols=shoutcast,http-video;videoDecoders=h264{profile:high&resolution:1080&level:51};audioDecoders=mp3,aac,dts{bitrate:800000&channels:8},ac3{bitrate:800000&channels:8}',
'X-Plex-Client-Profile-Extra': 'add-transcode-target-audio-codec(type=videoProfile&context=streaming&protocol=*&audioCodec=dca,ac3)',
} }
if self.token: if self.token:
@ -2178,10 +2173,12 @@ class API():
'mediaIndex': 0, # Probably refering to XML reply sheme 'mediaIndex': 0, # Probably refering to XML reply sheme
'partIndex': self.part, 'partIndex': self.part,
'protocol': 'hls', # seen in the wild: 'dash', 'http', 'hls' 'protocol': 'hls', # seen in the wild: 'dash', 'http', 'hls'
'session': self.clientId, 'session': str(uuid4()),
# 'offset': 0, # Resume point # 'offset': 0, # Resume point
'fastSeek': 1 'fastSeek': 1
} }
# Seem like PHT to let the PMS use the transcoding profile
xargs['X-Plex-Device'] = 'Plex Home Theater'
# Currently not used! # Currently not used!
if action == "DirectStream": if action == "DirectStream":
@ -2199,9 +2196,7 @@ class API():
args.update(quality) args.update(quality)
args.update(argsUpdate) args.update(argsUpdate)
url = transcodePath + \ url = transcodePath + urlencode(xargs) + '&' + urlencode(args)
urlencode(xargs) + '&' + \
urlencode(args)
return url return url
def externalSubs(self, playurl): def externalSubs(self, playurl):

View file

@ -184,7 +184,7 @@ class PlaybackUtils():
# For transcoding only, ask for audio/subs pref # For transcoding only, ask for audio/subs pref
if window('emby_%s.playmethod' % playurl) == "Transcode": if window('emby_%s.playmethod' % playurl) == "Transcode":
window('emby_%s.playmethod' % playurl, clear=True) window('emby_%s.playmethod' % playurl, clear=True)
playurl = playutils.audioSubsPref(playurl, listitem) playurl = playutils.audioSubsPref(listitem, playurl)
window('emby_%s.playmethod' % playurl, value="Transcode") window('emby_%s.playmethod' % playurl, value="Transcode")
listitem.setPath(playurl) listitem.setPath(playurl)

View file

@ -321,22 +321,24 @@ class PlayUtils():
# Set part where we're at # Set part where we're at
self.API.setPartNumber(part) self.API.setPartNumber(part)
if part is None:
part = 0
try: try:
mediastreams = self.item[0][part] mediastreams = self.item[0][part]
except (TypeError, KeyError, IndexError): except (TypeError, KeyError, IndexError):
return return url
audioNum = 0 audioNum = 0
# Remember 'no subtitles' # Remember 'no subtitles'
subNum = 1 subNum = 1
for stream in mediastreams: for stream in mediastreams:
# Since Emby returns all possible tracks together, have to sort them. # Since Emby returns all possible tracks together, have to sort them.
index = stream.attrib['id'] index = stream.attrib.get('id')
type = stream.attrib['streamType'] type = stream.attrib.get('streamType')
# Audio # Audio
if type == "2": if type == "2":
codec = stream.attrib['codec'] codec = stream.attrib.get('codec')
channelLayout = stream.attrib.get('audioChannelLayout', "") channelLayout = stream.attrib.get('audioChannelLayout', "")
try: try:
@ -356,7 +358,7 @@ class PlayUtils():
try: try:
track = "%s %s" % (subNum+1, stream.attrib['language']) track = "%s %s" % (subNum+1, stream.attrib['language'])
except: except:
track = "%s 'unknown' (%s)" % (subNum+1, stream.attrib['codec']) track = "%s 'unknown' (%s)" % (subNum+1, stream.attrib.get('codec'))
default = stream.attrib.get('default') default = stream.attrib.get('default')
forced = stream.attrib.get('forced') forced = stream.attrib.get('forced')