use CaseInsensitiveDict for headers
This commit is contained in:
parent
afad9d2933
commit
0cefc97d87
2 changed files with 5 additions and 5 deletions
|
|
@ -203,7 +203,7 @@ class UploadsMixin:
|
|||
+ ', '.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)
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
@ -74,15 +75,14 @@ class YTMusic(BrowsingMixin, WatchMixin, ExploreMixin, LibraryMixin, PlaylistsMi
|
|||
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(
|
||||
|
|
@ -120,7 +120,7 @@ class YTMusic(BrowsingMixin, WatchMixin, ExploreMixin, LibraryMixin, PlaylistsMi
|
|||
# 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")
|
||||
|
|
|
|||
Loading…
Reference in a new issue