-
Notifications
You must be signed in to change notification settings - Fork 199
Initialize headers from config in reset_base_headers() #707
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
3434f26
5d1878a
a8a9079
b5051d8
839c856
89f8bff
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -42,25 +42,47 @@ def get(self, key, default=None, cast=None): | |
def _asDict(self): | ||
""" Returns all configuration values as a dictionary. """ | ||
config = defaultdict(dict) | ||
config.update(self._defaults()) | ||
for section in self._sections: | ||
for name, value in self._sections[section].items(): | ||
if name != '__name__': | ||
config[section.lower()][name.lower()] = value | ||
return dict(config) | ||
|
||
def _defaults(self): | ||
from uuid import getnode | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Don’t in-line std libs. |
||
from platform import uname | ||
from plexapi import PROJECT, VERSION | ||
|
||
platform_name, device_name, platform_version = uname()[0:3] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fix the slicing. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Explain fix how? fix what? what is wrong with the current code? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why is the current slicing wrong. how is the correct way? |
||
|
||
return { | ||
'header': { | ||
'provides': 'controller', | ||
'platform': platform_name, | ||
'platform_version': platform_version, | ||
'product': PROJECT, | ||
'version': VERSION, | ||
'device': platform_name, | ||
'device_name': device_name, | ||
'identifier': str(hex(getnode())), | ||
} | ||
} | ||
|
||
|
||
def reset_base_headers(): | ||
""" Convenience function returns a dict of all base X-Plex-* headers for session requests. """ | ||
import plexapi | ||
from plexapi import CONFIG | ||
|
||
return { | ||
'X-Plex-Platform': plexapi.X_PLEX_PLATFORM, | ||
'X-Plex-Platform-Version': plexapi.X_PLEX_PLATFORM_VERSION, | ||
'X-Plex-Provides': plexapi.X_PLEX_PROVIDES, | ||
'X-Plex-Product': plexapi.X_PLEX_PRODUCT, | ||
'X-Plex-Version': plexapi.X_PLEX_VERSION, | ||
'X-Plex-Device': plexapi.X_PLEX_DEVICE, | ||
'X-Plex-Device-Name': plexapi.X_PLEX_DEVICE_NAME, | ||
'X-Plex-Client-Identifier': plexapi.X_PLEX_IDENTIFIER, | ||
'X-Plex-Platform': CONFIG.get('header.platorm', CONFIG.get('header.platform')), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe it's about time to drop support for the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it was fixed in 2018, matching 3.2.0 version: |
||
'X-Plex-Platform-Version': CONFIG.get('header.platform_version'), | ||
'X-Plex-Provides': CONFIG.get('header.provides'), | ||
'X-Plex-Product': CONFIG.get('header.product'), | ||
'X-Plex-Version': CONFIG.get('header.version'), | ||
'X-Plex-Device': CONFIG.get('header.device'), | ||
'X-Plex-Device-Name': CONFIG.get('header.device_name'), | ||
'X-Plex-Client-Identifier': CONFIG.get('header.identifier'), | ||
'X-Plex-Sync-Version': '2', | ||
'X-Plex-Features': 'external-media', | ||
} |
Uh oh!
There was an error while loading. Please reload this page.