diff options
Diffstat (limited to 'app-misc/ds-scripts/files/m3u')
-rwxr-xr-x | app-misc/ds-scripts/files/m3u | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/app-misc/ds-scripts/files/m3u b/app-misc/ds-scripts/files/m3u new file mode 100755 index 0000000..e5496a5 --- /dev/null +++ b/app-misc/ds-scripts/files/m3u @@ -0,0 +1,48 @@ +#! /bin/bash + +if [ -z "$1" ] +then + echo "Usage: m3u [ -f encoding -p encoding ] <playlist.m3u> [random]" + exit +fi + +if [ "$2" = "random" ] +then + prm="-Z -z" +else + prm="" +fi + +FSE=`cat /etc/m3u.conf | grep FSEncoding | sed s/'^[ \t]*FSEncoding[ \t]*=[ \t]*'//g | sed s/'[ \t]*'$//g` +PLE=`cat /etc/m3u.conf | grep PLEncoding | sed s/'^[ \t]*PLEncoding[ \t]*=[ \t]*'//g | sed s/'[ \t]*'$//g` + +pl=1 +while getopts 'f:p:' OPT; do + pl=`expr $pl + 2` + case $OPT in + f) + FSE=$OPTARG + ;; + p) + PLE=$OPTARG + ;; + esac +done + + +pl=`eval echo "\\$${pl}"` + +if [ -z "$FSE" -o -z "$PLE" ]; then + cmd="cat \"$pl\"" +else + cmd="cat \"$pl\" | iconv -f $PLE -t $FSE" +fi + +s=$(eval $cmd | grep -E "\.[mMoOwW][pPgGaA][23gGvV]" | sed s/
//g | sed s/'\\'/'\/'/g | sed s/^/\"/ | sed s/$/\"/ | perl -pi -e 's|\n| |gs' ) + +if [ -n "$prm" ] +then + eval mpg123 $prm "$s" +else + eval zinf "$s" +fi |