summaryrefslogtreecommitdiffstats
path: root/app-misc/ds-scripts/files/m3u
blob: e5496a5e625441cff39807b2fcb84bba7b4c187c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
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