Fix X-Plex-Client-Identifier to send unique id per client, not static value.

This commit is contained in:
Tim 2015-06-28 14:28:26 +02:00
parent 7bf45f8bef
commit 4f1056cf87
4 changed files with 14 additions and 2 deletions

View file

@ -732,11 +732,10 @@
dataType: 'xml', dataType: 'xml',
async: true, async: true,
headers: {'Content-Type': 'application/xml; charset=utf-8', headers: {'Content-Type': 'application/xml; charset=utf-8',
'Content-Length': '0',
'X-Plex-Device-Name': 'PlexPy', 'X-Plex-Device-Name': 'PlexPy',
'X-Plex-Product': 'PlexPy', 'X-Plex-Product': 'PlexPy',
'X-Plex-Version': 'v0.1 dev', 'X-Plex-Version': 'v0.1 dev',
'X-Plex-Client-Identifier': 'f0864d3531d75b19fa9204eaea456515e2502017', 'X-Plex-Client-Identifier': '${config['pms_uuid']}',
'Authorization': 'Basic ' + btoa($("#pms_username").val() + ':' + $("#pms_password").val()) 'Authorization': 'Basic ' + btoa($("#pms_username").val() + ':' + $("#pms_password").val())
}, },
error: function(jqXHR, textStatus, errorThrown) { error: function(jqXHR, textStatus, errorThrown) {

View file

@ -24,6 +24,7 @@ import webbrowser
import sqlite3 import sqlite3
import cherrypy import cherrypy
import datetime import datetime
import uuid
from apscheduler.schedulers.background import BackgroundScheduler from apscheduler.schedulers.background import BackgroundScheduler
from apscheduler.triggers.interval import IntervalTrigger from apscheduler.triggers.interval import IntervalTrigger
@ -128,6 +129,12 @@ def initialize(config_file):
except Exception as e: except Exception as e:
logger.error("Can't connect to the database: %s", e) logger.error("Can't connect to the database: %s", e)
# Check if PlexPy has a uuid
if CONFIG.PMS_UUID == '' or not CONFIG.PMS_UUID:
my_uuid = generate_uuid()
CONFIG.__setattr__('PMS_UUID', my_uuid)
CONFIG.write()
# Get the currently installed version. Returns None, 'win32' or the git # Get the currently installed version. Returns None, 'win32' or the git
# hash. # hash.
CURRENT_VERSION, CONFIG.GIT_BRANCH = versioncheck.getVersion() CURRENT_VERSION, CONFIG.GIT_BRANCH = versioncheck.getVersion()
@ -334,3 +341,7 @@ def shutdown(restart=False, update=False):
subprocess.Popen(popen_list, cwd=os.getcwd()) subprocess.Popen(popen_list, cwd=os.getcwd())
os._exit(0) os._exit(0)
def generate_uuid():
logger.debug(u"Generating UUID...")
return uuid.uuid4().hex

View file

@ -28,6 +28,7 @@ _CONFIG_DEFINITIONS = {
'PMS_TOKEN': (str, 'PMS', ''), 'PMS_TOKEN': (str, 'PMS', ''),
'PMS_USERNAME': (str, 'PMS', ''), 'PMS_USERNAME': (str, 'PMS', ''),
'PMS_USE_BIF': (int, 'PMS', 0), 'PMS_USE_BIF': (int, 'PMS', 0),
'PMS_UUID': (str, 'PMS', ''),
'TIME_FORMAT': (str, 'General', 'HH:mm'), 'TIME_FORMAT': (str, 'General', 'HH:mm'),
'API_ENABLED': (int, 'General', 0), 'API_ENABLED': (int, 'General', 0),
'API_KEY': (str, 'General', ''), 'API_KEY': (str, 'General', ''),

View file

@ -274,6 +274,7 @@ class WebInterface(object):
"pms_port": plexpy.CONFIG.PMS_PORT, "pms_port": plexpy.CONFIG.PMS_PORT,
"pms_token": plexpy.CONFIG.PMS_TOKEN, "pms_token": plexpy.CONFIG.PMS_TOKEN,
"pms_use_bif": checked(plexpy.CONFIG.PMS_USE_BIF), "pms_use_bif": checked(plexpy.CONFIG.PMS_USE_BIF),
"pms_uuid": plexpy.CONFIG.PMS_UUID,
"plexwatch_database": plexpy.CONFIG.PLEXWATCH_DATABASE, "plexwatch_database": plexpy.CONFIG.PLEXWATCH_DATABASE,
"date_format": plexpy.CONFIG.DATE_FORMAT, "date_format": plexpy.CONFIG.DATE_FORMAT,
"time_format": plexpy.CONFIG.TIME_FORMAT, "time_format": plexpy.CONFIG.TIME_FORMAT,