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))
|
+ ', '.join(supported_filetypes))
|
||||||
|
|
||||||
headers = self.headers.copy()
|
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)
|
filesize = os.path.getsize(filepath)
|
||||||
body = ("filename=" + ntpath.basename(filepath)).encode('utf-8')
|
body = ("filename=" + ntpath.basename(filepath)).encode('utf-8')
|
||||||
headers.pop('content-encoding', None)
|
headers.pop('content-encoding', None)
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
import requests
|
import requests
|
||||||
import gettext
|
import gettext
|
||||||
import os
|
import os
|
||||||
|
from requests.structures import CaseInsensitiveDict
|
||||||
from functools import partial
|
from functools import partial
|
||||||
from contextlib import suppress
|
from contextlib import suppress
|
||||||
from typing import Dict
|
from typing import Dict
|
||||||
|
|
@ -74,15 +75,14 @@ class YTMusic(BrowsingMixin, WatchMixin, ExploreMixin, LibraryMixin, PlaylistsMi
|
||||||
self.proxies = proxies
|
self.proxies = proxies
|
||||||
|
|
||||||
# prepare headers
|
# prepare headers
|
||||||
self.headers = {}
|
|
||||||
if auth:
|
if auth:
|
||||||
try:
|
try:
|
||||||
if os.path.isfile(auth):
|
if os.path.isfile(auth):
|
||||||
file = auth
|
file = auth
|
||||||
with open(file) as json_file:
|
with open(file) as json_file:
|
||||||
self.headers = json.load(json_file)
|
self.headers = CaseInsensitiveDict(json.load(json_file))
|
||||||
else:
|
else:
|
||||||
self.headers = json.loads(auth)
|
self.headers = CaseInsensitiveDict(json.loads(auth))
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(
|
print(
|
||||||
|
|
@ -120,7 +120,7 @@ class YTMusic(BrowsingMixin, WatchMixin, ExploreMixin, LibraryMixin, PlaylistsMi
|
||||||
# verify authentication credentials work
|
# verify authentication credentials work
|
||||||
if auth:
|
if auth:
|
||||||
try:
|
try:
|
||||||
cookie = self.headers.get('cookie', self.headers.get('Cookie'))
|
cookie = self.headers.get('cookie')
|
||||||
self.sapisid = sapisid_from_cookie(cookie)
|
self.sapisid = sapisid_from_cookie(cookie)
|
||||||
except KeyError:
|
except KeyError:
|
||||||
raise Exception("Your cookie is missing the required value __Secure-3PAPISID")
|
raise Exception("Your cookie is missing the required value __Secure-3PAPISID")
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue