You are here: Home » Reply

Reply To: Option to create dynamic playlists?



No, my request might be silly, I am still new to this, so it’s entirely possible.

I prefer to see lists broken down. True you can sort by artist and album, but it would be nice to create a playlist for an artist or for an album.

I’ll check out a newer version.


I wrote a quick script to take care of that, I’m not sure if it’s usefull. It prints the playlist to the stdout.

You will need to install the MP3::Info perl module before you can use the script.

Just: # cpan install MP3::Info

So I can currently:
./ /media/music/ ARTIST > /etc/mt-daapd.playlist
./ /media/music/ ALBUM > /etc/mt-daapd.playlist

#!/usr/bin/perl -w
use strict;
use MP3::Info;

my %playlistdata;

unless (@ARGV && @ARGV == 2){
print "Please specify the path and attributen";
print "ex. ./ /media/mp3 ARTISTn";

unless (-d $ARGV[0]){
print "Invalid directory given: $ARGV[0]n";

unless ( $ARGV[1] eq "ARTIST" || $ARGV[1] eq "ALBUM" ){
print "Invalid attrib given $ARGV[1]n";
print "Specify either ARTIST or ALBUMn";

chomp(my @mp3s = `find $ARGV[0] -iname *.mp3`);
die "There was an error with the find commandn" if $? != 0;;

foreach my $mp3 (@mp3s){
my $tag = get_mp3tag($mp3) or next;
$playlistdata{$tag->{$ARGV[1]}} = $tag->{"ARTIST"} if !$playlistdata{$tag->{$ARGV[1]}};

foreach my $data (keys %playlistdata){
print qq|"$data" { $ARGV[1] is "$data" }n| if $ARGV[1] eq "ARTIST";
print qq|"$data - $playlistdata{$data}" { $ARGV[1] is "$data" }n| if $ARGV[1] eq "ALBUM";