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
(and others...)
"""
# Specific to PlexDB:
import clientinfo
import utils
import downloadutils
import xbmcaddon
import xbmcgui
import xbmc
import xbmcvfs
import struct
import time
import urllib2
@ -52,13 +41,21 @@ import Queue
import traceback
import requests
import xml.etree.ElementTree as etree
from uuid import uuid4
import re
import json
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
from requests.packages.urllib3.exceptions import InsecureRequestWarning
@ -835,8 +832,6 @@ class PlexAPI():
'X-Plex-Version': self.plexversion,
'X-Plex-Client-Identifier': self.clientId,
'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:
@ -2178,10 +2173,12 @@ class API():
'mediaIndex': 0, # Probably refering to XML reply sheme
'partIndex': self.part,
'protocol': 'hls', # seen in the wild: 'dash', 'http', 'hls'
'session': self.clientId,
'session': str(uuid4()),
# 'offset': 0, # Resume point
'fastSeek': 1
}
# Seem like PHT to let the PMS use the transcoding profile
xargs['X-Plex-Device'] = 'Plex Home Theater'
# Currently not used!
if action == "DirectStream":
@ -2199,9 +2196,7 @@ class API():
args.update(quality)
args.update(argsUpdate)
url = transcodePath + \
urlencode(xargs) + '&' + \
urlencode(args)
url = transcodePath + urlencode(xargs) + '&' + urlencode(args)
return url
def externalSubs(self, playurl):

View file

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

View file

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