From 6660058a47dc31cefe1c3686067aeef0333c2590 Mon Sep 17 00:00:00 2001 From: sigma67 Date: Sun, 20 Aug 2023 18:16:43 +0200 Subject: [PATCH] fix weird new chromium pasting bug - please use firefox! (closes #409) --- docs/source/setup/browser.rst | 2 +- ytmusicapi/auth/browser.py | 12 ++++++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/docs/source/setup/browser.rst b/docs/source/setup/browser.rst index b146b52..d79567f 100644 --- a/docs/source/setup/browser.rst +++ b/docs/source/setup/browser.rst @@ -20,7 +20,7 @@ To do so, follow these steps: .. raw:: html
- Firefox + Firefox (recommended) .. container:: diff --git a/ytmusicapi/auth/browser.py b/ytmusicapi/auth/browser.py index 65c60a0..6f55218 100644 --- a/ytmusicapi/auth/browser.py +++ b/ytmusicapi/auth/browser.py @@ -29,11 +29,19 @@ def setup_browser(filepath=None, headers_raw=None): try: user_headers = {} + chrome_remembered_key = "" for content in contents: header = content.split(": ") - if len(header) == 1 or header[0].startswith( - ":"): # nothing was split or chromium headers + if header[0].startswith(":"): # nothing was split or chromium headers continue + if header[0].endswith(":"): # pragma: no cover + # weird new chrome "copy-paste in separate lines" format + chrome_remembered_key = content.replace(":", "") + if len(header) == 1: + if chrome_remembered_key: # pragma: no cover + user_headers[chrome_remembered_key] = header[0] + continue + user_headers[header[0].lower()] = ": ".join(header[1:]) except Exception as e: