You are not logged in.

#1 2009-06-25 15:10:16

geoisis
Member
From: greece
Registered: 2007-09-02
Posts: 100
Website

Mpd recently added tracks playlist ?

does anyone know how to make an recently added tracks playlist in mpd, sonata etc?
thanx smile


Archlinux x86_64 | post-engineering | last.fm

Offline

#2 2009-07-09 10:46:37

jensvejmand
Member
Registered: 2008-06-10
Posts: 3

Re: Mpd recently added tracks playlist ?

I can't really help you out, but I'm interested in this feature as well.

Offline

#3 2009-07-09 17:52:29

patogen
Member
Registered: 2008-05-11
Posts: 86

Re: Mpd recently added tracks playlist ?

If your filename(s) doesn't contain any spaces or "weird" signs, the following will work:

grep added ~/.mpd/mpd.log | tail -n 10 | awk '{print $6}' | mpc add   

replace ~/.mpd/mpd.log with your logfile and replace 10 with the number of songs to add.

Edit: Fixed

Last edited by patogen (2009-07-09 18:03:37)


We met up with the aliens and guess what? They have no word for fluffy!

Offline

#4 2009-07-10 10:51:59

Morra
Member
Registered: 2008-05-16
Posts: 39

Re: Mpd recently added tracks playlist ?

awk '{if ($5=="added") {sub(".*added ",""); line++; list[line]=$0}} END {for (i=line-10; i<line ;i++) {print list[i]}}' mpd.log | mpc add

I tried to remake patogen's script without using tail or grep commands (just for fun). This script should also be more tolerable with special characters.

Offline

#5 2011-05-16 21:33:20

tladuke
Member
Registered: 2009-07-23
Posts: 176

Re: Mpd recently added tracks playlist ?

just used this:

find . -type f -mtime -1  |egrep '\.mp3$|\.flac$' | awk '{ sub(/^\./, "audio"); print }'  | mpc add

this is assuming one of you mpd directories is 'audio' and you are in that directory. It doesn't choke on weird characters, so maybe mpc changed something in the last few years (sorry for necrobump...)


this gets songs added today, but can anyone show a better way to cut out the file name?

egrep "`date '+%b %d '`" log | grep added | cut -d':' -f4 | cut -d' ' -f3-100

Last edited by tladuke (2011-05-16 21:54:43)

Offline

#6 2012-01-25 07:02:30

imchairmanm
Member
Registered: 2009-09-26
Posts: 13

Re: Mpd recently added tracks playlist ?

Sorry for resurrecting a dead topic, but I was searching all night for this thread because I'd remembered seeing it before.  Because of the directory structure in my music folder (as far as I can tell), none of these were working for me.  So I took a bit of a shortcut and made myself a script to manually create a playlist file in the correct format instead of trying to get mpc to add songs to the current playlist.   I used everyone else's work for this, especially tladuke.  But if anyone else is looking for this solution, I just put this in a file:

#!/bin/bash

cd /path/to/your/music/directory && find . -type f -mtime -1  | egrep '\.mp3$|\.flac$' | awk '{ sub(/^\.\//, ""); print }' > /path/to/mpd/playlists/directory/newmusic.m3u

That'll create a playlist called newmusic, which you can then play.  Obviously replace those with your own music directory and playlist directory.  I'm not great with this stuff, but that ended up working perfectly for me.  YMMV.

Offline

Board footer

Powered by FluxBB