Skip to content

Commit

Permalink
fix weird new chromium pasting bug - please use firefox! (closes #409)
Browse files Browse the repository at this point in the history
  • Loading branch information
sigma67 committed Aug 20, 2023
1 parent 0ef4656 commit 6660058
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
2 changes: 1 addition & 1 deletion docs/source/setup/browser.rst
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ To do so, follow these steps:
.. raw:: html

<details open>
<summary><a>Firefox</a></summary>
<summary><a>Firefox (recommended)</a></summary>

.. container::

Expand Down
12 changes: 10 additions & 2 deletions ytmusicapi/auth/browser.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 6660058

Please sign in to comment.