Optimize headers for communication with PMS to appear like PMP

This commit is contained in:
croneter 2019-02-05 18:52:10 +01:00
parent 548d83874b
commit 9208cf2cb3
6 changed files with 29 additions and 25 deletions

View file

@ -32,12 +32,11 @@ def getXArgsDeviceInfo(options=None, include_token=True):
"Content-Type": "application/x-www-form-urlencoded",
# "Access-Control-Allow-Origin": "*",
# 'X-Plex-Language': 'en',
'X-Plex-Device': v.ADDON_NAME,
'X-Plex-Client-Platform': v.PLATFORM,
'X-Plex-Device': v.DEVICE,
'X-Plex-Model': v.MODEL,
'X-Plex-Device-Name': v.DEVICENAME,
'X-Plex-Platform': v.PLATFORM,
# 'X-Plex-Platform-Version': 'unknown',
# 'X-Plex-Model': 'unknown',
'X-Plex-Platform-Version': v.PLATFORM_VERSION,
'X-Plex-Product': v.ADDON_NAME,
'X-Plex-Version': v.ADDON_VERSION,
'X-Plex-Client-Identifier': getDeviceId(),

View file

@ -5,7 +5,7 @@ import xbmc
from .. import app, utils, variables as v
PLAYLIST_SYNC_ENABLED = (v.PLATFORM != 'Microsoft UWP' and
PLAYLIST_SYNC_ENABLED = (v.DEVICE != 'Microsoft UWP' and
utils.settings('enablePlaylistSync') == 'true')

View file

@ -40,7 +40,7 @@ RESOURCES_XML = ('%s<MediaContainer>\n'
'</MediaContainer>\n') % (v.XML_HEADER,
v.ADDON_NAME,
v.PLATFORM,
v.ADDON_VERSION)
v.PLATFORM_VERSION)
class MyHandler(BaseHTTPRequestHandler):
"""

View file

@ -9,7 +9,7 @@ from logging import getLogger
from threading import Thread
from ..downloadutils import DownloadUtils as DU
from .. import utils, timing
from .. import timing
from .. import app
from .. import variables as v
from .. import json_rpc as js
@ -50,7 +50,7 @@ HEADERS_PMS = {
'Accept': 'text/plain, */*; q=0.01',
'Accept-Language': 'en',
'Accept-Encoding': 'gzip, deflate',
'User-Agent': '%s %s (%s)' % (v.ADDON_NAME, v.ADDON_VERSION, v.PLATFORM)
'User-Agent': '%s %s (%s)' % (v.ADDON_NAME, v.ADDON_VERSION, v.DEVICE)
}
@ -64,14 +64,13 @@ def params_pms():
# 'audioDecoders=mp3,aac,dts{bitrate:800000&channels:2},'
# 'ac3{bitrate:800000&channels:2}',
'X-Plex-Client-Identifier': v.PKC_MACHINE_IDENTIFIER,
'X-Plex-Device': v.PLATFORM,
'X-Plex-Device': v.DEVICE,
'X-Plex-Device-Name': v.DEVICENAME,
# 'X-Plex-Device-Screen-Resolution': '1916x1018,1920x1080',
'X-Plex-Model': 'unknown',
'X-Plex-Model': v.MODEL,
'X-Plex-Platform': v.PLATFORM,
'X-Plex-Platform-Version': 'unknown',
'X-Plex-Platform-Version': v.PLATFORM_VERSION,
'X-Plex-Product': v.ADDON_NAME,
'X-Plex-Provider-Version': v.ADDON_VERSION,
'X-Plex-Version': v.ADDON_VERSION,
'hasMDE': '1',
# 'X-Plex-Session-Identifier': ['vinuvirm6m20iuw9c4cx1dcx'],
@ -89,7 +88,7 @@ def headers_companion_client():
'X-Plex-Client-Identifier': v.PKC_MACHINE_IDENTIFIER,
'X-Plex-Device-Name': v.DEVICENAME,
'X-Plex-Platform': v.PLATFORM,
'X-Plex-Platform-Version': 'unknown',
'X-Plex-Platform-Version': v.PLATFORM_VERSION,
'X-Plex-Product': v.ADDON_NAME,
'X-Plex-Version': v.ADDON_VERSION,
'Accept-Encoding': 'gzip, deflate',

View file

@ -340,14 +340,14 @@ def valid_filename(text):
text = re.sub(r'(?! )\s', '', text)
# ASCII characters 0 to 31 (non-printable, just in case)
text = re.sub(u'[\x00-\x1f]', '', text)
if v.PLATFORM == 'Windows':
if v.DEVICE == 'Windows':
# Whitespace at the end of the filename is illegal
text = text.strip()
# Dot at the end of a filename is illegal
text = re.sub(r'\.+$', '', text)
# Illegal Windows characters
text = re.sub(r'[/\\:*?"<>|\^]', '', text)
elif v.PLATFORM == 'MacOSX':
elif v.DEVICE == 'MacOSX':
# Colon is illegal
text = re.sub(r':', '', text)
# Files cannot begin with a dot

View file

@ -4,6 +4,7 @@ from __future__ import absolute_import, division, unicode_literals
import os
import sys
import re
import platform
import xbmc
from xbmcaddon import Addon
@ -51,23 +52,28 @@ KODILONGVERSION = xbmc.getInfoLabel('System.BuildVersion')
KODI_PROFILE = try_decode(xbmc.translatePath("special://profile"))
if xbmc.getCondVisibility('system.platform.osx'):
PLATFORM = "MacOSX"
DEVICE = "MacOSX"
elif xbmc.getCondVisibility("system.platform.uwp"):
PLATFORM = "Microsoft UWP"
DEVICE = "Microsoft UWP"
elif xbmc.getCondVisibility('system.platform.atv2'):
PLATFORM = "AppleTV2"
DEVICE = "AppleTV2"
elif xbmc.getCondVisibility('system.platform.ios'):
PLATFORM = "iOS"
DEVICE = "iOS"
elif xbmc.getCondVisibility('system.platform.windows'):
PLATFORM = "Windows"
DEVICE = "Windows"
elif xbmc.getCondVisibility('system.platform.raspberrypi'):
PLATFORM = "RaspberryPi"
DEVICE = "RaspberryPi"
elif xbmc.getCondVisibility('system.platform.linux'):
PLATFORM = "Linux"
DEVICE = "Linux"
elif xbmc.getCondVisibility('system.platform.android'):
PLATFORM = "Android"
DEVICE = "Android"
else:
PLATFORM = "Unknown"
DEVICE = "Unknown"
MODEL = platform.release() or 'Unknown'
# Plex' own platform for e.g. Plex Media Player
PLATFORM = 'Konvergo'
PLATFORM_VERSION = '2.26.0.947-1e21fa2b'
DEVICENAME = try_decode(_ADDON.getSetting('deviceName'))
if not DEVICENAME:
@ -637,7 +643,7 @@ def database_paths():
# Encoding to be used for our m3u playlist files
# m3u files do not have encoding specified by definition, unfortunately.
if PLATFORM == 'Windows':
if DEVICE == 'Windows':
M3U_ENCODING = 'mbcs'
else:
M3U_ENCODING = sys.getfilesystemencoding()