Page 1 of 2

Playlist Export Script

PostPosted: Tue Aug 20, 2013 5:30 pm
by flat-herc
Hi,
i've build a small Java Application to export all my Subsonic playlists to m3u files on my fileshare. Seen that many guys are searching for such a script so i've attached the code. If you call the Script via Console without Parameters, you'll get a small help. Some parts of the code are dirty hack, but it works ;) In line 57 i'm just modifying the path, as the path is different when i access the playlist via fileshare. I've outcommented this part but you can edit it as you want to.

Greetings
flat-herc

Re: Playlist Export Script

PostPosted: Tue Aug 20, 2013 5:51 pm
by daneren2005
I'm going to have to try this on a daily cron job. Thanks for sharing!

Re: Playlist Export Script

PostPosted: Tue Aug 20, 2013 10:39 pm
by flat-herc
Pretty much the same what i'am doing with it. I'm using a Cron Job to serve my DLNA Server with the playlist files.

Had some issues with Character Encoding (as always :evil: ). Fixed it in the attached file.

Re: Playlist Export Script

PostPosted: Thu Oct 31, 2013 1:15 am
by Jägs
Pardon my ignorance, but how does one "run" this? I tried doing:

Code: Select all
java SubsonicPlaylistExporterWeb.java


but I received an error:

Code: Select all
Exception in thread "main" java.lang.NoClassDefFoundError: SubsonicPlaylistExporterWeb/java
Caused by: java.lang.ClassNotFoundException: SubsonicPlaylistExporterWeb.java
   at java.net.URLClassLoader$1.run(URLClassLoader.java:217)
   at java.security.AccessController.doPrivileged(Native Method)
   at java.net.URLClassLoader.findClass(URLClassLoader.java:205)
   at java.lang.ClassLoader.loadClass(ClassLoader.java:321)
   at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294)
   at java.lang.ClassLoader.loadClass(ClassLoader.java:266)
Could not find the main class: SubsonicPlaylistExporterWeb.java. Program will exit.


What am I doing wrong? I'm running Subsonic on Ubuntu 13.04, if that helps.

Re: Playlist Export Script

PostPosted: Mon Nov 04, 2013 10:37 pm
by flat-herc
You have to compile it first with:
Code: Select all
javac SubsonicPlaylistExporterWeb.java


Then you can run it with
Code: Select all
java SubsonicPlaylistExporterWeb

Re: Playlist Export Script

PostPosted: Tue Nov 05, 2013 1:55 am
by Jägs
Brilliant! It worked! I am now happily rebuilding playlists, hopefully for the last time. Thanks!

Re: Playlist Export Script

PostPosted: Fri Dec 27, 2013 2:23 am
by tsquillario
Thanks for this! Trying to get my playlists into XBMC.

Re: Playlist Export Script

PostPosted: Sun Jan 12, 2014 4:50 pm
by unimatrix27
Hi,

how exactly do i give as argument the username/password? i have tried this:

java SubsonicPlaylistExporterWeb "http://192.168.2.2:4040/db.view?query=" myuser:mypass .

but I always get 401 error (no access)

i also wonder how the playlist is sorted. i have executed the query to db.view manually with the browser but the order of songs is not according to what i get in the subsonic user interface or the Android APP.

Re: Playlist Export Script

PostPosted: Sun Jan 12, 2014 5:55 pm
by flat-herc
The user:pass has to be in Base64. You can encode your username:Password String here: http://www.base64encode.org/
Haven't had any trouble with the sorting yet. The Sorting is just done by an ID within the Query at line 70.

Re: Playlist Export Script

PostPosted: Mon Jan 13, 2014 6:13 am
by unimatrix27
Hi,

ok the base64 encoding I should have realized that...thanks!

THe sorting is still a problem for me. When I move a track in a playlist e.g. from the last position to the second last position in the subsonic webif, this is obviously saved somewhere by Subsonic, because when I then update this playlist on my Android APP, the move of the song is reflected there.

However reexporting the list from the DB does not reflect the new sorting. Not really a problem of your script because as far as I have compared the DB the new sorting is not part of it! So I really start to wonder where this info is saved :(

I also tried the REST APi functions, but the same problem there. Which is even more strange as I thought the android app is also using it. I will look into it further...

Re: Playlist Export Script

PostPosted: Sat Feb 01, 2014 10:21 pm
by Octacon100
Thanks for this, it really saved me a lot of effort!

Re: Playlist Export Script

PostPosted: Sun Feb 23, 2014 3:26 pm
by Octacon100
Hi,

I've been able to edit the playlist exporter so that it will work on windows, and so that the exported playlists will work in itunes and windows media player.

The playlists are now exported with the songs in the same order that they are in on your subsonic server. With some other cmd scripts, perl scripts and auto hot key scripts, you can import the exported playlists into itunes. If anyone is interested in that code, let me know and I'll upload it.

Hope it helps!

Re: Playlist Export Script

PostPosted: Tue Jul 08, 2014 6:08 pm
by loubat
Octacon100 wrote:Hi,

I've been able to edit the playlist exporter so that it will work on windows, and so that the exported playlists will work in itunes and windows media player.

The playlists are now exported with the songs in the same order that they are in on your subsonic server. With some other cmd scripts, perl scripts and auto hot key scripts, you can import the exported playlists into itunes. If anyone is interested in that code, let me know and I'll upload it.

Hope it helps!

I'm totally inexperienced in java, and haven't done much command prompt work in years, I'm getting old! :) Ok, I'm getting errors when I try to run this from cmd, without the brackets inclduded:
java.io.IOException: Server returned HTTP response code: 401 for URL: http://192.168.2.5:4040/db.view?query=S ... 20PLAYLIST
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source)
at SubsonicPlaylistExporterWeb.executeQuery(SubsonicPlaylistExporterWeb.java:108)
at SubsonicPlaylistExporterWeb.main(SubsonicPlaylistExporterWeb.java:43)

With brackets I get:
java.net.MalformedURLException: no protocol

which I'm guessing is because I shouldn't be using the bracket, lol. Pretty embarrassing that I can't remember something simple like that. Help me out here, I'm clueless. I'm sure it's something simple...

Edit: Interesting workaround, I can see the Subsonic server in Mediamonkey, then save the playlist as an m3u. It's all links to streams from subsonic, rather than actual filepaths. That works fine for Winamp, but Sonos won't play it, which is really what I'm looking for. It sees the playlist, but doesn't recognize that there's any music in it.

Re: Playlist Export Script

PostPosted: Mon Aug 11, 2014 1:38 am
by madhusker
Looks like this is depreciated. :(

~/temp$ java SubsonicPlaylistExporterWeb "https://192.168.1.10:4141/subsonic/db.view?query=" YW5ksmV3:JGFzfDAx .
Exception in thread "main" java.lang.UnsupportedClassVersionError: SubsonicPlaylistExporterWeb : Unsupported major.minor version 51.0
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:643)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:277)
at java.net.URLClassLoader.access$000(URLClassLoader.java:73)
at java.net.URLClassLoader$1.run(URLClassLoader.java:212)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:205)
at java.lang.ClassLoader.loadClass(ClassLoader.java:323)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294)
at java.lang.ClassLoader.loadClass(ClassLoader.java:268)
Could not find the main class: SubsonicPlaylistExporterWeb. Program will exit.

Re: Playlist Export Script

PostPosted: Thu Nov 27, 2014 7:16 pm
by friendlyferret
Here's a friendly ammendment to the playlist exporter. This version accepts the username:password string in plaintext so that you don't have to encode it before you run the exporter. It requires Java 1.5 or greater.