source: titan/mediathek/localparser_secret/streamlive.sh @ 37152

Last change on this file since 37152 was 37152, checked in by obi, 8 years ago

optimize localhoster

  • Property svn:executable set to *
File size: 4.0 KB
Line 
1
2#!/bin/sh
3# first sh box parser for titannit mfg obi
4
5SRC=$1
6INPUT=$2
7FROM=$3
8PAGE=$4
9
10FILENAME=`echo $PAGE | tr '/' '.'`
11FILENAME=`echo $FILENAME | tr '&' '.'`
12
13if [ -z "$PAGE" ]; then
14        FILENAME=none
15fi
16
17ARCH=`cat /etc/.arch`
18URL=www.streamlive.to
19PARSER=`echo $SRC | tr '/' '\n' | tail -n1 | sed 's/.sh//'`
20NAME=StreamLive
21
22debuglevel=`cat /mnt/config/titan.cfg | grep debuglevel | cut -d"=" -f2`
23curlbin='curl -k -s -L --cookie /mnt/network/cookies --cookie-jar /mnt/network/cookies'
24if [ "$debuglevel" == "99" ]; then curlbin="$curlbin -v"; fi
25
26wgetbin="wget -q -T2"
27TMP=/tmp/localcache
28
29mkdir $TMP > /dev/null 2>&1
30
31if [ `echo $SRC | grep ^"/mnt/parser" | wc -l` -gt 0 ];then
32        TYPE="$SRC - Shell script"
33elif [ `echo $SRC | grep ^"/var/swap" | wc -l` -gt 0 ];then
34        TYPE="Swap - Shell script"
35elif [ `echo $SRC | grep ^"/mnt/swapextensions" | wc -l` -gt 0 ];then
36        TYPE="Mnt - Shell script"
37else
38        TYPE="Flash - Shell script"
39fi
40
41init()
42{
43        if [ "$ARCH" != "sh4" ] || [ -e /etc/.beta ];then
44                rm -f /mnt/network/cookies > /dev/null 2>&1
45                rm -rf $TMP > /dev/null 2>&1
46                echo "$NAME ($TYPE)#$SRC $SRC mainmenu#http://atemio.dyndns.tv/mediathek/menu/$PARSER.jpg#$PARSER.jpg#TiThek#0"
47        fi
48}
49
50mainmenu()
51{
52        echo "Category#$SRC $SRC category#http://atemio.dyndns.tv/mediathek/menu/categoty.jpg#categoty.jpg#$NAME#0" > $TMP/$PARSER.$INPUT.list
53        echo "$TMP/$PARSER.$INPUT.list"
54}
55
56category()
57{
58        if [ ! -e "/tmp/tithek/$PARSER.$INPUT.list" ]; then
59                tagcount=60
60                i=1
61                until [ "$i" -gt "$tagcount" ]
62                do
63                TITLE="Page $i"
64                echo "$TITLE#$SRC $SRC page category '?p=$i&q=&sort=1'#http://atemio.dyndns.tv/mediathek/menu/page.jpg#page.jpg#$NAME#0" >> /tmp/tithek/$PARSER.$INPUT.list
65                i=`expr $i + 1`
66                done
67        fi
68        echo "/tmp/tithek/$PARSER.$INPUT.list"
69}
70
71page()
72{
73        if [ ! -e "$TMP/$PARSER.$INPUT.$FROM.$FILENAME.list" ]; then
74                piccount=0
75
76                $curlbin $URL/$PAGE -o $TMP/cache.$PARSER.$FROM.$FILENAME.1
77
78                cat $TMP/cache.$PARSER.$FROM.$FILENAME.1 | tr '\n' '\r' |  tr '\r' ' ' | tr '\n' ' ' | tr '\t' ' ' | sed 's/ \+/ /g' | sed 's!<a href="http://www.streamlive.to/view/!\nhttp://www.streamlive.to/view/!g' | grep ^"http://www.streamlive.to/view/" | grep -v "<strong>" | grep -v "premium_only" >$TMP/cache.$PARSER.$FROM.$FILENAME.2
79
80                while read -u 3 ROUND; do
81
82                        URL=`echo $ROUND | cut -d'"' -f1`
83                        PIC=`echo $ROUND | sed 's!src="!\npic="!g' | grep ^pic= | cut -d'"' -f2 | tail -n1`
84                        TITLE=`echo $ROUND | sed 's!title="!\ntitle="!g' | grep ^title= | cut -d'"' -f2 | tail -n1`
85                        if [ -z "$TITLE" ];then
86                                TITLE=`echo $ROUND | cut -d"<" -f2 | cut -d">" -f2`
87                        fi
88               
89                        if [ -z "$PIC" ] || [ "$PIC" = "http:" ]; then 
90                                PIC="http://atemio.dyndns.tv/mediathek/menu/default.jpg"
91                        fi
92               
93                        TITLE=`echo $URL | tr '/' '\n' | tail -n1 | sed 's/_/ /g'`
94                        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'`
95
96                        if [ ! -z "$TITLE" ] && [ ! -z "$URL" ];then
97                                if [ ! -e $TMP/$PARSER.$INPUT.$FROM.$FILENAME.list ];then
98                                        touch $TMP/$PARSER.$INPUT.$FROM.$FILENAME.list
99                                fi
100                                piccount=$[$piccount+1]
101                                LINE="$TITLE#$URL#$PIC#$PARSER_$piccount.jpg#$NAME#91"
102                                echo "$LINE" >> $TMP/$PARSER.$INPUT.$FROM.$FILENAME.list
103                        fi
104       
105                done 3<$TMP/cache.$PARSER.$FROM.$FILENAME.2
106                rm $TMP/cache.* > /dev/null 2>&1
107        fi
108        echo "$TMP/$PARSER.$INPUT.$FROM.$FILENAME.list"
109}
110
111case $INPUT in
112        init) $INPUT;;
113        mainmenu) $INPUT;;
114        category) $INPUT;;
115        page) $INPUT;;
116esac
Note: See TracBrowser for help on using the repository browser.