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

Last change on this file since 37513 was 37507, checked in by tt4sk, 8 years ago

[TiThek] fixed: beeg api changed from v5 to v6 (forget "/")

  • Property svn:executable set to *
File size: 7.4 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/1740/"
10PARSER=`echo $SRC | tr '/' '\n' | tail -n1 | sed 's/.sh//'`
11NAME=`echo -n ${PARSER:0:1} | tr '[a-z]' '[A-Z]'`${PARSER:1}
12
13rm -rf $TMP > /dev/null 2>&1
14mkdir $TMP > /dev/null 2>&1
15
16if [ `echo $SRC | grep ^"/mnt/parser" |wc -l` -gt 0 ];then
17        TYPE="$SRC - Shell script"
18elif [ `echo $SRC | grep ^"/var/swap" | wc -l` -gt 0 ];then
19        TYPE="Swap - Shell script"
20elif [ `echo $SRC | grep ^"/mnt/swapextensions" | wc -l` -gt 0 ];then
21        TYPE="Mnt - Shell script"
22else
23        TYPE="Flash - Shell script"
24fi
25
26init()
27{
28        echo "$NAME ($TYPE)#$SRC $SRC mainmenu#http://atemio.dyndns.tv/mediathek/menu/$PARSER.jpg#$PARSER.jpg#TiThek#1000"
29}
30
31mainmenu()
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=#http://atemio.dyndns.tv/mediathek/menu/search.jpg#search.jpg#$NAME#112" >>/tmp/tithek/$PARSER.list
38        echo "/tmp/tithek/$PARSER.list"
39}
40
41videos()
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 '
44BEGIN { 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 " play video/" id "#https://img.beeg.com/236x177/" id ".jpg#" PARSER "_" id ".jpg#" NAME "#111"
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
97play()
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 '
100BEGIN { 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 = "00bD4mj2FMx0VcXnr3HZEhJn"
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 "#http:" video "#https://img.beeg.com/236x177/" id ".jpg#" PARSER "_" id ".jpg#" NAME "#2"
142           print "http:" video
143           }
144        title = ""
145        id = ""
146        v720p = ""
147        v480p = ""
148        v240p = ""
149        next
150      }
151/^\]/ { table = ""
152        next
153      }
154      { split($0, a, "\"")
155        if (a[3] ==":") {
156           value = a[4]
157        }
158        else {
159           value = substr(a[3], 2, length(a[3]) - 2)
160        }
161        if (a[2] == "title") {
162           title = value
163        }
164        else {
165           if (a[2] == "id") {
166              id = value
167           }
168           else {
169              if (a[2] == "240p") {
170                 v240p = value
171              }
172              else {
173                 if (a[2] == "480p") {
174                    v480p = value
175                 }
176                 else {
177                    if (a[2] == "720p") {
178                       v720p = value
179                    }
180                 }
181              }
182           }
183        }
184      }
185
186function decrypt_url(url)
187      { print "URL1: " url >>"/mnt/parser/beeg.log"
188        sub(/\{DATA_MARKERS\}/, "", url)
189        key_von = match(url, /\/key=/) + 5
190        print "URL2: " url >>"/mnt/parser/beeg.log"
191        key_bis = match(url, /\%2Cend/)
192        key_len = key_bis - key_von
193        key = ""
194        for (i = key_von; i < key_bis; i++) {
195           s = substr(url, i , 1)
196           if (s == "%") {
197              n = (index(h2d, toupper(substr(url, i + 1, 1))) - 1) * 16
198              n = n + (index(h2d, toupper(substr(url, i + 2, 1))) - 1)
199              if (n != 194) {
200                 s = sprintf("%c", n)
201              }
202              else {
203                 s = ""
204              }
205              i = i + 2
206           }
207           key = key s
208        }
209        print "KEY1: " key >>"/mnt/parser/beeg.log"
210        o = ""
211        for (i = 1; i <= length(key); i++) {
212           o = o sprintf("%c", ord[substr(key, i, 1)] - (ord[substr(crc, i % length(crc), 1)] % 21))
213        }
214        print "KEY2: " o >>"/mnt/parser/beeg.log"
215        r = ""
216        for (i = length(o) - 2; i > -2; i = i - 3) {
217           if (i > 0) {
218              r = r substr(o, i, 3)
219           }
220           else {
221              r = r substr(o, 1, 2 + i)
222           }
223        }
224        print "KEY3: " r >>"/mnt/parser/beeg.log"
225        return substr(url, 1, key_von - 1) r substr(url, key_bis)
226      }
227' >/tmp/tithek/$PARSER.list
228#       echo "/tmp/tithek/$PARSER.list"
229        cat "/tmp/tithek/$PARSER.list"
230}
231
232tags()
233{
234        $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 '
235BEGIN { table = ""
236      }
237/\"/  { m = 1
238        while (m == 1) {
239           s = $0
240           i = gsub("[\"]", "x", s)
241           m = i % 2
242           if (m == 1) {
243              getline l
244              $0 = $0 l
245           }
246        }
247      }
248/^\{/ { next
249      }
250/\[$/ { split($0, a, "\"")
251        table = a[2]
252        next
253      }
254/^\}/ { next
255      }
256/^\]/ { table = ""
257        next
258      }
259      { if (table == PARAM) {
260           split($0, a, "\"")
261           title = a[2]
262           tag = title
263           gsub(/ /, "%20", tag)
264           print title "#" SRC " " SRC " videos index/tag/0/pc?tag=" tag "#http://atemio.dyndns.tv/mediathek/menu/" tag ".jpg#" tag ".jpg#" NAME "#0"
265        }
266      }
267' >/tmp/tithek/$PARSER.list
268        echo "/tmp/tithek/$PARSER.list"
269}
270
271case $INPUT in
272        init) $INPUT;;
273        mainmenu) $INPUT;;
274        videos) $INPUT;;
275        play) $INPUT;;
276        tags) $INPUT;;
277        page) $INPUT;;
278esac
279
Note: See TracBrowser for help on using the repository browser.