Make (x-)origin header backwards-compatible to avoid breaking existing headers files (#87)

This commit is contained in:
sigma67 2020-10-31 14:20:06 +01:00
commit 6405bec93f
No known key found for this signature in database
GPG key ID: 1545A01D4474BAF0

View file

@ -103,8 +103,8 @@ class YTMusic(BrowsingMixin, WatchMixin, LibraryMixin, PlaylistsMixin, UploadsMi
def _send_request(self, endpoint: str, body: Dict, additionalParams: str = "") -> Dict: def _send_request(self, endpoint: str, body: Dict, additionalParams: str = "") -> Dict:
body.update(self.context) body.update(self.context)
if self.auth: if self.auth:
self.headers["Authorization"] = get_authorization(self.sapisid + ' ' origin = self.headers.get('origin', self.headers.get('x-origin'))
+ self.headers['origin']) self.headers["Authorization"] = get_authorization(self.sapisid + ' ' + origin)
response = requests.post(base_url + endpoint + params + additionalParams, response = requests.post(base_url + endpoint + params + additionalParams,
json=body, json=body,
headers=self.headers, headers=self.headers,
@ -127,9 +127,9 @@ class YTMusic(BrowsingMixin, WatchMixin, LibraryMixin, PlaylistsMixin, UploadsMi
:return: configuration headers string :return: configuration headers string
""" """
return setup(filepath, headers_raw) return setup(filepath, headers_raw)
def __enter__(self): def __enter__(self):
return self return self
def __exit__(self, execType = None, execValue = None, trackback = None): def __exit__(self, execType=None, execValue=None, trackback=None):
pass pass