source: titan/mediathek/localparser_free/dmax.sh @ 42170

Last change on this file since 42170 was 42170, checked in by phillipsd2, 6 years ago

added dmax including search. working after obi included libx264 for all platforms.
mips and arm should work and sh4 7600 is working too

File size: 7.3 KB
Line 
1#!/bin/sh
2# first sh box parser for titannit mfg obi
3
4#. /tmp/localhoster/hoster.sh
5. /mnt/parser/hoster.sh
6
7SRC=$1
8INPUT=$2
9CURPAGE=$3
10MAXPAGE=$4
11PAGE=$5
12
13FILENAME=`echo $PAGE | tr '/' '.'`
14FILENAME=`echo $FILENAME | tr '&' '.'`
15
16if [ -z "$PAGE" ]; then
17        FILENAME=none
18fi
19
20URL=https://www.dmax.de
21PARSER=`echo $SRC | tr '/' '\n' | tail -n1 | sed 's/.sh//'`
22NAME="DMAX"
23
24mkdir $TMP > /dev/null 2>&1
25
26if [ `echo $SRC | grep ^"/mnt/parser" | wc -l` -gt 0 ];then
27        TYPE="$SRC - Shell script"
28elif [ `echo $SRC | grep ^"/var/swap" | wc -l` -gt 0 ];then
29        TYPE="Swap - Shell script"
30elif [ `echo $SRC | grep ^"/mnt/swapextensions" | wc -l` -gt 0 ];then
31        TYPE="Mnt - Shell script"
32else
33        TYPE="Flash - Shell script"
34fi
35
36init()
37{
38        rm -rf $TMP > /dev/null 2>&1
39        echo "$NAME ($TYPE)#$SRC $SRC mainmenu#http://atemio.dyndns.tv/mediathek/menu/$PARSER.jpg#$PARSER.jpg#TiThek#0"
40}
41
42mainmenu()
43{
44        echo "Genres#$SRC $SRC genre 1 0 'themen'#http://atemio.dyndns.tv/mediathek/menu/all-newfirst.jpg#all-newfirst.jpg#$NAME#0" > $TMP/$PARSER.$INPUT.list
45        echo "Search#$SRC $SRC series 1 0 '/api/search?query='#http://atemio.dyndns.tv/mediathek/menu/search.jpg#search.jpg#$NAME#112" >> $TMP/$PARSER.$INPUT.list
46
47        if [ -e "$TMP/$PARSER.new.list" ] ; then
48                rm $TMP/$PARSER.new.list
49        fi
50        if [ "`echo $TMP/$PARSER.search.*.list`" != "$TMP/$PARSER.search.*.list" ] ; then
51                rm $TMP/$PARSER.search.*.list
52        fi
53        if [ -e "$TMP/$PARSER.page.list" ] ; then
54                rm $TMP/$PARSER.page.list
55        fi
56
57        echo "$TMP/$PARSER.$INPUT.list"
58}
59
60genre()
61{
62        if [ ! -e "$TMP/$PARSER.$INPUT.list" ] ; then
63                $curlbin $URL/$PAGE -o $TMP/cache.$PARSER.$INPUT.1
64                cat $TMP/cache.$PARSER.$INPUT.1 | sed 's!sendungen"},{"submenu!sendungen"},\n{"submenu!g' | sed -n '/sendungen"},/{n;p;}' | cut -d "]" -f1 | sed -e 's!"title"!\n"title"!g' | sed "/submenu/d" > /$TMP/cache.$PARSER.$INPUT.2
65                while read -u 3 ROUND; do
66                        TITLE=`echo $ROUND | cut -d '"' -f4 | sed 's!"title":!!g' | cut -d '"' -f2`
67                        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/&%8211;/-/g' -e "s/&%8217;/'/g"`
68                        NEWPAGE=`echo $ROUND | sed 's/"url/\n"url/g' | grep ^'"url"' | sed 's!"url"!!g'| cut -d '"' -f2 | sed 's!themen!api/genres!g'`
69
70                        if [ -z  "$PIC" ]; then 
71                                PIC="http://atemio.dyndns.tv/mediathek/menu/default.jpg"
72                                TMPPIC="default.jpg"
73                        else
74                                TMPPIC=$PARSER'_'`echo $PIC | tr '/' '\n' | tail -n1`
75                        fi
76
77                        if [ ! -z "$TITLE" ] && [ ! -z "$NEWPAGE" ];then
78                                if [ `cat $TMP/$PARSER.$INPUT.list | grep ^"$NEWPAGE" | wc -l` -eq 0 ];then
79                                        if [ ! -e $TMP/$PARSER.$INPUT.list ];then
80                                                touch $TMP/$PARSER.$INPUT.list
81                                        fi
82                                        LINE="$TITLE#$SRC $SRC series 1 0 $NEWPAGE#$PIC#$TMPPIC#$NAME#0"
83                                        echo "$LINE" >> $TMP/$PARSER.$INPUT.list
84                                fi
85                        fi
86                done 3<$TMP/cache.$PARSER.$INPUT.2
87                rm $TMP/cache.$PARSER.$INPUT.* > /dev/null 2>&1
88        fi
89
90        if [ "`echo $TMP/$PARSER.series.*.list`" != "$TMP/$PARSER.series.*.list" ] ; then
91                rm $TMP/$PARSER.series.*.list
92        fi
93
94       
95        echo "$TMP/$PARSER.$INPUT.list"
96}
97
98series()
99{
100        if [ ! -e "$TMP/$PARSER.$INPUT.$CURPAGE.list" ] ; then
101               
102                if [ "$CURPAGE" -eq "1" ] ; then
103                        NEWPAGE=$PAGE
104                else
105                        NEWPAGE=$PAGE'?page='$CURPAGE
106                fi
107               
108                $curlbin $URL$NEWPAGE -o $TMP/cache.$PARSER.$INPUT.$CURPAGE.1
109
110                cat $TMP/cache.$PARSER.$INPUT.$CURPAGE.1 | sed 's!"id"!\n"id"!g' | sed '/alias/d' > /$TMP/cache.$PARSER.$INPUT.$CURPAGE.2
111                echo >> $TMP/cache.$PARSER.$INPUT.$CURPAGE.2
112                while read -u 3 ROUND; do
113                        TITLE=`echo $ROUND | sed 's/"title"/\n"title"/g' | grep '"title"' | cut -d ',' -f1 | sed 's!"title":!!g'`
114                        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/&%8211;/-/g' -e "s/&%8217;/'/g"`
115                        PIC=`echo $ROUND | sed 's/"src"/\n"src"/g' | sed 's!"src":!!g' | sed 's!id!!g' | grep "http[^ ]*"| cut -d '"' -f2`
116                        NEWPAGE=api/show-detail/`echo $ROUND | sed 's/"id"/\n"id"/' | grep ^'"id":' | sed 's!"id":!!g'| cut -d '"' -f2`
117
118                        if [ -z  "$PIC" ]; then 
119                                PIC="http://atemio.dyndns.tv/mediathek/menu/default.jpg"
120                                TMPPIC="default.jpg"
121                        else
122                                TMPPIC=$PARSER_`echo $PIC | tr '/' '\n' | tail -n1`
123                        fi
124
125                        if [ ! -z "$TITLE" ] && [ ! -z "$NEWPAGE" ];then
126                                        LINE="$TITLE#$SRC $SRC season 1 0 '$NEWPAGE'#$PIC#$TMPPIC#$NAME#0"
127                                        echo "$LINE" >> $TMP/$PARSER.$INPUT.$CURPAGE.list
128                               
129                        fi
130                done 3<$TMP/cache.$PARSER.$INPUT.$CURPAGE.2
131
132                MAXPAGE=$(grep '"totalPages"' $TMP/cache.$PARSER.$INPUT.$CURPAGE.2 |sed 's!"totalPages!\n"totalPages!g' | sed -n '/meta/{n;p;}' | sed 's!"totalPages":!!g' | cut -d '}' -f1)
133
134                if [ $MAXPAGE != $CURPAGE ];then
135               
136                NEWPAGE=`expr $CURPAGE + 1`
137                echo "Page $NEWPAGE#$SRC $SRC series $NEWPAGE $MAXPAGE '$PAGE'#http://atemio.dyndns.tv/mediathek/menu/next.jpg#next.jpg#$NAME#0" >> $TMP/$PARSER.$INPUT.$CURPAGE.list
138                fi
139               
140
141                rm $TMP/cache.$PARSER.$INPUT.$CURPAGE.* > /dev/null 2>&1
142        fi
143       
144        if [ "`echo $TMP/$PARSER.season.*.list`" != "$TMP/$PARSER.season.*.list" ] ; then
145                rm $TMP/$PARSER.season.*.list
146        fi
147       
148        echo "$TMP/$PARSER.$INPUT.$CURPAGE.list"
149}
150
151season()
152{
153        if [ ! -e "$TMP/$PARSER.$INPUT.$CURPAGE.list" ] ; then
154               
155                if [ "$CURPAGE" -eq "1" ] ; then
156                        NEWPAGE=$PAGE
157                else
158                        NEWPAGE=$PAGE'?page='`expr $CURPAGE - 1`
159                fi
160               
161                $curlbin $URL/$NEWPAGE -o $TMP/cache.$PARSER.$INPUT.$CURPAGE.1
162
163                cat $TMP/cache.$PARSER.$INPUT.$CURPAGE.1 | sed 's!"videos"!\n"videos"!g' | sed '/"show"/d' | sed 's!"id"!\n"id"!g' | sed '/"videos"/d' > /$TMP/cache.$PARSER.$INPUT.$CURPAGE.2
164                echo >> $TMP/cache.$PARSER.$INPUT.$CURPAGE.2
165                while read -u 3 ROUND; do
166                        TITLE=`echo $ROUND | sed 's!"name"!\n"name"!1' | grep ^'"name":' | cut -d '"' -f4`
167                        TITLE=`echo $TITLE | sed -e 's/-/ /g' -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/&%8211;/-/g' -e "s/&%8217;/'/g"`
168                        PIC=`echo $ROUND | sed 's!"src"!\n"src"!1' | grep '"src":' | cut -d '"' -f4`
169                        NEWPAGE=https://sonic-eu1-prod.disco-api.com/playback/videoPlaybackInfo/`echo $ROUND | sed 's!"id"!\n"id"!g' | grep ^'"id":' | cut -d '"' -f4`
170
171                        if [ -z  "$PIC" ]; then 
172                                PIC="http://atemio.dyndns.tv/mediathek/menu/default.jpg"
173                                TMPPIC="default.jpg"
174                        else
175                                TMPPIC=$PARSER'_'`echo $PIC | tr '/' '\n' | tail -n1`
176                        fi
177
178                        if [ ! -z "$TITLE" ] && [ ! -z "$NEWPAGE" ];then
179                               
180                                        LINE="$TITLE#$SRC $SRC play 0 0 '$NEWPAGE'#$PIC#$TMPPIC#$NAME#111"
181                                        echo "$LINE" >> $TMP/$PARSER.$INPUT.$CURPAGE.list
182                               
183                        fi
184                done 3<$TMP/cache.$PARSER.$INPUT.$CURPAGE.2
185
186                rm $TMP/cache.$PARSER.$INPUT.$CURPAGE.* > /dev/null 2>&1
187        fi
188       
189        if [ "`echo $TMP/$PARSER.episode.*.list`" != "$TMP/$PARSER.episode.*.list" ] ; then
190                rm $TMP/$PARSER.episode.*.list
191                rm /tmp/tithek/$PARSER.episode.* > /dev/null 2>&1
192       
193        fi
194       
195        echo "$TMP/$PARSER.$INPUT.$CURPAGE.list"
196}
197
198play()
199{
200        if [ -e "$TMP/$PARSER.$INPUT.list" ] ; then
201                rm $TMP/$PARSER.$INPUT.list
202        fi
203       
204        TOKEN=$($curlbin $URL | sed 's!"sonicToken"!\n"sonicToken"!g' | grep ^'"sonicToken":' | cut -d '"' -f4)
205        curl -H "Authorization: Bearer $TOKEN" $PAGE -o $TMP/cache.$PARSER.$INPUT.1a
206
207        cat $TMP/cache.$PARSER.$INPUT.1a | grep -A 2 'hls' | grep '"url"' | cut -d '"' -f4 > $TMP/cache.$PARSER.$INPUT.2
208#       cat $TMP/cache.$PARSER.$INPUT.1a | grep -A 2 'dash' | grep '"url"' | cut -d '"' -f4 >> $TMP/cache.$PARSER.$INPUT.2
209
210        cat $TMP/cache.$PARSER.$INPUT.2 > $TMP/$PARSER.playlist.list
211
212        echo "$TMP/$PARSER.playlist.list"
213}
214
215case $INPUT in
216        init) $INPUT;;
217        mainmenu) $INPUT;;
218        genre) $INPUT;;
219        series) $INPUT;;
220        season) $INPUT;;
221        play) $INPUT;;
222esac
Note: See TracBrowser for help on using the repository browser.