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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
| #!/bin/bash
print_help_msg () {
echo "You see, I'm nothing ."
exit 0
}
check_param () {
if [ $# -ne 1 ]; then
print_help_msg
fi
}
check_m3u () {
if ! [ -a p.m3u ] || [ `wc -l p.m3u|awk '{ print $1 }'` -eq 0 ]; then
echo '#EXTM3U' > p.m3u
fi
}
check_param $*
check_m3u
export LC_ALL=en_US.UTF-8
ue=$(php -r "echo urlencode('$1');")
parser="http://www.flvcd.com/parse.php?flag=&format=&kw=$ue&sbt=%BF%AA%CA%BCGO%21"
if ! wget $parser -U mozilla -O meta.html ; then
echo "Unable to touch the parser, check network status for the cause ."
exit 0
fi
grep "<N>" meta.html > title.lst
grep "<U>" meta.html > url.lst
iconv -f gbk -t utf-8 title.lst -o title.lst
sed -i 's/<N>//g' title.lst
sed -i 's/ //g' title.lst
sed -i 's/<U>//g' url.lst
l1=`wc -l title.lst|awk '{ print $1 }'`
l2=`wc -l url.lst|awk '{ print $1 }'`
if [ "$l1" != "$l2" ]; then
echo "Title.lst has $l1 lines, but url.lst got $l2."
exit 0
fi
if [ $l1 -eq 0 ]; then
echo "Nothing got from the parser, check meta.html for detail info."
exit 0
fi
arrTitle=(`cat title.lst`)
arrURL=(`cat url.lst`)
idx=$((`wc -l p.m3u|awk '{ print $1 }'`-1))
while [ $idx -lt $l1 ]; do
title=${arrTitle[$idx]}
url=${arrURL[$idx]}
idx=$((idx+1))
if ! wget $url -U mozilla -O "${title}.flv" ; then
echo "Failed fetching ${title}.flv, maybe its URL has been changed !"
exit 0
fi
cmd="sed -i '\$a\\${title}.flv' p.m3u"
eval $cmd
done
echo 'done !'
exit 0
|