#!/bin/bash

# Work-around for the ugly URLs in mocp when playing m3u ?

LIST="$@"

for name in $(cat "$LIST" | sort)
do
basename "$name" \
| sed -s 's/\%20/ /g'\
| tr '_' ' ' >> /tmp/current
done

player ()
{
. f-colours
clear
bold
green
figlet m3u
echo
yellow
echo "This interface lets you read the playlist without extra characters..."
green
echo
echo "r: Read the playlist"
echo "p: Player Interface (mocp)"
echo "q: Back to the browser "
white

echo
read -s -n 1 NEXT
case $NEXT in
	r)
	less /tmp/current
	player
	;;
	p)
	mocp "$LIST"
	player
	;;
	q)
	rm -f /tmp/current
	exit
	;;
	*)
	player
	;;
esac

}

player

