Simple shell script wrapper for mplayer +

    • xpasky disse...
    • Usuário
    • Fev 8 2008, 3h52

    Simple shell script wrapper for mplayer +

    I use the following simple script (as /usr/local/bin/m so I can write just 'm track.mp3') as mplayer wrapper that reports stuff to

    Hope it will be useful for someone else too. Linewrapped inline version follows ;-) :

    # Prerequisites:
    # * Get and setup
    # * perl -MCPAN -e 'install MP3::Info' (check your distro for perl-MP3-Info package first)
    # Install this script with some handy name, e.g. '/usr/local/bin/m'.
    # Known problems:
    # * 'q' interrupts only playback of current file; press and *hold* ctrl-C
    # * even if you skip file immediately with Enter or 'q', it gets scrobbled - see below
    # Song info will be submitted after you finish listening to the song;
    # if you are SKIPPING a track and don't want it to appear, press Ctrl-C
    # in mplayer - it will skip to the next track without scrobbling.

    kill -0 `cat /var/run/lastfm/` 2>&1 || lastfmsubmitd

    for f; do
    mplayer "$f" || continue

    case "$f" in
    perl -MMP3::Info -le \
    'my $f = $ARGV[0]; my $i = new MP3::Info $f;
    print $i->time; print $i->artist; print $i->album; print $i->title;' \
    "$f" |
    read time;
    read artist;
    read album;
    read title;
    [ "$album" = "1" ] && album=""
    echo "## Last.FM : -l \"$time\" -a \"$artist\" -b \"$album\" --title \"$title\""
    /usr/local/lib/lastfmsubmitd/lastfmsubmit \
    -l "$time" -a "$artist" -b "$album" --title "$title"

  • wonderful! thanks a lot. simple yet effective.

    • alex_pol disse...
    • Usuário
    • Jan 25 2009, 16h59
    i commented out "kill -0 `cat /var/run/lastfm/` 2>&1 || lastfmsubmitd" because lastfmsubmitd writes wrong pid. a bit better can be replacing that line with " ps aux | grep lastfmsubmitd | grep -v grep | cut -d " " -f 6 || lastfmsubmitd"

    • alex_pol disse...
    • Usuário
    • Jan 25 2009, 17h00
    btw, thanks for the script!

  • Just to let you know, i added m4a support and hosted your script at

    thx :)

    'never whistle while you're pissing!'
  • Thank you for this script.

    To satisfy its dependency, I prepared and submitting a lastfmsubmitd port in FreeBSD.

    I'm also considering to add a port for this script, but "lastfm" seems rather generic (e.g. I've a /home/dereckson/bin/lastfm script to print what a user is listening to or the last 10 titles).

    What would be the ideal name? lastfmplayer is rather obscure too, as the script launch mplayer and scrobble (some could expect from a a lastfmplayer command it allows to play radios).

    • GioMac disse...
    • Usuário
    • Mai 8 2011, 23h45
    aaaaaaaaaaa, you're a great crazy man, you know? might be funny windows guys, but we are high :D rules!
  • No Ogg Vorbis support?

    It would be helpful if this script could be modified to support free file formats such as Ogg Vorbis and FLAC.

Usuários anônimos não podem postar mensagens. É preciso fazer login ou criar uma conta para postar nos fóruns.