source: titan/mediathek/localparser_secret/kkiste.sh @ 42593

Last change on this file since 42593 was 42464, checked in by obi, 6 years ago

tithek testfix speedup init localhoster

  • Property svn:executable set to *
File size: 12.0 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
11PAGE=$3
12NEXT=$4
13
14FILENAME=`echo $PAGE | tr '/' '.' | tr '?' '.'  | tr '=' '.'`
15FILENAME=`echo $FILENAME | tr '&' '.'`
16
17if [ -z "$FILENAME" ]; then
18        FILENAME=none
19fi
20
21URL="http://kkiste.to/"
22PARSER=`echo $SRC | tr '/' '\n' | tail -n1 | sed 's/.sh//'`
23NAME=`echo -n ${PARSER:0:2} | tr '[a-z]' '[A-Z]'`${PARSER:2}
24
25mkdir $TMP > /dev/null 2>&1
26
27if [ `echo $SRC | grep ^"/mnt/parser" |wc -l` -gt 0 ];then
28        TYPE="$SRC - Shell script"
29elif [ `echo $SRC | grep ^"/var/swap" | wc -l` -gt 0 ];then
30        TYPE="Swap - Shell script"
31elif [ `echo $SRC | grep ^"/mnt/swapextensions" | wc -l` -gt 0 ];then
32        TYPE="Mnt - Shell script"
33else
34        TYPE="Flash - Shell script"
35fi
36
37init()
38{
39        rm -rf $TMP > /dev/null 2>&1
40        echo "$NAME ($TYPE)#$SRC $SRC mainmenu#http://atemio.dyndns.tv/mediathek/menu/$PARSER.jpg#$PARSER.jpg#TiThek#0"
41}
42
43mainmenu()
44{
45        echo "Neue Filme#$SRC $SRC videos neue-filme/?page= 1#http://atemio.dyndns.tv/mediathek/menu/all-newfirst.jpg#all-newfirst.jpg#$NAME#0" >$TMP/$PARSER.$INPUT.list
46        echo "Kinofilme#$SRC $SRC videos aktuelle-kinofilme/?page= 1#http://atemio.dyndns.tv/mediathek/menu/all-newfirst.jpg#all-newfirst.jpg#$NAME#0" >>$TMP/$PARSER.$INPUT.list
47        echo "Serien#$SRC $SRC videos serien/?page= 1#http://atemio.dyndns.tv/mediathek/menu/series.jpg#series.jpg#$NAME#0" >>$TMP/$PARSER.$INPUT.list
48        echo "Genre#$SRC $SRC genre#http://atemio.dyndns.tv/mediathek/menu/search.jpg#gebre.jpg#$NAME#0" >>$TMP/$PARSER.$INPUT.list
49        echo "A-Z#$SRC $SRC sorted#http://atemio.dyndns.tv/mediathek/menu/search.jpg#search.jpg#$NAME#0" >>$TMP/$PARSER.$INPUT.list
50        echo "Search#$SRC $SRC search 'search/?q=%search%'#http://atemio.dyndns.tv/mediathek/menu/search.jpg#search.jpg#$NAME#112" >>$TMP/$PARSER.$INPUT.list
51
52#       echo "d 6#$SRC $SRC search 'film-index/d/?page=' 6#http://atemio.dyndns.tv/mediathek/menu/search.jpg#search.jpg#$NAME#0" >>$TMP/$PARSER.$INPUT.list
53
54        echo "$TMP/$PARSER.$INPUT.list"
55}
56
57sorted()
58{
59        watchlist="0 1 2 3 4 5 6 7 8 9 a b c d e f g h i j k l m n o p q r s t u v w x y z"
60
61        rm $TMP/$PARSER.$INPUT.list > /dev/null 2>&1
62
63        for ROUND0 in $watchlist; do
64                TITLE=`echo $ROUND0`
65                filename=`echo $TITLE`
66                echo "$TITLE#$SRC $SRC search film-index/$ROUND0/?page= 1#http://atemio.dyndns.tv/mediathek/menu/$filename.jpg#$filename.jpg#$NAME#0" >> $TMP/$PARSER.$INPUT.list
67        done
68        echo "$TMP/$PARSER.$INPUT.list"
69}
70
71genre()
72{
73        watchlist="
74                abenteuer
75                action
76                animation
77                biographie
78                bollywood
79                dokumentation
80                drama
81                familie
82                fantasy
83                geschichte
84                horror
85                klassiker
86                komoedie
87                kriegsfilm
88                krimi
89                musik
90                mystery
91                romantik
92                sci-fi
93                sport
94                thriller
95                western
96                "
97        rm $TMP/$PARSER.$INPUT.list > /dev/null 2>&1
98
99        for ROUND0 in $watchlist; do
100                TITLE=`echo $ROUND0 | tr '/' '-' | sed 's/free-//g'`
101                filename=`echo $TITLE` 
102                echo "$TITLE#$SRC $SRC videos $ROUND0/?page= 1#http://atemio.dyndns.tv/mediathek/menu/$filename.jpg#$filename.jpg#$NAME#0" >> $TMP/$PARSER.$INPUT.list
103        done
104        echo "$TMP/$PARSER.$INPUT.list"
105}
106
107search()
108{
109        if [ -z "$NEXT" ]; then NEXT="search"; fi
110
111        if [ ! -e "$TMP/$PARSER.$INPUT.$NEXT.$FILENAME.list" ]; then
112                piccount=0
113       
114                if [ "$NEXT" == "search" ]; then
115                        $curlbin $URL/$PAGE -o $TMP/cache.$PARSER.$INPUT.$NEXT.$FILENAME.1
116                else
117                        $curlbin $URL/$PAGE$NEXT -o $TMP/cache.$PARSER.$INPUT.$NEXT.$FILENAME.1
118                fi
119       
120                cat $TMP/cache.$PARSER.$INPUT.$NEXT.$FILENAME.1 | tr '\n' '\r' |  tr '\r' ' ' | tr '\n' ' ' | tr '\t' ' ' | sed 's/ \+/ /g' | sed 's!<li class="mbox list"!\nfound=!g' | sed 's!<div class="clear">!\n<div class="clear">!g' | grep ^"found=" >$TMP/cache.$PARSER.$INPUT.$NEXT.$FILENAME.2
121       
122                pages=`cat $TMP/cache.$PARSER.$INPUT.$NEXT.$FILENAME.1 | grep 'div class="paginated"' | sed 's!<li><a href=!\nfound=!g' | grep ^"found=" | cut -d'"' -f2 | cut -d'=' -f2 | tail -n1`
123       
124                while read -u 3 ROUND; do
125                        ID=`echo $ROUND | cut -d'"' -f1 | tail -n1`
126                        PIC=`echo $ROUND | sed 's!"url": !\nurl=!g' | grep ^url= | cut -d'"' -f2 | tail -n1`
127                        TITLE=`echo $ROUND | sed 's!class="title">!\ntitle=<!g' | grep ^title= | cut -d'<' -f2`
128                        NEWPAGE=`echo $ROUND | sed 's!<a href=!\nfound=!g' | grep ^found= | cut -d'"' -f2 | tail -n1`
129       
130                        PIC=`$curlbin "$URL/$NEWPAGE" | tr '\n' '\r' |  tr '\r' ' ' | tr '\n' ' ' | tr '\t' ' ' | sed 's/ \+/ /g' | sed 's!<img src=!\nfound=!g' | grep ^found= | cut -d'"' -f2 | tail -n1`
131       
132                        if [ -z "$PIC" ]; then
133                                PIC="http://atemio.dyndns.tv/mediathek/menu/default.jpg"
134                        fi
135       
136                        TITLE=`echo $TITLE | sed -e 's/&#038;/&/g' -e 's/&amp;/und/g' -e 's/&quot;/"/g' -e 's/&lt;/\</g' -e 's/&#034;/\"/g' -e 's/&#039;/\"/g' -e 's/#034;/\"/g' -e 's/#039;/\"/g' -e 's/&szlig;/Ãx/g' -e 's/&ndash;/-/g' -e 's/&Auml;/Ã/g' -e 's/&Uuml;/ÃS/g' -e 's/&Ouml;/Ã/g' -e 's/&auml;/ä/g' -e 's/&uuml;/ü/g' -e 's/&ouml;/ö/g' -e 's/&eacute;/é/g' -e 's/&egrave;/è/g' -e 's/%F6/ö/g' -e 's/%FC/ü/g' -e 's/%E4/ä/g' -e 's/%26/&/g' -e 's/%C4/Ã/g' -e 's/%D6/Ã/g' -e 's/%DC/ÃS/g' -e 's/%28/(/g' -e 's/%29/)/g' -e 's/%3A/:/g' -e 's/%40/@/g' -e 's/%2B/&/g' -e 's/%C3/A/g' -e 's/%B1/&/g' -e 's/%5B//g' -e 's/%5D//g' -e 's!%2F!/!g' -e 's/|/ /g' -e 's/(/ /g' -e 's/)/ /g' -e 's/+/ /g' -e 's/\//-/g' -e 's/,/ /g' -e 's/;/ /g' -e 's/:/ /g' -e 's/\.\+/./g'`
137       
138                        if [ ! -z "$TITLE" ] && [ ! -z "$NEWPAGE" ];then
139                                if [ ! -e $TMP/$PARSER.$INPUT.$INPUT.$FILENAME.list ];then
140                                        touch $TMP/$PARSER.$INPUT.$INPUT.$FILENAME.list
141                                fi
142                                piccount=`expr $piccount + 1`
143                                LINE="$TITLE $LANG#$SRC $SRC parts $NEWPAGE#$PIC#$PARSER.$INPUT.$FILENAME.$piccount.jpg#$NAME#0"
144       
145                                echo "$LINE" >> $TMP/$PARSER.$INPUT.$NEXT.$FILENAME.list
146                        fi
147       
148                done 3<$TMP/cache.$PARSER.$INPUT.$NEXT.$FILENAME.2
149       
150                if [ "$NEXT" -lt "$pages" ]; then
151                        NEXTPAGE=`expr $NEXT + 1`
152                        LINE="Page ($NEXTPAGE/$pages)#$SRC $SRC search '$PAGE' $NEXTPAGE#http://atemio.dyndns.tv/mediathek/menu/next.jpg#next.jpg#$NAME#0"
153                        echo "$LINE" >> $TMP/$PARSER.$INPUT.$NEXT.$FILENAME.list
154                fi
155       
156                rm $TMP/cache.* > /dev/null 2>&1
157        fi
158        echo "$TMP/$PARSER.$INPUT.$NEXT.$FILENAME.list"
159}
160
161videos()
162{
163        $curlbin -o - $URL$PAGE$NEXT | awk -v SRC=$SRC -v INPUT=$INPUT -v PAGE=$PAGE -v NEXT=$NEXT -v PARSER=$PARSER -v NAME=$NAME '
164
165BEGIN { title=""
166        url=""
167        pic=""
168      }
169
170/<a href="/ { if(match($0, /class="title">/) != 0) {
171                 i = match($0, /<a href="/)
172                 split(substr($0, i), a, "\"")
173                 url = a[2]
174                 i = match($0, / title="Jetzt /)
175                 split(substr($0, i), a, "\"")
176                 title = substr(a[2], 7, length(a[2]) - 21)
177              }
178            }
179
180/<img src="/ { i = match($0, /<img src="/)
181               split(substr($0, i), a, "\"")
182               pic = a[2]
183             }
184
185/<div class="title"><strong>/ { n = split(pic, a, "/")
186                                pic2 = a[n]
187                                print title "#" SRC " " SRC " parts " url "#" pic "#" pic2 "#" NAME "#0"
188                                title=""
189                                url=""
190                                pic=""
191                                pic2=""
192                              }
193
194END   { print "Page " NEXT + 1 "#" SRC " " SRC " " INPUT " " PAGE " " NEXT + 1 "#http://atemio.dyndns.tv/mediathek/menu/next.jpg#next.jpg#" NAME "#0"
195      }
196' >$TMP/$PARSER.$INPUT.list
197        echo "$TMP/$PARSER.$INPUT.list"
198}
199
200parts()
201{
202        $curlbin -o - $URL$PAGE >$TMP/cache.$PARSER.$INPUT.1
203
204        cat $TMP/cache.$PARSER.$INPUT.1 | awk -v SRC=$SRC -v INPUT=$INPUT -v PAGE=$PAGE -v NEXT=$NEXT -v PARSER=$PARSER -v NAME=$NAME '
205BEGIN { kz_parts=0
206        count=1
207        extra=test
208      }
209
210/<div class="mediabar">/ { kz_parts=1
211                           next
212                 }
213/<select class="seasonselect"/ { extra=1
214                           next
215                 }
216/<option value="/ { if(extra=1) {
217                 i = match($0, /<option value="/)
218                 split(substr($0, i), a, "\"")
219                 #print url
220                 title = a[2]
221                                 if(title!="") {
222                         count = title
223                     print "Staffel: " title "#" SRC " " SRC " episodelist " PAGE " " "season=" count "#http://atemio.dyndns.tv/mediathek/menu/s" title ".jpg#s" title ".jpg#" NAME "#0"
224                         }
225                 next
226              }
227            }
228
229/<a href="/ { if(kz_parts!=0) {
230                 i = match($0, /<a href="/)
231                 split(substr($0, i), a, "\"")
232                 url = a[2]
233                 i = match($0, /target="/)
234                 split(substr($0, i), a, "\"")
235                 title = a[3]
236                 sub(/>/, "", title)
237                 sub(/<small>/, "", title)
238                 sub(/<\/small><\/a><\/li>/, "", title)
239                 split(title, a, "\[")
240                 split(a[2], b, "\]")
241                 split(b[1], a, " ")
242                 part = a[2]
243                 print title "#" SRC " " SRC " hoster " PAGE " " count "#http://atemio.dyndns.tv/mediathek/menu/" part ".jpg#" part ".jpg#" NAME "#111"
244                 count=count+1
245                 next
246              }
247            }
248
249/<div class="ad leaderboard">/ { kz_parts=0
250                                 next
251         }
252' >$TMP/$PARSER.$INPUT.$FILENAME.list
253        echo "$TMP/$PARSER.$INPUT.$FILENAME.list"
254}
255
256hoster()
257{
258        i=`expr $NEXT \* 2`
259        data=`$curlbin "$URL$PAGE" | grep "data-det=" | cut -d'"' -f4`
260
261        if [ ! -z "$data" ];then
262                id=`$curlbin --header "Content-Type: application/json" -H "X-Requested-With: XMLHttpRequest" -X POST --data "$data" --referer $URL$PAGE http://kkiste.to/xhr/link/ | cut -d'"' -f$i`
263        fi
264
265        if [ -z "$id" ];then
266                id=`$curlbin "$URL$PAGE" | grep "http://www.ecostream.tv/stream" | sed 's#http://www.ecostream.tv/stream/#\nlink=.#g' | cut -d"." -f2`
267        fi
268        echo "http://www.ecostream.tv/stream/$id.html"
269}
270
271episodelist()
272{
273        if [ -e "$TMP/$PARSER.$INPUT.list" ] ; then
274                rm $TMP/$PARSER.$INPUT.list
275        fi
276
277        SEASON=`echo $NEXT | cut -d"=" -f2`
278        PARAM1=`echo $PAGE | sed 's!.html!/!g'`
279
280        data=`$curlbin "$URL$PAGE" | grep "data-movie=" | cut -d'"' -f4`
281        $curlbin2 -H "X-Requested-With: XMLHttpRequest" -X POST --data "$NEXT" --referer $URL$PAGE http://kkiste.to/xhr/movies/episodes/$data/ -o "$TMP/cache.$PARSER.$INPUT.1"
282### curl -k -s -v -H "X-Requested-With: XMLHttpRequest" -X POST --data "season=1" --referer http://kkiste.to/24-twenty-four-stream.html http://kkiste.to/xhr/movies/episodes/24-twenty-four-stream/
283
284        cat $TMP/cache.$PARSER.$INPUT.1 | sed 's!},{!\n{!g' | cut -d"[" -f2 >$TMP/cache.$PARSER.$INPUT.2
285
286        count=0
287
288        while read -u 3 ROUND; do
289                count=`expr $count + 1`
290       
291                TITLE=`echo $ROUND | cut -d'"' -f10 | tail -n1`
292                ID=`echo $ROUND | cut -d'"' -f6 | tail -n1`
293                NEWPAGE="http://www.ecostream.tv/stream/$ID.html"
294                EPISODE=`echo $TITLE | tr ' ' '\n' | tail -n1`
295                PICNAME=s"$SEASON"e"$EPISODE".jpg
296                PIC="http://atemio.dyndns.tv/mediathek/menu/$PICNAME"
297
298                TITLE=`echo $TITLE | sed -e 's/&#038;/&/g' -e 's/&amp;/und/g' -e 's/&quot;/"/g' -e 's/&lt;/\</g' -e 's/&#034;/\"/g' -e 's/&#039;/\"/g' -e 's/#034;/\"/g' -e 's/#039;/\"/g' -e 's/&szlig;/Ãx/g' -e 's/&ndash;/-/g' -e 's/&Auml;/Ã/g' -e 's/&Uuml;/ÃS/g' -e 's/&Ouml;/Ã/g' -e 's/&auml;/ä/g' -e 's/&uuml;/ü/g' -e 's/&ouml;/ö/g' -e 's/&eacute;/é/g' -e 's/&egrave;/è/g' -e 's/%F6/ö/g' -e 's/%FC/ü/g' -e 's/%E4/ä/g' -e 's/%26/&/g' -e 's/%C4/Ã/g' -e 's/%D6/Ã/g' -e 's/%DC/ÃS/g' -e 's/%28/(/g' -e 's/%29/)/g' -e 's/%3A/:/g' -e 's/%40/@/g' -e 's/%2B/&/g' -e 's/%C3/A/g' -e 's/%B1/&/g' -e 's/%5B//g' -e 's/%5D//g' -e 's!%2F!/!g' -e 's/|/ /g' -e 's/(/ /g' -e 's/)/ /g' -e 's/+/ /g' -e 's/\//-/g' -e 's/,/ /g' -e 's/;/ /g' -e 's/:/ /g' -e 's/\.\+/./g'`
299
300                if [ ! -z "$TITLE" ] && [ ! -z "$NEWPAGE" ];then
301                        if [ ! -e $TMP/$PARSER.$INPUT.$FILENAME.list ];then
302                                touch $TMP/$PARSER.$INPUT.$FILENAME.list
303                        fi
304#gehen beide varianten weiss nur nicht ob die folgen dann stimmen
305#                       LINE="$TITLE#$SRC $SRC hoster $PARAM $count#$PIC#$PICNAME#$NAME#111"
306                        LINE="$TITLE#$NEWPAGE#$PIC#$PICNAME#$NAME#14"
307
308                        echo "$LINE" >> $TMP/$PARSER.$INPUT.list
309                fi
310
311        done 3<$TMP/cache.$PARSER.$INPUT.2
312        rm $TMP/cache.* > /dev/null 2>&1
313
314        echo "$TMP/$PARSER.$INPUT.list"
315}
316
317
318case $INPUT in
319#       init) $INPUT;;
320        mainmenu) $INPUT;;
321        videos) $INPUT;;
322        parts) $INPUT;;
323        serien) $INPUT;;
324        hoster) $INPUT;;
325        search) $INPUT;;
326        page) $INPUT;;
327        episodelist) $INPUT;;
328        sorted) $INPUT;;
329        genre) $INPUT;;
330esac
331
Note: See TracBrowser for help on using the repository browser.