Skip to content

Commit 3434f26

Browse files
committed
Initialize headers from config in reset_base_headers()
1 parent 8b32354 commit 3434f26

1 file changed

Lines changed: 23 additions & 9 deletions

File tree

plexapi/config.py

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -51,16 +51,30 @@ 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 platform import uname
55+
from uuid import getnode
56+
57+
from plexapi import CONFIG, PROJECT, VERSION
58+
59+
# Plex Header Configuration
60+
X_PLEX_PROVIDES = CONFIG.get('header.provides', 'controller')
61+
X_PLEX_PLATFORM = CONFIG.get('header.platform', CONFIG.get('header.platorm', uname()[0]))
62+
X_PLEX_PLATFORM_VERSION = CONFIG.get('header.platform_version', uname()[2])
63+
X_PLEX_PRODUCT = CONFIG.get('header.product', PROJECT)
64+
X_PLEX_VERSION = CONFIG.get('header.version', VERSION)
65+
X_PLEX_DEVICE = CONFIG.get('header.device', X_PLEX_PLATFORM)
66+
X_PLEX_DEVICE_NAME = CONFIG.get('header.device_name', uname()[1])
67+
X_PLEX_IDENTIFIER = CONFIG.get('header.identifier', str(hex(getnode())))
68+
5569
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,
70+
'X-Plex-Platform': X_PLEX_PLATFORM,
71+
'X-Plex-Platform-Version': X_PLEX_PLATFORM_VERSION,
72+
'X-Plex-Provides': X_PLEX_PROVIDES,
73+
'X-Plex-Product': X_PLEX_PRODUCT,
74+
'X-Plex-Version': X_PLEX_VERSION,
75+
'X-Plex-Device': X_PLEX_DEVICE,
76+
'X-Plex-Device-Name': X_PLEX_DEVICE_NAME,
77+
'X-Plex-Client-Identifier': X_PLEX_IDENTIFIER,
6478
'X-Plex-Sync-Version': '2',
6579
'X-Plex-Features': 'external-media',
6680
}

0 commit comments

Comments
 (0)