Answers:
这是@chronitis答案,但有一些改进:
命令
playlist='play.m3u' ; if [ -f $playlist ]; then rm $playlist ; fi ; for f in *.mp3; do echo "$(pwd)/$f" >> "$playlist"; done
也可以在命令行上使用mplayer播放
mplayer -playlist play.m3u
这个bash脚本可以完成以下任务:
rawurlencode() {
local string="${1}"
local strlen=${#string}
local encoded=""
local pos c o
for (( pos=0 ; pos<strlen ; pos++ )); do
c=${string:$pos:1}
case "$c" in
[-_.~a-zA-Z0-9] ) o="${c}" ;;
* ) printf -v o '%%%02x' "'$c"
esac
encoded+="${o}"
done
echo "${encoded}"
}
rm -rf p.m3u
for f in *.mkv; do echo "#EXTINF:-1,SR:$f
http://10.0.0.144/tvtmp/"$(rawurlencode $f) >> p.m3u;
done
sed -i '1s/^/#EXTM3U\n/' p.m3u
rm -rf l.m3u
for f in *.mkv; do echo "#EXTINF:-1,SR:$f
http://127.0.0.1/tvtmp/$f" >> l.m3u;
done
sed -i '1s/^/#EXTM3U\n/' l.m3u
更发达的版本。该URL以正确的.m3u
样式编码。