diff --git a/data/interfaces/default/config.html b/data/interfaces/default/config.html index 1e81e8ba..b4d4f38b 100644 --- a/data/interfaces/default/config.html +++ b/data/interfaces/default/config.html @@ -732,11 +732,10 @@ dataType: 'xml', async: true, headers: {'Content-Type': 'application/xml; charset=utf-8', - 'Content-Length': '0', 'X-Plex-Device-Name': 'PlexPy', 'X-Plex-Product': 'PlexPy', '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()) }, error: function(jqXHR, textStatus, errorThrown) { diff --git a/plexpy/__init__.py b/plexpy/__init__.py index 15c2e351..f456bb8c 100644 --- a/plexpy/__init__.py +++ b/plexpy/__init__.py @@ -24,6 +24,7 @@ import webbrowser import sqlite3 import cherrypy import datetime +import uuid from apscheduler.schedulers.background import BackgroundScheduler from apscheduler.triggers.interval import IntervalTrigger @@ -128,6 +129,12 @@ def initialize(config_file): except Exception as 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 # hash. CURRENT_VERSION, CONFIG.GIT_BRANCH = versioncheck.getVersion() @@ -334,3 +341,7 @@ def shutdown(restart=False, update=False): subprocess.Popen(popen_list, cwd=os.getcwd()) os._exit(0) + +def generate_uuid(): + logger.debug(u"Generating UUID...") + return uuid.uuid4().hex \ No newline at end of file diff --git a/plexpy/config.py b/plexpy/config.py index b677422b..fb9854ad 100644 --- a/plexpy/config.py +++ b/plexpy/config.py @@ -28,6 +28,7 @@ _CONFIG_DEFINITIONS = { 'PMS_TOKEN': (str, 'PMS', ''), 'PMS_USERNAME': (str, 'PMS', ''), 'PMS_USE_BIF': (int, 'PMS', 0), + 'PMS_UUID': (str, 'PMS', ''), 'TIME_FORMAT': (str, 'General', 'HH:mm'), 'API_ENABLED': (int, 'General', 0), 'API_KEY': (str, 'General', ''), diff --git a/plexpy/webserve.py b/plexpy/webserve.py index 45f3245a..d756dbeb 100644 --- a/plexpy/webserve.py +++ b/plexpy/webserve.py @@ -274,6 +274,7 @@ class WebInterface(object): "pms_port": plexpy.CONFIG.PMS_PORT, "pms_token": plexpy.CONFIG.PMS_TOKEN, "pms_use_bif": checked(plexpy.CONFIG.PMS_USE_BIF), + "pms_uuid": plexpy.CONFIG.PMS_UUID, "plexwatch_database": plexpy.CONFIG.PLEXWATCH_DATABASE, "date_format": plexpy.CONFIG.DATE_FORMAT, "time_format": plexpy.CONFIG.TIME_FORMAT,