mpratt / Embera

A Oembed consumer library, that gives you information about urls. It helps you replace urls to youtube or vimeo for example, with their html embed code. It has advanced features like offline support, responsive embeds and caching support.
MIT License
335 stars 59 forks source link

fix: playlist API URL support for SoundCloud #94

Closed matzeeable closed 2 years ago

matzeeable commented 2 years ago

The oEmbed provder of SoundCloud also supports playlist URLs from api.soundcloud.com:

Reproduce:

  1. Navigate to https://soundcloud.com/search/sets?q=playlist
  2. Pick any playlist, e.g. https://soundcloud.com/billieeilish/sets/playlist
  3. Click on share and copy the "Embed" code

The embed code looks like this:

<iframe width="100%" height="300" scrolling="no" frameborder="no" allow="autoplay" src="https://w.soundcloud.com/player/?url=https%3A//api.soundcloud.com/playlists/336397030&color=%23ff5500&auto_play=true&hide_related=false&show_comments=true&show_user=true&show_reposts=false&show_teaser=true&visual=true"></iframe><div style="font-size: 10px; color: #cccccc;line-break: anywhere;word-break: normal;overflow: hidden;white-space: nowrap;text-overflow: ellipsis; font-family: Interstate,Lucida Grande,Lucida Sans Unicode,Lucida Sans,Garuda,Verdana,Tahoma,sans-serif;font-weight: 100;"><a href="https://soundcloud.com/billieeilish" title="Billie Eilish" target="_blank" style="color: #cccccc; text-decoration: none;">Billie Eilish</a> · <a href="https://soundcloud.com/billieeilish/sets/playlist" title="playlist" target="_blank" style="color: #cccccc; text-decoration: none;">playlist</a></div>

From the embed URL we can extract the API url https://api.soundcloud.com/playlists/336397030 and pass it to the oEmbed provider:

https://soundcloud.com/oembed?format=json&url=https://api.soundcloud.com/playlists/336397030

image

mpratt commented 2 years ago

Thanks for the PR!