Skip to content

Commit

Permalink
use CaseInsensitiveDict for headers
Browse files Browse the repository at this point in the history
  • Loading branch information
sigma67 committed Dec 12, 2021
1 parent afad9d2 commit 0cefc97
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion ytmusicapi/mixins/uploads.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ def upload_song(self, filepath: str) -> Union[str, requests.Response]:
+ ', '.join(supported_filetypes))

headers = self.headers.copy()
upload_url = "https://upload.youtube.com/upload/usermusic/http?authuser=%s" % headers['X-Goog-AuthUser']
upload_url = "https://upload.youtube.com/upload/usermusic/http?authuser=%s" % headers['x-goog-authuser']
filesize = os.path.getsize(filepath)
body = ("filename=" + ntpath.basename(filepath)).encode('utf-8')
headers.pop('content-encoding', None)
Expand Down
8 changes: 4 additions & 4 deletions ytmusicapi/ytmusic.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import requests
import gettext
import os
from requests.structures import CaseInsensitiveDict
from functools import partial
from contextlib import suppress
from typing import Dict
Expand Down Expand Up @@ -74,15 +75,14 @@ def __init__(self,
self.proxies = proxies

# prepare headers
self.headers = {}
if auth:
try:
if os.path.isfile(auth):
file = auth
with open(file) as json_file:
self.headers = json.load(json_file)
self.headers = CaseInsensitiveDict(json.load(json_file))
else:
self.headers = json.loads(auth)
self.headers = CaseInsensitiveDict(json.loads(auth))

except Exception as e:
print(
Expand Down Expand Up @@ -120,7 +120,7 @@ def __init__(self,
# verify authentication credentials work
if auth:
try:
cookie = self.headers.get('cookie', self.headers.get('Cookie'))
cookie = self.headers.get('cookie')
self.sapisid = sapisid_from_cookie(cookie)
except KeyError:
raise Exception("Your cookie is missing the required value __Secure-3PAPISID")
Expand Down

0 comments on commit 0cefc97

Please sign in to comment.