-
Notifications
You must be signed in to change notification settings - Fork 0
/
Radio_Caprice.sh
124 lines (87 loc) · 2.8 KB
/
Radio_Caprice.sh
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
#!/bin/bash
# Copyright 2018 David Hedlund
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
case "$1" in
""|-help)
[ "$1" = "" ] && echo "Usage: $filename [--option] [--debug]
OPTIONS
$0 --all
$0 --get-data
$0 --get-playlists
$0 --merge
" && exit 1
;;
--get-data)
mkdir build
cd build/ || exit
wget "http://radcap.ru/index-d.html" -O index-d.html
cp -a index-d.html 1.html
sed -i 's/.$//' 1.html # Remove carrige return
#tr -d '\r' test.html # Didn't work to remove the carrige returns for some reason
sed -i '/romance/{N;s/\n//;}
s| ||g
' 1.html
grep "\"genres\"" 1.html > 2.html
cp 2.html 3.html
sed -i "s|><a|>\n<a|g" 3.html
grep "\"genres\"" 3.html > 4.html
sed -i "s|> |>|
s|<span>||g
s|</span>||g
s|</a>||g
s|</td>||g
s|<br>||g
s|<a href=\"||g
s|.html||g
s|\" class=\"genres\">|\t|g
s|<img src=\"|\t|g
s|\" alt=\"|\t|g
s|\" width=\"200\"/>|\t|g
# R'N'B issue
s|<span class=\"genres\">||g
" 4.html
;;
--get-playlists)
cd build/ || exit
rm -fr playlists.txt
cp -a 4.html entries.txt
IFS=$'\n' # make newlines the only separator
for i in $(cat entries.txt); do
x1=$(echo $i | awk '{print $1}');
playlist=$(wget "http://radcap.ru/$x1.html" -qO- | grep "\.pls" | sed "s|\"|\n|g" | grep "\.pls");
echo $playlist
echo $playlist >> playlists.txt
done
;;
--merge)
IFS=$'\n' # make newlines the only separator
rm -f radio-droid.tsv
cd build/ || exit
paste -d '\t' entries.txt playlists.txt > all.txt
for i in $(cat all.txt); do
homepage=$(echo $i | awk -F '\t' '{print $1}');
name=$(echo $i | awk -F '\t' '{print $5}');
playlist_url=$(echo $i | awk -F '\t' '{print $6}');
list=$(echo -e "Radio Caprice - $name\t$playlist_url\thttp://radcap.ru/$homepage.html\thttp://radcap.ru/apple-touch-icon.png\tRussia\t\t\t$name")
echo "$list"
echo "$list" >> ../radio-droid.tsv
#echo $i | awk -F '\t' '{print $4}';
done
;;
--all)
$0 --get-data "$2"
$0 --get-playlists "$2"
$0 --merge "$2"
;;
esac