Open noplanman opened 5 years ago
Hi there, Funkwhale maintainer here!
The fact is that Funkwhale's web interface is a Single Page Application written in javascript. Thus, you cannot request the pages from the command line (or non-javascript web clients) and extract content from it.
However, you can extract the IDs in the URL and query the Funkwhale API directly to extract download urls.
Example: https://demo.funkwhale.audio/api/v1/albums/13/, which yield the following data:
{
"id": 13,
"mbid": null,
"title": "The Slip",
"release_date": null,
"cover": {},
"creation_date": "2018-10-21T00:11:22.683442Z",
"is_playable": true,
"artist": {
"id": 12,
"mbid": null,
"name": "Nine Inch Nails",
"creation_date": "2018-10-23T07:01:31.518110Z"
},
"tracks": [
{
"id": 70,
"mbid": null,
"title": "999,999",
"album": 13,
"artist": {
"id": 12,
"mbid": null,
"name": "Nine Inch Nails",
"creation_date": "2018-10-23T07:01:31.518110Z"
},
"creation_date": "2018-10-23T07:01:31.522321Z",
"position": 1,
"is_playable": true,
"listen_url": "/api/v1/listen/968dc9ac-0bbf-4d3b-b4b5-2274f2448044/",
"duration": 85
},
{
"id": 71,
"mbid": null,
"title": "1,000,000",
"album": 13,
"artist": {
"id": 12,
"mbid": null,
"name": "Nine Inch Nails",
"creation_date": "2018-10-23T07:01:31.518110Z"
},
"creation_date": "2018-10-23T07:01:31.604775Z",
"position": 2,
"is_playable": true,
"listen_url": "/api/v1/listen/4ec0c646-1de3-468b-9802-08a25b456c7d/",
"duration": 236
}
]
}
The important bit for each track is the listen_url
which returns the audio file for playback.
We also have a /api/v1/tracks/
endpoint which returns track data dir. Example for a single track: https://demo.funkwhale.audio/api/v1/tracks/12/.
To download all the discography of an artist, you can filter albums using the artist ID: https://demo.funkwhale.audio/api/v1/albums/?artist=1
@EliotBerriot Perfect to have such a simple and easy to use API!
How does one know (with just the plain HTML) that it is a Funkwhale instance?
@noplanman I don't see an easy way right now, but we could easily add a meta tag in the Single Page App HTML, like <meta name="app" content="Funkwhale">
, if it's something youtube-dl can use for detection?
Something like that will probably be necessary, but as I'm no youbube-dl dev, there might be a different / better way.
Let's wait for a knowledgable person to read these lines... :wink:
As of version 0.18 (to be released next week) a Funkwhale server will output microdata on artist, album on track pages. Example for https://open.audio/library/tracks/40389:
<meta content="https://open.audio/library/tracks/40389" property="og:url" />
<meta content="Dead Inside" property="og:title" />
<meta content="music.song" property="og:type" />
<meta property="music:album:disc" />
<meta content="4" property="music:album:track" />
<meta content="https://open.audio/library/artists/93" property="music:musician" />
<meta content="https://open.audio/library/albums/6078" property="music:album" />
<meta content="https://open.audio/media/__sized__/albums/covers/2018/12/29/b28a4232e-9a64-45a2-93cf-046454d6bbb8-crop-c0-5__0-5-400x400-70.jpg" property="og:image" />
<meta content="https://open.audio/api/v1/listen/155c966f-e733-4b08-85c3-3b8b57f4c117/" property="og:audio" />
<link href="https://open.audio/api/v1/oembed/?format=json&url=https%3A%2F%2Fopen.audio%2Flibrary%2Ftracks%2F40389" rel="alternate" type="application/json+oembed" />
<meta content="Open.Audio - Funkwhale" property="og:site_name" />
<meta content="Libre Music from the Commons" property="og:description" />
Especially, the og:audio
tag will give you the audio file.
Using this data, we can probably easily support downloading individual files and full albums. I'd be happy to work on a generic youtube-dl extractor that supports music microformat (thus would be working not only with Funkwhale), but I'm not sure how to proceed.
BTW, just wanting to say thanks to @EliotBerriot. Great, how you support the integration into youtube-dl here and even offer to write a PR!
Make sure you are using the latest version: run
youtube-dl --version
and ensure your version is 2018.10.05. If it's not, read this FAQ entry and update. Issues with outdated version will be rejected.Before submitting an issue make sure you have:
What is the purpose of your issue?
Purpose of this issue is a site support request
Funkwhale
https://funkwhale.mastodon.host/library/tracks/4821
https://funkwhale.mastodon.host/library/albums/1120
https://funkwhale.mastodon.host/library/artists/845
youtube-dl
Falls back to generic and fails.Description of your issue, suggested solution and other information
Related to #16301, as PeerTube is also a project from the Fediverse.