mirror of
https://github.com/kokarare1212/librespot-python.git
synced 2026-04-25 08:35:49 +03:00
[GH-ISSUE #135] [BUG] Podcast episodes no longer load, missing external_playback_url in metadata #17
Labels
No labels
bug
dependencies
duplicate
enhancement
invalid
pull-request
question
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/librespot-python-kokarare1212#17
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @Yetangitu on GitHub (Jun 22, 2022).
Original GitHub issue: https://github.com/kokarare1212/librespot-python/issues/135
Since a few days it is no longer possible to download podcast episodes through librespot due to a missing metadata item (
external_playback_url):https://github.com/Yetangitu/Spodcast/issues/13
The problem is most likely caused by some missing scope or other authorisation-related item in the authorisation token, the question is - which? A similar problem seems to exist in the rust-based version (https://github.com/librespot-org/librespot/issues/818) where the absence of the required URL in the stream is also mentioned.
I do notice that the metadata returned by Spotify to the web based player is contradictory in that it claims an episode to not be externally hosted while serving an externally hosted stream:
This change seems to have taken place on or around the 16th of June since that is the last day things worked as intended.
I notice the token generated by the web player is quite a bit longer than the one generated by librespot suggesting it contains some extra authorisations missing from the latter. The question is, which?
@kokarare1212 commented on GitHub (Jun 22, 2022):
I think there is a good chance of that.
However, I think it is also important to note that the API endpoints used by librespot-python are different.
@Yetangitu commented on GitHub (Jun 22, 2022):
It used to work with the existing endpoints, now it no longer does - the endpoint still returns data but this no longer contains playable streams, only previews. Here's what used to be returned for Spotify-hosted podcasts:
API call to
https://api-partner.spotify.com/pathfinder/v1/query?operationName=getEpisode&variables={"uri":"spotify:episode:{epidodeId}"}...Notice the use of the
anon-podcast.scdn.codomain for serving these streams.Here's what used to be returned for externally-hosted podcasts:
Notice the last object in the array which contains an external url.
This is what is returned now for the same API call:
The domain used for podcast streams (anon-podcast.scdn.co) does not exist any more:
...so it does look like something has changed on Spotify's side. The returned data now only contains 'preview' URLs (which all return
HTTP/1.1 404 Not Foundwhen polled using the token from the web player, I guess these need special treatment in some way - are they Widevine-encumbered streams?). The actual playable stream has moved and is now found in the output fromGET /v1/episodes/{episodeId}, inexternal_playback_url. Switching out the token returned by librespot for the one returned by the web player makes this url appear in the output, this seems to be the only difference:Using a web player generated token:
The
external_playback_urlis playable without any further problems but... it only appears when using a web player provided token. Using a librespot generated token produces the same output minus the external_playback_url, i.e. it does not provide a playable stream.@kokarare1212 commented on GitHub (Jun 28, 2022):
Apparently Spotify had added something called ClientToken to use.
github.com/librespot-org/librespot-java@08b7890ed0@kokarare1212 commented on GitHub (Jun 28, 2022):
4c4c5642d7e97cf56343d6c385af3c64796711ea...560c5000a8c8509c028951b055efd8f93ff02d75
This commit should have fixed it.
@Yetangitu commented on GitHub (Jun 29, 2022):
It does not seem to work just yet, the
external_playback_urlis not returned when using a token generated by librespot-python while it is returned for exactly the same query when using one generated by the web client.Can these tokens be decoded to show which scopes they include? Tokens generated by the web client (344 characters) are noticeably longer than those generated by librespot-python (291 characters) so it stands to reason that the former include something which is missing from the latter.
@kokarare1212 commented on GitHub (Jun 29, 2022):
ApiClient#get_metadata_4_episode allows the use of external_url.
Other API endpoints have not been tested and are probably not implemented in upstream repositories.
@Yetangitu commented on GitHub (Jun 29, 2022):
I'll have a look at that endpoint.
By the way, the web client does not seem to use the
client-tokenheader:Still the data is returned when the web client-generated token is used while it is not when using a librespot-python generated one.
@kokarare1212 commented on GitHub (Jun 29, 2022):
Sorry, this library is targeted at native apps.
It is not intended to guarantee the operation of API endpoints for web clients.
The API endpoints that are currently working are not web endpoints, but endpoints inside TCP sockets.
So use ApiClient#get_metadata_4_episode to retrieve metadata.
@Yetangitu commented on GitHub (Jun 29, 2022):
OK. I'll refactor spodcast to use these endpoints
@Yetangitu commented on GitHub (Jun 30, 2022):
The original problem - not being able to download episodes - is now solved, I assume partly due to the inclusion of the
client-token, partly due to me refactoring spodcast to use librespot-python-provided API interfaces instead of raw web API access. Some problems remain to be fixed - e.g. there does not seem to be a way to get the total decrypted size (or 'disk file size', this in contrast to 'stream size') for a given file_id which makes it impossible to check whether a previously downloaded episode should be downloaded again. This is not related to this bug report so I'll close this one and open a request for information on that subject.@MikeeI commented on GitHub (Jul 6, 2022):
external_urlis missing for joe rogan podcasthttps://open.spotify.com/episode/0k503tOyovs71ddjCCfmHA@kokarare1212 commented on GitHub (Jul 6, 2022):
If
external_urlis not present,audiois used.github.com/kokarare1212/librespot-python@8ac9e6cf0d/librespot/audio/init.py#L751-L759