Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Export playlists via API #908

Closed
haeringer opened this issue Oct 20, 2021 · 2 comments
Closed

Export playlists via API #908

haeringer opened this issue Oct 20, 2021 · 2 comments

Comments

@haeringer
Copy link

I would like to export playlists via API on a regular basis in order to throw them onto a local NAS which is read by a Sonos system. Having automatic playlist backups in an open format (m3u) would be a nice side effect.

The proprietary API endpoint /api/playlists/{id}/export seems to work only if called from the UI, so I tried the Subsonic endpoint /subsonic/rest/getPlaylist and wanted to write the file paths from the API output into an m3u file, but the path key (which seems to be present in the original API, see example) is missing from the owncloud/music variant of the Subsonic API:

<?xml version="1.0" encoding="UTF-8"?>
<subsonic-response status="ok" version="1.16.1">
    <playlist id="2" name="Test" owner="Me" public="false" songCount="69" duration="21011" comment="" created="2021-10-20T11:54:02.000Z" changed="2021-10-20T11:57:08.000Z" coverArt="pl-2">
        <entry id="track-9320" parent="album-6347" title="Me, I'm Not" artist="Nine Inch Nails" isDir="false" album="Year Zero" year="2007" size="11682353" contentType="audio/mpeg" suffix="mp3" duration="292" bitRate="320" isVideo="false" albumId="album-6347" artistId="artist-12277" type="music" created="2021-10-19T21:22:54.000Z" track="64" genre="Electronica" coverArt="album-6347"/>
        [...]
    </playlist>
</subsonic-response>

Is there any other method to get the file paths programmatically or to export playlists? I have seen issue #832 and that would also solve my problem, but maybe including the file path in the getPlaylist Subsonic API response would be a quick solution for at least enabling users to do the export/sync themselves (can't estimate the effort).

@paulijar
Copy link
Collaborator

I can't think of any way to solve your use case with the currently available API.

Adding the path property to the songs returned by the Subsonic API has been on my to-do list but not with a very high priority, as I haven't seen any use case for it before. The reason, it has been left out at this time, is the potential performance implications: the straight forward way for the Music app to get the path would be to use the API provided by the cloud core. But this would need to be called separately for each song returned, and it could slow down a lot such method calls which return a large set of songs. On the other hand, we could bypass the cloud core API and get all the needed paths with a single DB query, but that works easily only for the files in the default storage; any external storages and files shared by other users would be a problem for this solution.

The best solution would probably be to intelligently combine some use of the proper file API and direct DB queries. We are already doing something like this to implement the Folders view on the web UI. But this is quite delicate business which requires careful implementation and testing.

So in the end, it would probably be easier to just add the occ command which could export the playlist to a file. This should be rather straight forward task.

@haeringer
Copy link
Author

Thank you for the detailed explanations, this is very helpful.

So I'll close this in favor of #832.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants