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

Last change on this file since 39656 was 39635, checked in by obi, 7 years ago

kkiste add series

  • Property svn:executable set to *
File size: 9.7 KB
Line 
1#!/bin/bash
2# box parser for titannit
3
4. /tmp/localhoster/hoster.sh
5
6SRC=$1
7INPUT=$2
8PARAM=$3
9PAGE=$4
10
11FILENAME=`echo $PARAM | tr '/' '.' | tr '?' '.'  | tr '=' '.'`
12
13URL="http://kkiste.to/"
14PARSER=`echo $SRC | tr '/' '\n' | tail -n1 | sed 's/.sh//'`
15NAME=`echo -n ${PARSER:0:2} | tr '[a-z]' '[A-Z]'`${PARSER:2}
16
17mkdir $TMP > /dev/null 2>&1
18
19if [ `echo $SRC | grep ^"/mnt/parser" |wc -l` -gt 0 ];then
20        TYPE="$SRC - Shell script"
21elif [ `echo $SRC | grep ^"/var/swap" | wc -l` -gt 0 ];then
22        TYPE="Swap - Shell script"
23elif [ `echo $SRC | grep ^"/mnt/swapextensions" | wc -l` -gt 0 ];then
24        TYPE="Mnt - Shell script"
25else
26        TYPE="Flash - Shell script"
27fi
28
29init()
30{
31        rm -rf $TMP > /dev/null 2>&1
32        echo "$NAME ($TYPE)#$SRC $SRC mainmenu#http://atemio.dyndns.tv/mediathek/menu/$PARSER.jpg#$PARSER.jpg#TiThek#0"
33}
34
35mainmenu()
36{
37        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
38        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
39        echo "Serien#$SRC $SRC videos serien/?page= 1#http://atemio.dyndns.tv/mediathek/menu/series.jpg#series.jpg#$NAME#0" >>$TMP/$PARSER.$INPUT.list
40        echo "Search#$SRC $SRC search 'search/?q=%search%'#http://atemio.dyndns.tv/mediathek/menu/search.jpg#search.jpg#$NAME#112" >>$TMP/$PARSER.$INPUT.list
41        echo "$TMP/$PARSER.$INPUT.list"
42}
43
44search()
45{
46        if [ -e "$TMP/$PARSER.$INPUT.list" ] ; then
47                rm $TMP/$PARSER.$INPUT.list > /dev/null 2>&1
48        fi
49
50        piccount=0
51        $curlbin "$URL/$PARAM" -o "$TMP/cache.$PARSER.$INPUT.1"
52        cat $TMP/cache.$PARSER.$INPUT.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.2
53
54        while read -u 3 ROUND; do
55                ID=`echo $ROUND | cut -d'"' -f1 | tail -n1`
56                PIC=`echo $ROUND | sed 's!"url": !\nurl=!g' | grep ^url= | cut -d'"' -f2 | tail -n1`
57                TITLE=`echo $ROUND | sed 's!class="title">!\ntitle=<!g' | grep ^title= | cut -d'<' -f2`
58                NEWPAGE=`echo $ROUND | sed 's!<a href=!\nfound=!g' | grep ^found= | cut -d'"' -f2 | tail -n1`
59
60                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`
61
62                if [ -z "$PIC" ]; then
63                        PIC="http://atemio.dyndns.tv/mediathek/menu/default.jpg"
64                fi
65
66                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'`
67
68                if [ ! -z "$TITLE" ] && [ ! -z "$NEWPAGE" ];then
69                        if [ ! -e $TMP/$PARSER.$INPUT.$FILENAME.list ];then
70                                touch $TMP/$PARSER.$INPUT.$FILENAME.list
71                        fi
72                        piccount=`expr $piccount + 1`
73                        LINE="$TITLE $LANG#$SRC $SRC parts $NEWPAGE#$PIC#$PARSER.$INPUT.$FILENAME.$piccount.jpg#$NAME#0"
74
75                        echo "$LINE" >> $TMP/$PARSER.$INPUT.list
76                fi
77
78        done 3<$TMP/cache.$PARSER.$INPUT.2
79        rm $TMP/cache.* > /dev/null 2>&1
80
81        echo "$TMP/$PARSER.$INPUT.list"
82}
83
84videos()
85{
86        $curlbin -o - $URL$PARAM$PAGE | awk -v SRC=$SRC -v INPUT=$INPUT -v PARAM=$PARAM -v PAGE=$PAGE -v PARSER=$PARSER -v NAME=$NAME '
87
88BEGIN { title=""
89        url=""
90        pic=""
91      }
92
93/<a href="/ { if(match($0, /class="title">/) != 0) {
94                 i = match($0, /<a href="/)
95                 split(substr($0, i), a, "\"")
96                 url = a[2]
97                 i = match($0, / title="Jetzt /)
98                 split(substr($0, i), a, "\"")
99                 title = substr(a[2], 7, length(a[2]) - 21)
100              }
101            }
102
103/<img src="/ { i = match($0, /<img src="/)
104               split(substr($0, i), a, "\"")
105               pic = a[2]
106             }
107
108/<div class="title"><strong>/ { n = split(pic, a, "/")
109                                pic2 = a[n]
110                                print title "#" SRC " " SRC " parts " url "#" pic "#" pic2 "#" NAME "#0"
111                                title=""
112                                url=""
113                                pic=""
114                                pic2=""
115                              }
116
117END   { print "Page " PAGE + 1 "#" SRC " " SRC " " INPUT " " PARAM " " PAGE + 1 "#http://atemio.dyndns.tv/mediathek/menu/next.jpg#next.jpg#" NAME "#0"
118      }
119' >$TMP/$PARSER.$INPUT.list
120        echo "$TMP/$PARSER.$INPUT.list"
121}
122
123parts()
124{
125        $curlbin -o - $URL$PARAM >$TMP/cache.$PARSER.$INPUT.1
126
127        cat $TMP/cache.$PARSER.$INPUT.1 | awk -v SRC=$SRC -v INPUT=$INPUT -v PARAM=$PARAM -v PAGE=$PAGE -v PARSER=$PARSER -v NAME=$NAME '
128BEGIN { kz_parts=0
129        count=1
130        extra=test
131      }
132
133/<div class="mediabar">/ { kz_parts=1
134                           next
135                 }
136/<select class="seasonselect"/ { extra=1
137                           next
138                 }
139/<option value="/ { if(extra=1) {
140                 i = match($0, /<option value="/)
141                 split(substr($0, i), a, "\"")
142                 #print url
143                 title = a[2]
144                                 if(title!="") {
145                         count = title
146                     print "Staffel: " title "#" SRC " " SRC " episodelist " PARAM " " "season=" count "#http://atemio.dyndns.tv/mediathek/menu/s" title ".jpg#s" title ".jpg#" NAME "#0"
147                         }
148                 next
149              }
150            }
151
152/<a href="/ { if(kz_parts!=0) {
153                 i = match($0, /<a href="/)
154                 split(substr($0, i), a, "\"")
155                 url = a[2]
156                 i = match($0, /target="/)
157                 split(substr($0, i), a, "\"")
158                 title = a[3]
159                 sub(/>/, "", title)
160                 sub(/<small>/, "", title)
161                 sub(/<\/small><\/a><\/li>/, "", title)
162                 split(title, a, "\[")
163                 split(a[2], b, "\]")
164                 split(b[1], a, " ")
165                 part = a[2]
166                 print title "#" SRC " " SRC " hoster " PARAM " " count "#http://atemio.dyndns.tv/mediathek/menu/" part ".jpg#" part ".jpg#" NAME "#111"
167                 count=count+1
168                 next
169              }
170            }
171
172/<div class="ad leaderboard">/ { kz_parts=0
173                                 next
174         }
175' >$TMP/$PARSER.$INPUT.$FILENAME.list
176        echo "$TMP/$PARSER.$INPUT.$FILENAME.list"
177}
178
179hoster()
180{
181        i=`expr $PAGE \* 2`
182        data=`$curlbin "$URL$PARAM" | grep "data-det=" | cut -d'"' -f4`
183
184        if [ ! -z "$data" ];then
185                id=`$curlbin --header "Content-Type: application/json" -H "X-Requested-With: XMLHttpRequest" -X POST --data "$data" --referer $URL$PARAM http://kkiste.to/xhr/link/ | cut -d'"' -f$i`
186        fi
187
188        if [ -z "$id" ];then
189                id=`$curlbin "$URL$PARAM" | grep "http://www.ecostream.tv/stream" | sed 's#http://www.ecostream.tv/stream/#\nlink=.#g' | cut -d"." -f2`
190        fi
191        echo "http://www.ecostream.tv/stream/$id.html"
192}
193
194episodelist()
195{
196        if [ -e "$TMP/$PARSER.$INPUT.list" ] ; then
197                rm $TMP/$PARSER.$INPUT.list
198        fi
199
200        SEASON=`echo $PAGE | cut -d"=" -f2`
201        PARAM1=`echo $PARAM | sed 's!.html!/!g'`
202
203        data=`$curlbin "$URL$PARAM" | grep "data-movie=" | cut -d'"' -f4`
204        $curlbin2 -H "X-Requested-With: XMLHttpRequest" -X POST --data "$PAGE" --referer $URL$PARAM http://kkiste.to/xhr/movies/episodes/$data/ -o "$TMP/cache.$PARSER.$INPUT.1"
205### 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/
206
207        cat $TMP/cache.$PARSER.$INPUT.1 | sed 's!},{!\n{!g' | cut -d"[" -f2 >$TMP/cache.$PARSER.$INPUT.2
208
209        count=0
210
211        while read -u 3 ROUND; do
212                count=`expr $count + 1`
213       
214                TITLE=`echo $ROUND | cut -d'"' -f10 | tail -n1`
215                ID=`echo $ROUND | cut -d'"' -f6 | tail -n1`
216                NEWPAGE="http://www.ecostream.tv/stream/$ID.html"
217                EPISODE=`echo $TITLE | tr ' ' '\n' | tail -n1`
218                PICNAME=s"$SEASON"e"$EPISODE".jpg
219                PIC="http://atemio.dyndns.tv/mediathek/menu/$PICNAME"
220
221                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'`
222
223                if [ ! -z "$TITLE" ] && [ ! -z "$NEWPAGE" ];then
224                        if [ ! -e $TMP/$PARSER.$INPUT.$FILENAME.list ];then
225                                touch $TMP/$PARSER.$INPUT.$FILENAME.list
226                        fi
227#gehen beide varianten weiss nur nicht ob die folgen dann stimmen
228#                       LINE="$TITLE#$SRC $SRC hoster $PARAM $count#$PIC#$PICNAME#$NAME#111"
229                        LINE="$TITLE#$NEWPAGE#$PIC#$PICNAME#$NAME#14"
230
231                        echo "$LINE" >> $TMP/$PARSER.$INPUT.list
232                fi
233
234        done 3<$TMP/cache.$PARSER.$INPUT.2
235        rm $TMP/cache.* > /dev/null 2>&1
236
237        echo "$TMP/$PARSER.$INPUT.list"
238}
239
240
241case $INPUT in
242        init) $INPUT;;
243        mainmenu) $INPUT;;
244        videos) $INPUT;;
245        parts) $INPUT;;
246        serien) $INPUT;;
247        hoster) $INPUT;;
248        search) $INPUT;;
249        page) $INPUT;;
250        episodelist) $INPUT;;
251esac
252
Note: See TracBrowser for help on using the repository browser.