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

Last change on this file since 43326 was 42731, checked in by obi, 6 years ago

tithek hid bs/beeg show tata

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