[GH-ISSUE #247] get_liked_songs Errorring Out #191

Closed
opened 2026-02-27 22:08:31 +03:00 by kerem · 1 comment
Owner

Originally created by @oraqol on GitHub (Dec 19, 2021).
Original GitHub issue: https://github.com/sigma67/ytmusicapi/issues/247

I've been using ytmusicapi for the last few days, scraping some data music.youtube.com. Working great for a few days, yesterday it began to error out. I went into the offending module and added the following print statement to see what is being returned as a json string, but it only has a <Response [200]> where I imagine the payload should be. Any ideas? I tried flushing my browsers cookies and re-adding the headers, because before I did that the error returned a 403 Forbidden.

<Response [200]>
Traceback (most recent call last):
  File "yt_mover.py", line 16, in <module>
    liked_songs = yt.get_liked_songs(10000)
  File "/usr/local/lib/python3.8/dist-packages/ytmusicapi/mixins/library.py", line 185, in get_liked_songs
    return self.get_playlist('LM', limit)
  File "/usr/local/lib/python3.8/dist-packages/ytmusicapi/mixins/playlists.py", line 66, in get_playlist
    response = self._send_request(endpoint, body)
  File "/usr/local/lib/python3.8/dist-packages/ytmusicapi/ytmusic.py", line 139, in _send_request
    response_text = json.loads(response.text)
  File "/usr/lib/python3.8/json/__init__.py", line 357, in loads
    return _default_decoder.decode(s)
  File "/usr/lib/python3.8/json/decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/lib/python3.8/json/decoder.py", line 355, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)```


```  def _send_request(self, endpoint: str, body: Dict, additionalParams: str = "") -> Dict:
        body.update(self.context)
        if self.auth:
            origin = self.headers.get('origin', self.headers.get('x-origin'))
            self.headers["Authorization"] = get_authorization(self.sapisid + ' ' + origin)
        response = self._session.post(YTM_BASE_API + endpoint + YTM_PARAMS + additionalParams,
                                      json=body,
                                      headers=self.headers,
                                      proxies=self.proxies)
        print(response)
        #, json=body, headers=self.headers,  proxies=self.proxies)
        response_text = json.loads(response.text)
        if response.status_code >= 400:
            message = "Server returned HTTP " + str(```
Originally created by @oraqol on GitHub (Dec 19, 2021). Original GitHub issue: https://github.com/sigma67/ytmusicapi/issues/247 I've been using ytmusicapi for the last few days, scraping some data music.youtube.com. Working great for a few days, yesterday it began to error out. I went into the offending module and added the following print statement to see what is being returned as a json string, but it only has a ```<Response [200]>``` where I imagine the payload should be. Any ideas? I tried flushing my browsers cookies and re-adding the headers, because before I did that the error returned a ```403 Forbidden```. ``` python yt_mover.py <Response [200]> Traceback (most recent call last): File "yt_mover.py", line 16, in <module> liked_songs = yt.get_liked_songs(10000) File "/usr/local/lib/python3.8/dist-packages/ytmusicapi/mixins/library.py", line 185, in get_liked_songs return self.get_playlist('LM', limit) File "/usr/local/lib/python3.8/dist-packages/ytmusicapi/mixins/playlists.py", line 66, in get_playlist response = self._send_request(endpoint, body) File "/usr/local/lib/python3.8/dist-packages/ytmusicapi/ytmusic.py", line 139, in _send_request response_text = json.loads(response.text) File "/usr/lib/python3.8/json/__init__.py", line 357, in loads return _default_decoder.decode(s) File "/usr/lib/python3.8/json/decoder.py", line 337, in decode obj, end = self.raw_decode(s, idx=_w(s, 0).end()) File "/usr/lib/python3.8/json/decoder.py", line 355, in raw_decode raise JSONDecodeError("Expecting value", s, err.value) from None json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)``` ``` def _send_request(self, endpoint: str, body: Dict, additionalParams: str = "") -> Dict: body.update(self.context) if self.auth: origin = self.headers.get('origin', self.headers.get('x-origin')) self.headers["Authorization"] = get_authorization(self.sapisid + ' ' + origin) response = self._session.post(YTM_BASE_API + endpoint + YTM_PARAMS + additionalParams, json=body, headers=self.headers, proxies=self.proxies) print(response) #, json=body, headers=self.headers, proxies=self.proxies) response_text = json.loads(response.text) if response.status_code >= 400: message = "Server returned HTTP " + str(```
kerem closed this issue 2026-02-27 22:08:32 +03:00
Author
Owner

@sigma67 commented on GitHub (Dec 20, 2021):

Not sure what the issue is here, seems like you aren't properly authenticated since the first errors were 403s. There's no parsing problems with get_liked_songs for me. Can you repeat the setup procedure to see if that fixes it?

<!-- gh-comment-id:997749827 --> @sigma67 commented on GitHub (Dec 20, 2021): Not sure what the issue is here, seems like you aren't properly authenticated since the first errors were 403s. There's no parsing problems with `get_liked_songs` for me. Can you repeat the setup procedure to see if that fixes it?
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/ytmusicapi#191
No description provided.