error proofing for new setup/init
This commit is contained in:
parent
048f17989a
commit
650f0a220d
4 changed files with 7 additions and 4 deletions
|
|
@ -1,4 +1,4 @@
|
|||
YTM_DOMAIN = 'https://music.youtube.com/'
|
||||
YTM_BASE_API = YTM_DOMAIN + 'youtubei/v1/'
|
||||
YTM_DOMAIN = 'https://music.youtube.com'
|
||||
YTM_BASE_API = YTM_DOMAIN + '/youtubei/v1/'
|
||||
YTM_PARAMS = '?alt=json&key=AIzaSyC9XL3ZjWddXya6X74dJoCTL-WEYFDNX30'
|
||||
USER_AGENT = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:88.0) Gecko/20100101 Firefox/88.0'
|
||||
|
|
|
|||
|
|
@ -410,7 +410,7 @@ class BrowsingMixin:
|
|||
:return: browseId (starting with `MPREb_`)
|
||||
"""
|
||||
params = {"list": audioPlaylistId}
|
||||
response = self._send_get_request(YTM_DOMAIN + "playlist", params)
|
||||
response = self._send_get_request(YTM_DOMAIN + "/playlist", params)
|
||||
matches = re.findall(r"\"MPRE.+?\"", response)
|
||||
browse_id = None
|
||||
if len(matches) > 0:
|
||||
|
|
|
|||
|
|
@ -23,6 +23,8 @@ def setup(filepath=None, headers_raw=None):
|
|||
user_headers = {}
|
||||
for content in contents:
|
||||
header = content.split(': ')
|
||||
if len(header) == 1: # nothing was split
|
||||
continue
|
||||
user_headers[header[0]] = ': '.join(header[1:])
|
||||
|
||||
except Exception as e:
|
||||
|
|
|
|||
|
|
@ -113,7 +113,8 @@ class YTMusic(BrowsingMixin, WatchMixin, LibraryMixin, PlaylistsMixin, UploadsMi
|
|||
# verify authentication credentials work
|
||||
if auth:
|
||||
try:
|
||||
self.sapisid = sapisid_from_cookie(self.headers['Cookie'])
|
||||
cookie = self.headers.get('cookie', self.headers.get('Cookie'))
|
||||
self.sapisid = sapisid_from_cookie(cookie)
|
||||
except KeyError:
|
||||
raise Exception("Your cookie is missing the required value __Secure-3PAPISID")
|
||||
self._send_request('guide', {})
|
||||
|
|
|
|||
Loading…
Reference in a new issue