source: titan/mediathek/localparser_secret/beeg.sh @ 40982

Last change on this file since 40982 was 40982, checked in by tt4sk, 7 years ago

[TiThek] fixed: beeg website changed

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