From 6405bec93fa87200b48d90fa6e874f61b0ecdc58 Mon Sep 17 00:00:00 2001 From: sigma67 Date: Sat, 31 Oct 2020 14:20:06 +0100 Subject: [PATCH] Make (x-)origin header backwards-compatible to avoid breaking existing headers files (#87) --- ytmusicapi/ytmusic.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/ytmusicapi/ytmusic.py b/ytmusicapi/ytmusic.py index 2d1db76..40f6f1c 100644 --- a/ytmusicapi/ytmusic.py +++ b/ytmusicapi/ytmusic.py @@ -103,8 +103,8 @@ class YTMusic(BrowsingMixin, WatchMixin, LibraryMixin, PlaylistsMixin, UploadsMi def _send_request(self, endpoint: str, body: Dict, additionalParams: str = "") -> Dict: body.update(self.context) if self.auth: - self.headers["Authorization"] = get_authorization(self.sapisid + ' ' - + self.headers['origin']) + origin = self.headers.get('origin', self.headers.get('x-origin')) + self.headers["Authorization"] = get_authorization(self.sapisid + ' ' + origin) response = requests.post(base_url + endpoint + params + additionalParams, json=body, headers=self.headers, @@ -127,9 +127,9 @@ class YTMusic(BrowsingMixin, WatchMixin, LibraryMixin, PlaylistsMixin, UploadsMi :return: configuration headers string """ return setup(filepath, headers_raw) - + def __enter__(self): return self - - def __exit__(self, execType = None, execValue = None, trackback = None): + + def __exit__(self, execType=None, execValue=None, trackback=None): pass