You are here: Home » Topic » Option to create dynamic playlists?

Option to create dynamic playlists?

This topic contains 2 replies, has 1 voice, and was last updated by  msalerno 10 years, 11 months ago.

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #857

    msalerno

    mt-daapd 0.2.4
    Gentoo

    Is there a way to create dynamic playlists with Artist, Album or any other attribute?

    For example, we can create a playlist by specifying:

    "Beck" {
    Artist is "Beck"
    }

    But, is there a way to do it with something like:

    $ARTIST {
    Artist is $ARTIST
    }

    I don’t see anything like that in the docs.

    Is it possible?

    #7701

    fizze
    Participant

    seeing as 0.2.4 is rather old, Id suggest you upgrade to one of the nightlies, especially since the ‘smart’ playlist handling has changed quite a bit.

    Your request is kinda intriguing though. 🙂

    With $ARTIST the request seems rather silly tbh, because one can just browse by artist, assuming you use a soundbridge…?

    Or maybe Im just getting it all plain wrong. 😉

    #7702

    msalerno

    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.

    Thanks

    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:
    ./playlist.pl /media/music/ ARTIST > /etc/mt-daapd.playlist
    or
    ./playlist.pl /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. ./playlist.pl /media/mp3 ARTISTn";
    exit;
    }

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

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

    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";
    }
Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.