Index: /titan/mediathek/localparser_secret/kkiste.sh
===================================================================
--- /titan/mediathek/localparser_secret/kkiste.sh	(revision 39676)
+++ /titan/mediathek/localparser_secret/kkiste.sh	(revision 39677)
@@ -6,8 +6,13 @@
 SRC=$1
 INPUT=$2
-PARAM=$3
-PAGE=$4
-
-FILENAME=`echo $PARAM | tr '/' '.' | tr '?' '.'  | tr '=' '.'`
+PAGE=$3
+NEXT=$4
+
+FILENAME=`echo $PAGE | tr '/' '.' | tr '?' '.'  | tr '=' '.'`
+FILENAME=`echo $FILENAME | tr '&' '.'`
+
+if [ -z "$FILENAME" ]; then
+	FILENAME=none
+fi
 
 URL="http://kkiste.to/"
@@ -38,53 +43,122 @@
 	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
 	echo "Serien#$SRC $SRC videos serien/?page= 1#http://atemio.dyndns.tv/mediathek/menu/series.jpg#series.jpg#$NAME#0" >>$TMP/$PARSER.$INPUT.list
+	echo "Genre#$SRC $SRC genre#http://atemio.dyndns.tv/mediathek/menu/search.jpg#gebre.jpg#$NAME#0" >>$TMP/$PARSER.$INPUT.list
+	echo "A-Z#$SRC $SRC sorted#http://atemio.dyndns.tv/mediathek/menu/search.jpg#search.jpg#$NAME#0" >>$TMP/$PARSER.$INPUT.list
 	echo "Search#$SRC $SRC search 'search/?q=%search%'#http://atemio.dyndns.tv/mediathek/menu/search.jpg#search.jpg#$NAME#112" >>$TMP/$PARSER.$INPUT.list
+
+#	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
+
 	echo "$TMP/$PARSER.$INPUT.list"
 }
 
+sorted()
+{
+	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"
+
+	rm $TMP/$PARSER.$INPUT.list > /dev/null 2>&1
+
+	for ROUND0 in $watchlist; do
+		TITLE=`echo $ROUND0`
+		filename=`echo $TITLE`
+		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
+	done
+  	echo "$TMP/$PARSER.$INPUT.list"
+}
+
+genre()
+{
+	watchlist="
+		abenteuer
+		action
+		animation
+		biographie
+		bollywood
+		dokumentation
+		drama
+		familie
+		fantasy
+		geschichte
+		horror
+		klassiker
+		komoedie
+		kriegsfilm
+		krimi
+		musik
+		mystery
+		romantik
+		sci-fi
+		sport
+		thriller
+		western
+		"
+	rm $TMP/$PARSER.$INPUT.list > /dev/null 2>&1
+
+	for ROUND0 in $watchlist; do
+		TITLE=`echo $ROUND0 | tr '/' '-' | sed 's/free-//g'`
+		filename=`echo $TITLE`	
+		echo "$TITLE#$SRC $SRC videos $ROUND0/?page= 1#http://atemio.dyndns.tv/mediathek/menu/$filename.jpg#$filename.jpg#$NAME#0" >> $TMP/$PARSER.$INPUT.list
+	done
+  	echo "$TMP/$PARSER.$INPUT.list"
+}
+
 search()
 {
-	if [ -e "$TMP/$PARSER.$INPUT.list" ] ; then
-		rm $TMP/$PARSER.$INPUT.list > /dev/null 2>&1
-	fi
-
-	piccount=0
-	$curlbin "$URL/$PARAM" -o "$TMP/cache.$PARSER.$INPUT.1"
-	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
-
-	while read -u 3 ROUND; do
-		ID=`echo $ROUND | cut -d'"' -f1 | tail -n1`
-		PIC=`echo $ROUND | sed 's!"url": !\nurl=!g' | grep ^url= | cut -d'"' -f2 | tail -n1`
-		TITLE=`echo $ROUND | sed 's!class="title">!\ntitle=<!g' | grep ^title= | cut -d'<' -f2`
-		NEWPAGE=`echo $ROUND | sed 's!<a href=!\nfound=!g' | grep ^found= | cut -d'"' -f2 | tail -n1`
-
-		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`
-
-		if [ -z "$PIC" ]; then
-			PIC="http://atemio.dyndns.tv/mediathek/menu/default.jpg"
+	if [ -z "$NEXT" ]; then NEXT="search"; fi
+
+	if [ ! -e "$TMP/$PARSER.$INPUT.$NEXT.$FILENAME.list" ]; then
+		piccount=0
+	
+		if [ "$NEXT" == "search" ]; then
+			$curlbin $URL/$PAGE -o $TMP/cache.$PARSER.$INPUT.$NEXT.$FILENAME.1
+		else
+			$curlbin $URL/$PAGE$NEXT -o $TMP/cache.$PARSER.$INPUT.$NEXT.$FILENAME.1
 		fi
-
-		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;/Ã
+	
+		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
+	
+		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`
+	
+		while read -u 3 ROUND; do
+			ID=`echo $ROUND | cut -d'"' -f1 | tail -n1`
+			PIC=`echo $ROUND | sed 's!"url": !\nurl=!g' | grep ^url= | cut -d'"' -f2 | tail -n1`
+			TITLE=`echo $ROUND | sed 's!class="title">!\ntitle=<!g' | grep ^title= | cut -d'<' -f2`
+			NEWPAGE=`echo $ROUND | sed 's!<a href=!\nfound=!g' | grep ^found= | cut -d'"' -f2 | tail -n1`
+	
+			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`
+	
+			if [ -z "$PIC" ]; then
+				PIC="http://atemio.dyndns.tv/mediathek/menu/default.jpg"
+			fi
+	
+			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'`
-
-		if [ ! -z "$TITLE" ] && [ ! -z "$NEWPAGE" ];then
-			if [ ! -e $TMP/$PARSER.$INPUT.$FILENAME.list ];then
-				touch $TMP/$PARSER.$INPUT.$FILENAME.list
+	
+			if [ ! -z "$TITLE" ] && [ ! -z "$NEWPAGE" ];then
+				if [ ! -e $TMP/$PARSER.$INPUT.$INPUT.$FILENAME.list ];then
+					touch $TMP/$PARSER.$INPUT.$INPUT.$FILENAME.list
+				fi
+				piccount=`expr $piccount + 1`
+				LINE="$TITLE $LANG#$SRC $SRC parts $NEWPAGE#$PIC#$PARSER.$INPUT.$FILENAME.$piccount.jpg#$NAME#0"
+	
+				echo "$LINE" >> $TMP/$PARSER.$INPUT.$NEXT.$FILENAME.list
 			fi
-			piccount=`expr $piccount + 1`
-			LINE="$TITLE $LANG#$SRC $SRC parts $NEWPAGE#$PIC#$PARSER.$INPUT.$FILENAME.$piccount.jpg#$NAME#0"
-
-			echo "$LINE" >> $TMP/$PARSER.$INPUT.list
+	
+		done 3<$TMP/cache.$PARSER.$INPUT.$NEXT.$FILENAME.2
+	
+		if [ "$NEXT" -lt "$pages" ]; then
+			NEXTPAGE=`expr $NEXT + 1`
+			LINE="Page ($NEXTPAGE/$pages)#$SRC $SRC search '$PAGE' $NEXTPAGE#http://atemio.dyndns.tv/mediathek/menu/next.jpg#next.jpg#$NAME#0"
+			echo "$LINE" >> $TMP/$PARSER.$INPUT.$NEXT.$FILENAME.list
 		fi
-
-	done 3<$TMP/cache.$PARSER.$INPUT.2
-	rm $TMP/cache.* > /dev/null 2>&1
-
-	echo "$TMP/$PARSER.$INPUT.list"
+	
+		rm $TMP/cache.* > /dev/null 2>&1
+	fi
+	echo "$TMP/$PARSER.$INPUT.$NEXT.$FILENAME.list"
 }
 
 videos()
 {
-	$curlbin -o - $URL$PARAM$PAGE | awk -v SRC=$SRC -v INPUT=$INPUT -v PARAM=$PARAM -v PAGE=$PAGE -v PARSER=$PARSER -v NAME=$NAME '
+	$curlbin -o - $URL$PAGE$NEXT | awk -v SRC=$SRC -v INPUT=$INPUT -v PAGE=$PAGE -v NEXT=$NEXT -v PARSER=$PARSER -v NAME=$NAME '
 
 BEGIN { title=""
@@ -117,5 +191,5 @@
                               }
 
-END   { print "Page " PAGE + 1 "#" SRC " " SRC " " INPUT " " PARAM " " PAGE + 1 "#http://atemio.dyndns.tv/mediathek/menu/next.jpg#next.jpg#" NAME "#0"
+END   { print "Page " NEXT + 1 "#" SRC " " SRC " " INPUT " " PAGE " " NEXT + 1 "#http://atemio.dyndns.tv/mediathek/menu/next.jpg#next.jpg#" NAME "#0"
       }
 ' >$TMP/$PARSER.$INPUT.list
@@ -125,7 +199,7 @@
 parts()
 {
-	$curlbin -o - $URL$PARAM >$TMP/cache.$PARSER.$INPUT.1
-
-	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 '
+	$curlbin -o - $URL$PAGE >$TMP/cache.$PARSER.$INPUT.1
+
+	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 '
 BEGIN { kz_parts=0
         count=1
@@ -146,5 +220,5 @@
 				 if(title!="") {
 	                 count = title
-    	             print "Staffel: " title "#" SRC " " SRC " episodelist " PARAM " " "season=" count "#http://atemio.dyndns.tv/mediathek/menu/s" title ".jpg#s" title ".jpg#" NAME "#0"
+    	             print "Staffel: " title "#" SRC " " SRC " episodelist " PAGE " " "season=" count "#http://atemio.dyndns.tv/mediathek/menu/s" title ".jpg#s" title ".jpg#" NAME "#0"
         		 }
                  next
@@ -166,5 +240,5 @@
                  split(b[1], a, " ")
                  part = a[2]
-                 print title "#" SRC " " SRC " hoster " PARAM " " count "#http://atemio.dyndns.tv/mediathek/menu/" part ".jpg#" part ".jpg#" NAME "#111"
+                 print title "#" SRC " " SRC " hoster " PAGE " " count "#http://atemio.dyndns.tv/mediathek/menu/" part ".jpg#" part ".jpg#" NAME "#111"
                  count=count+1
                  next
@@ -181,13 +255,13 @@
 hoster()
 {
-	i=`expr $PAGE \* 2`
-	data=`$curlbin "$URL$PARAM" | grep "data-det=" | cut -d'"' -f4`
+	i=`expr $NEXT \* 2`
+	data=`$curlbin "$URL$PAGE" | grep "data-det=" | cut -d'"' -f4`
 
 	if [ ! -z "$data" ];then
-		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`
+		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`
 	fi
 
 	if [ -z "$id" ];then
-		id=`$curlbin "$URL$PARAM" | grep "http://www.ecostream.tv/stream" | sed 's#http://www.ecostream.tv/stream/#\nlink=.#g' | cut -d"." -f2`
+		id=`$curlbin "$URL$PAGE" | grep "http://www.ecostream.tv/stream" | sed 's#http://www.ecostream.tv/stream/#\nlink=.#g' | cut -d"." -f2`
 	fi
 	echo "http://www.ecostream.tv/stream/$id.html"
@@ -200,9 +274,9 @@
 	fi
 
-	SEASON=`echo $PAGE | cut -d"=" -f2`
-	PARAM1=`echo $PARAM | sed 's!.html!/!g'`
-
-	data=`$curlbin "$URL$PARAM" | grep "data-movie=" | cut -d'"' -f4`
-	$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"
+	SEASON=`echo $NEXT | cut -d"=" -f2`
+	PARAM1=`echo $PAGE | sed 's!.html!/!g'`
+
+	data=`$curlbin "$URL$PAGE" | grep "data-movie=" | cut -d'"' -f4`
+	$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"
 ### 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/
 
@@ -253,4 +327,6 @@
 	page) $INPUT;;
 	episodelist) $INPUT;;
+	sorted) $INPUT;;
+	genre) $INPUT;;
 esac
 
