MPC Playlist Handler

One tiny problem I found with MPC is that it didn't integrate as nicely with Firefox/Opera as I would wish, for example when I download a .m3u or .pls file I can't have the streams it points to added to the MPC playlist.

So the solution is:

#!/bin/bash
if [ -z "$1" ]; then
  echo "Usage: `basename $0` " > /dev/sdterr
  exit
fi

url=$1
# Presumed to be a remote URL
if [ ! -f "$1" ]; then
  tmpfile=`mktemp`
  wget --quiet -O "$tmpfile" "$1" && url=$tmpfile
fi

if [ ! -f "$url" ]; then
  echo "Error: cannot retrieve playlist" > /dev/stderr
  exit
fi

cat $url | grep -E '^File' | cut -f 2 -d '=' | xargs mpc add 

Takes either a local file or a URL to the playlist as the first parameter and adds all streams/files to the MPC playlist.


Leave a Reply



About

Harry is a professional developer and sysadmin from London, UK.

He's an atheist, employed at PixelMags LLC, a socialist and has a pragmatic outlook on life, love and religion.

Bookmarks

I'm constantly finding interesting stuff, here are some of the things I've bookmarked recently:

HarryR on Faves.com