Page 1 of 1

Custom Random Playlists

PostPosted: Wed Jul 06, 2016 4:11 am
by cybersaga
I thought I'd share something I setup. I wanted random video playlists, which isn't supported out of the box in Serviio right now. So I setup something to do it for me. This will work for audio too.

I ended up writing a pretty basic program (Windows-only, .NET 4 required) to read all the files in a folder and put them all in random order into an m3u playlist file. Then I setup a scheduled task in Windows to run that every hour.

For anyone else wanting to set this up, I put the little program on GitHub. The exe can be downloaded here: ... ses/latest

In its simplest form, you run this:
Random.Playlist.exe [folder with files]

So for example, in my case I run (Yes, this is mainly for the kids):
Random.Playlist.exe "K:\Video\Baby Einstein"

That creates the file "K:\Video\Baby Einstein\Random Baby Einstein.m3u" with all the media files inside that folder listed. It will only include audio OR video files, but not both.

There are more options. For example, you can include several folders and search all subfolders. Here are all the options:
Random.Playlist.exe [-d folder1 folder2] [-p playlistName] [-r] [-t audio|video]
                    [-m maxLength] [-x types] [-i types] [-h]

  -d    A list of folders to include, separated by spaces.
        If this is not included, the current folder is used.
  -p    The name of the playlist file. If not specified,
        the playlist will be named after the first folder being searched,
        preceded by the word Random. e.g. Random Music.m3u
  -r    Recurse subfolders.
  -t    Specify whether to look for audio or video files. If not specified,
        the first file found will determine if it looks for audio or video
        files. e.g. If it comes across an audio file first, then only audio
        files will be included.
  -m    Limit the playlist to this many files.
  -x    A list of file extensions to exclude, separated by semicolons.
        e.g. -x m4a;wav
  -i    A list of file extensions to include, separated by semicolons.
        All other files will be ignored. e.g. -i mp3;m4a
  -h    Show this help screen

Set that up as a scheduled task in Windows to run, say, every hour, and Serviio will pick up the changes when they happen.

If you want to create multiple playlists, it's simpler to create a batch file and list each one:
Random.Playlist.exe "K:\Video\Baby Einstein"
Random.Playlist.exe "K:\Video\Signing TIme"
Random.Playlist.exe "K:\Video\Octonauts"

Then set up the scheduled task to run that batch file.

I hope this helps someone! I tried a *ton* of different DLNA server software, and Serviio fit my needs the best. This was the only feature I wanted that Serviio didn't have.

Re: Random Video Playlists

PostPosted: Wed Jul 06, 2016 1:46 pm
by jhb50
Great Idea. You should repost this in the 3rd Party Tools Integration section as a [TOOL], or send zip a note and ask him to move it, so it does not get lost in this support section. I'm thinking this could also be used for music and image playlists and would be very popular for random songs and random slideshows.

Re: Random Video Playlists

PostPosted: Wed Jul 06, 2016 2:25 pm
by cybersaga
Thanks, I sent him a note. I didn't notice that forum when I posted. Maybe I just didn't scroll down far enough :)

I'm thinking of developing this further into a general purpose command line playlist generator. I had done some searching, and I couldn't find any out there. There were several playlist generators with GUI's but nothing command line that I could setup as a scheduled task.

Right now it just dumps the file names into the m3u file, but later I might add the extended information (the "EXTM3U" and "EXTINF" lines). Serviio doesn't seem to care, but other programs might.

Re: Random Video Playlists

PostPosted: Fri Jul 08, 2016 2:25 am
by cybersaga
Turns out that it does work great with music files, and it's a good workaround for an existing problem between Serviio and Sony devices. See here: viewtopic.php?f=11&t=22190

Re: Custom Random Playlists

PostPosted: Wed Dec 21, 2016 10:55 pm
by Tedward
Thanks! I have been looking for a way to do this, it works perfectly! :D

Re: Custom Random Playlists

PostPosted: Fri Dec 23, 2016 3:23 pm
by DenyAll
Agree, nice app that works perfectly. I've come across it just in time to randomise about a gig's worth of Christmas carols/songs ready to drive the family crazy :lol:

Re: Custom Random Playlists

PostPosted: Fri Dec 23, 2016 3:31 pm
by cybersaga
My condolences to your family. :)

Re: Custom Random Playlists

PostPosted: Thu Nov 09, 2017 12:28 am
by utaaanaga
You can use this on linux

cd /media/Music/
find . -type f  -name "*.mp3" -o -name "*.ogg"  -name "*.flac" -o -name "*.wav" -name "*.m4a" |sort -R |head -n 100 > /media/Music/random.m3u