1 | #!/bin/bash |
---|
2 | # box parser for titannit |
---|
3 | |
---|
4 | SRC=$1 |
---|
5 | INPUT=$2 |
---|
6 | PARAM=$3 |
---|
7 | URL="https://beeg.com/api/v5/" |
---|
8 | PARSER=`echo $SRC | tr '/' '\n' | tail -n1 | sed 's/.sh//'` |
---|
9 | NAME=`echo -n ${PARSER:0:1} | tr '[a-z]' '[A-Z]'`${PARSER:1} |
---|
10 | curlbin="curl -k -s" |
---|
11 | TMP=/tmp/parser |
---|
12 | |
---|
13 | rm -rf $TMP > /dev/null 2>&1 |
---|
14 | mkdir $TMP > /dev/null 2>&1 |
---|
15 | |
---|
16 | if [ `echo $SRC | grep ^"/mnt/parser" |wc -l` -gt 0 ];then |
---|
17 | TYPE="$SRC - Shell script" |
---|
18 | elif [ `echo $SRC | grep ^"/var/swap" | wc -l` -gt 0 ];then |
---|
19 | TYPE="Swap - Shell script" |
---|
20 | elif [ `echo $SRC | grep ^"/mnt/swapextensions" | wc -l` -gt 0 ];then |
---|
21 | TYPE="Mnt - Shell script" |
---|
22 | else |
---|
23 | TYPE="Flash - Shell script" |
---|
24 | fi |
---|
25 | |
---|
26 | init() |
---|
27 | { |
---|
28 | echo "$NAME ($TYPE)#$SRC $SRC mainmenu#http://atemio.dyndns.tv/mediathek/menu/$PARSER.jpg#$PARSER.jpg#TiThek#0" |
---|
29 | } |
---|
30 | |
---|
31 | mainmenu() |
---|
32 | { |
---|
33 | echo "Sorted by date#$SRC $SRC videos index/main/0/pc#http://atemio.dyndns.tv/mediathek/menu/all-newfirst.jpg#all-newfirst.jpg#$NAME#0" >/tmp/tithek/$PARSER.list |
---|
34 | echo "Popular Tags#$SRC $SRC tags popular#http://atemio.dyndns.tv/mediathek/menu/category.jpg#category.jpg#$NAME#0" >>/tmp/tithek/$PARSER.list |
---|
35 | echo "All Tags#$SRC $SRC tags nonpopular#http://atemio.dyndns.tv/mediathek/menu/category.jpg#category.jpg#$NAME#0" >>/tmp/tithek/$PARSER.list |
---|
36 | echo "Long Videos#$SRC $SRC videos tag/0/pc?tag=long+videos#http://atemio.dyndns.tv/mediathek/menu/category.jpg#category.jpg#$NAME#0" >>/tmp/tithek/$PARSER.list |
---|
37 | echo "Search#$SRC $SRC videos index/search/0/pc?query=cathy%20legs#http://atemio.dyndns.tv/mediathek/menu/search.jpg#search.jpg#$NAME#112" >>/tmp/tithek/$PARSER.list |
---|
38 | echo "/tmp/tithek/$PARSER.list" |
---|
39 | } |
---|
40 | |
---|
41 | videos() |
---|
42 | { |
---|
43 | $curlbin -o - $URL$PARAM | sed -e 's/{/{\n/g' -e 's/,/,\n/g' -e 's/\[/\[\n/g' -e 's/\}/\n\}/g' -e 's/\]/\n\]/g' | awk -v SRC=$SRC -v PARSER=$PARSER -v NAME=$NAME ' |
---|
44 | BEGIN { table = "" |
---|
45 | title = "" |
---|
46 | id = "" |
---|
47 | } |
---|
48 | /\"/ { m = 1 |
---|
49 | while (m == 1) { |
---|
50 | s = $0 |
---|
51 | i = gsub("[\"]", "x", s) |
---|
52 | m = i % 2 |
---|
53 | if (m == 1) { |
---|
54 | getline l |
---|
55 | $0 = $0 l |
---|
56 | } |
---|
57 | } |
---|
58 | } |
---|
59 | /^\{/ { next |
---|
60 | } |
---|
61 | /\[$/ { split($0, a, "\"") |
---|
62 | table = a[2] |
---|
63 | next |
---|
64 | } |
---|
65 | /^\}/ { if (table == "videos") { |
---|
66 | print title "#" SRC " " SRC " stream video/" id "#https://img.beeg.com/236x177/" id ".jpg#" PARSER "_" id ".jpg#" NAME "#0" |
---|
67 | title = "" |
---|
68 | id = "" |
---|
69 | } |
---|
70 | next |
---|
71 | } |
---|
72 | /^\]/ { table = "" |
---|
73 | next |
---|
74 | } |
---|
75 | { if (table == "videos") { |
---|
76 | split($0, a, "\"") |
---|
77 | if (a[3] ==":") { |
---|
78 | value = a[4] |
---|
79 | } |
---|
80 | else { |
---|
81 | value = substr(a[3], 2, length(a[3]) - 2) |
---|
82 | } |
---|
83 | if (a[2] == "title") { |
---|
84 | title = value |
---|
85 | } |
---|
86 | else { |
---|
87 | if (a[2] == "id") { |
---|
88 | id = value |
---|
89 | } |
---|
90 | } |
---|
91 | } |
---|
92 | } |
---|
93 | ' >/tmp/tithek/$PARSER.list |
---|
94 | echo "/tmp/tithek/$PARSER.list" |
---|
95 | } |
---|
96 | |
---|
97 | stream() |
---|
98 | { |
---|
99 | $curlbin -o - $URL$PARAM | sed -e 's/{/{\n/g' -e 's/,/,\n/g' -e 's/\[/\[\n/g' -e 's/\}/\n\}/g' -e 's/\]/\n\]/g' | awk -v PARSER=$PARSER -v NAME=$NAME ' |
---|
100 | BEGIN { table = "" |
---|
101 | title = "" |
---|
102 | id = "" |
---|
103 | v720p = "" |
---|
104 | v480p = "" |
---|
105 | v240p = "" |
---|
106 | h2d = "0123456789ABCDEF" |
---|
107 | for (i = 0; i <= 255; i++) { |
---|
108 | ord[sprintf("%c", i)] = i |
---|
109 | } |
---|
110 | crc = "5ShMcIQlssOd7zChAIOlmeTZDaUxULbJRnywYaiB" |
---|
111 | } |
---|
112 | /\"/ { m = 1 |
---|
113 | while (m == 1) { |
---|
114 | s = $0 |
---|
115 | i = gsub("[\"]", "x", s) |
---|
116 | m = i % 2 |
---|
117 | if (m == 1) { |
---|
118 | getline l |
---|
119 | $0 = $0 l |
---|
120 | } |
---|
121 | } |
---|
122 | } |
---|
123 | /^\{/ { next |
---|
124 | } |
---|
125 | /\[$/ { split($0, a, "\"") |
---|
126 | table = a[2] |
---|
127 | next |
---|
128 | } |
---|
129 | /^\}/ { if (v720p == "null") { |
---|
130 | if (v480p == "null") { |
---|
131 | video = decrypt_url(v240p) |
---|
132 | } |
---|
133 | else { |
---|
134 | video = decrypt_url(v480p) |
---|
135 | } |
---|
136 | } |
---|
137 | else { |
---|
138 | video = decrypt_url(v720p) |
---|
139 | } |
---|
140 | if (video != "null") { |
---|
141 | print title "#https:" video "#https://img.beeg.com/236x177/" id ".jpg#" PARSER "_" id ".jpg#" NAME "#2" |
---|
142 | } |
---|
143 | title = "" |
---|
144 | id = "" |
---|
145 | v720p = "" |
---|
146 | v480p = "" |
---|
147 | v240p = "" |
---|
148 | next |
---|
149 | } |
---|
150 | /^\]/ { table = "" |
---|
151 | next |
---|
152 | } |
---|
153 | { split($0, a, "\"") |
---|
154 | if (a[3] ==":") { |
---|
155 | value = a[4] |
---|
156 | } |
---|
157 | else { |
---|
158 | value = substr(a[3], 2, length(a[3]) - 2) |
---|
159 | } |
---|
160 | if (a[2] == "title") { |
---|
161 | title = value |
---|
162 | } |
---|
163 | else { |
---|
164 | if (a[2] == "id") { |
---|
165 | id = value |
---|
166 | } |
---|
167 | else { |
---|
168 | if (a[2] == "240p") { |
---|
169 | v240p = value |
---|
170 | } |
---|
171 | else { |
---|
172 | if (a[2] == "480p") { |
---|
173 | v480p = value |
---|
174 | } |
---|
175 | else { |
---|
176 | if (a[2] == "720p") { |
---|
177 | v720p = value |
---|
178 | } |
---|
179 | } |
---|
180 | } |
---|
181 | } |
---|
182 | } |
---|
183 | } |
---|
184 | |
---|
185 | function decrypt_url(url) |
---|
186 | { print "URL1: " url >>"/mnt/parser/beeg.log" |
---|
187 | sub(/\{DATA_MARKERS\}/, "", url) |
---|
188 | key_von = match(url, /\/key=/) + 5 |
---|
189 | print "URL2: " url >>"/mnt/parser/beeg.log" |
---|
190 | key_bis = match(url, /\%2Cend/) |
---|
191 | key_len = key_bis - key_von |
---|
192 | key = "" |
---|
193 | for (i = key_von; i < key_bis; i++) { |
---|
194 | s = substr(url, i , 1) |
---|
195 | if (s == "%") { |
---|
196 | n = (index(h2d, toupper(substr(url, i + 1, 1))) - 1) * 16 |
---|
197 | n = n + (index(h2d, toupper(substr(url, i + 2, 1))) - 1) |
---|
198 | if (n != 194) { |
---|
199 | s = sprintf("%c", n) |
---|
200 | } |
---|
201 | else { |
---|
202 | s = "" |
---|
203 | } |
---|
204 | i = i + 2 |
---|
205 | } |
---|
206 | key = key s |
---|
207 | } |
---|
208 | print "KEY1: " key >>"/mnt/parser/beeg.log" |
---|
209 | o = "" |
---|
210 | for (i = 1; i <= length(key); i++) { |
---|
211 | o = o sprintf("%c", ord[substr(key, i, 1)] - (ord[substr(crc, i % length(crc), 1)] % 21)) |
---|
212 | } |
---|
213 | print "KEY2: " o >>"/mnt/parser/beeg.log" |
---|
214 | r = "" |
---|
215 | for (i = length(o) - 2; i > -3; i = i - 3) { |
---|
216 | if (i > 0) { |
---|
217 | r = r substr(o, i, 3)A |
---|
218 | } |
---|
219 | else { |
---|
220 | r = r substr(o, 1, 2 - i) |
---|
221 | } |
---|
222 | } |
---|
223 | print "KEY3: " r >>"/mnt/parser/beeg.log" |
---|
224 | return substr(url, 1, key_von - 1) r substr(url, key_bis) |
---|
225 | } |
---|
226 | ' >/tmp/tithek/$PARSER.list |
---|
227 | echo "/tmp/tithek/$PARSER.list" |
---|
228 | } |
---|
229 | |
---|
230 | tags() |
---|
231 | { |
---|
232 | $curlbin -o - ${URL}index/main/0/pc | sed -e 's/{DATA_MARKERS}/data=pc.XX/g' -e 's/{/{\n/g' -e 's/,/,\n/g' -e 's/\[/\[\n/g' -e 's/\}/\n\}/g' -e 's/\]/\n\]/g' | awk -v PARAM=$PARAM -v SRC=$SRC -v NAME=$NAME ' |
---|
233 | BEGIN { table = "" |
---|
234 | } |
---|
235 | /\"/ { m = 1 |
---|
236 | while (m == 1) { |
---|
237 | s = $0 |
---|
238 | i = gsub("[\"]", "x", s) |
---|
239 | m = i % 2 |
---|
240 | if (m == 1) { |
---|
241 | getline l |
---|
242 | $0 = $0 l |
---|
243 | } |
---|
244 | } |
---|
245 | } |
---|
246 | /^\{/ { next |
---|
247 | } |
---|
248 | /\[$/ { split($0, a, "\"") |
---|
249 | table = a[2] |
---|
250 | next |
---|
251 | } |
---|
252 | /^\}/ { next |
---|
253 | } |
---|
254 | /^\]/ { table = "" |
---|
255 | next |
---|
256 | } |
---|
257 | { if (table == PARAM) { |
---|
258 | split($0, a, "\"") |
---|
259 | title = a[2] |
---|
260 | tag = title |
---|
261 | gsub(/ /, "%20", tag) |
---|
262 | print title "#" SRC " " SRC " videos index/tag/0/pc?tag=" tag "#http://atemio.dyndns.tv/mediathek/menu/" tag ".jpg#" tag ".jpg#" NAME "#0" |
---|
263 | } |
---|
264 | } |
---|
265 | ' >/tmp/tithek/$PARSER.list |
---|
266 | echo "/tmp/tithek/$PARSER.list" |
---|
267 | } |
---|
268 | |
---|
269 | case $INPUT in |
---|
270 | init) $INPUT;; |
---|
271 | mainmenu) $INPUT;; |
---|
272 | videos) $INPUT;; |
---|
273 | stream) $INPUT;; |
---|
274 | tags) $INPUT;; |
---|
275 | page) $INPUT;; |
---|
276 | esac |
---|
277 | |
---|