Skip to content

Commit 41f9787

Browse files
committed
Initialize headers from config in reset_base_headers()
1 parent cc313c5 commit 41f9787

1 file changed

Lines changed: 22 additions & 9 deletions

File tree

plexapi/config.py

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -51,15 +51,28 @@ def _asDict(self):
5151

5252
def reset_base_headers():
5353
""" Convenience function returns a dict of all base X-Plex-* headers for session requests. """
54-
import plexapi
54+
from plexapi import CONFIG, PROJECT, VERSION
55+
from platform import uname
56+
from uuid import getnode
57+
58+
# Plex Header Configuration
59+
X_PLEX_PROVIDES = CONFIG.get('header.provides', 'controller')
60+
X_PLEX_PLATFORM = CONFIG.get('header.platform', CONFIG.get('header.platorm', uname()[0]))
61+
X_PLEX_PLATFORM_VERSION = CONFIG.get('header.platform_version', uname()[2])
62+
X_PLEX_PRODUCT = CONFIG.get('header.product', PROJECT)
63+
X_PLEX_VERSION = CONFIG.get('header.version', VERSION)
64+
X_PLEX_DEVICE = CONFIG.get('header.device', X_PLEX_PLATFORM)
65+
X_PLEX_DEVICE_NAME = CONFIG.get('header.device_name', uname()[1])
66+
X_PLEX_IDENTIFIER = CONFIG.get('header.identifier', str(hex(getnode())))
67+
5568
return {
56-
'X-Plex-Platform': plexapi.X_PLEX_PLATFORM,
57-
'X-Plex-Platform-Version': plexapi.X_PLEX_PLATFORM_VERSION,
58-
'X-Plex-Provides': plexapi.X_PLEX_PROVIDES,
59-
'X-Plex-Product': plexapi.X_PLEX_PRODUCT,
60-
'X-Plex-Version': plexapi.X_PLEX_VERSION,
61-
'X-Plex-Device': plexapi.X_PLEX_DEVICE,
62-
'X-Plex-Device-Name': plexapi.X_PLEX_DEVICE_NAME,
63-
'X-Plex-Client-Identifier': plexapi.X_PLEX_IDENTIFIER,
69+
'X-Plex-Platform': X_PLEX_PLATFORM,
70+
'X-Plex-Platform-Version': X_PLEX_PLATFORM_VERSION,
71+
'X-Plex-Provides': X_PLEX_PROVIDES,
72+
'X-Plex-Product': X_PLEX_PRODUCT,
73+
'X-Plex-Version': X_PLEX_VERSION,
74+
'X-Plex-Device': X_PLEX_DEVICE,
75+
'X-Plex-Device-Name': X_PLEX_DEVICE_NAME,
76+
'X-Plex-Client-Identifier': X_PLEX_IDENTIFIER,
6477
'X-Plex-Sync-Version': '2',
6578
}

0 commit comments

Comments
 (0)