source: titan/mediathek/localparser_free/youtube.sh @ 42588

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

tithek testfix speedup init localhoster

  • Property svn:executable set to *
File size: 5.6 KB
Line 
1#!/bin/sh
2# first sh box parser for titannit mfg obi
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
13PARSER=`echo $SRC | tr '/' '\n' | tail -n1 | sed 's/.sh//'`
14
15FILENAME="$PARSER $INPUT $PAGE $NEXT"
16FILENAME=`echo $FILENAME | tr '&' '.' | tr '/' '.' | tr '?' '.' | tr ';' '.' | tr '=' '.' | sed 's/ \+/./g' | sed 's/\.\+/./g'`
17
18if [ -z "$FILENAME" ]; then
19        FILENAME=none
20fi
21
22URL=https://www.googleapis.com
23NAME=Youtube
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 "Search 10#$SRC $SRC search '/youtube/v3/search?q=%search%&regionCode=US&part=snippet&hl=en_US&key=AIzaSyAVwck6Y5fhDuEu6YyNGTEr88KPU7f_TqU&type=video&maxResults=10'#http://atemio.dyndns.tv/mediathek/menu/search.jpg#search.jpg#$NAME#112" >$TMP/$FILENAME.list
46        echo "Search 50#$SRC $SRC search '/youtube/v3/search?q=%search%&regionCode=US&part=snippet&hl=en_US&key=AIzaSyAVwck6Y5fhDuEu6YyNGTEr88KPU7f_TqU&type=video&maxResults=50'#http://atemio.dyndns.tv/mediathek/menu/search.jpg#search.jpg#$NAME#112" >>$TMP/$FILENAME.list
47        echo "$TMP/$FILENAME.list"
48}
49
50search()
51{
52        if [ ! -e "$TMP/$FILENAME.list" ]; then
53                piccount=0
54                $curlbin "$URL/$PAGE" -o "$TMP/cache.$FILENAME.1"
55                cat $TMP/cache.$FILENAME.1 | tr '\n' '\r' |  tr '\r' ' ' | tr '\n' ' ' | tr '\t' ' ' | sed 's/ \+/ /g' | sed 's!"kind":!\nkind":!g' | grep ^"kind" | grep videoId >$TMP/cache.$FILENAME.2
56
57                while read -u 3 ROUND; do
58                        ID=`echo $ROUND | sed 's!"videoId": !\nvideoId=!g' | grep ^videoId= | cut -d'"' -f2 | tail -n1`
59                        PIC=`echo $ROUND | sed 's!"url": !\nurl=!g' | grep ^url= | cut -d'"' -f2 | tail -n1`
60                        TITLE=`echo $ROUND | sed 's!"title": !\ntitle=!g' | grep ^title= | cut -d'"' -f2 | tail -n1`
61#                       URL="/get_video_info?el=leanback&cplayer=UNIPLAYER&cos=Windows&height=1080&cbr=Chrome&hl=en_US&cver=4&ps=leanback&c=TVHTML5&video_id=$ID&cbrver=40.0.2214.115&width=1920&cosver=6.1&ssl_stream=1"
62#                       URL="https://www.youtube.com/get_video_info?el=leanback&cplayer=UNIPLAYER&cos=Windows&height=1080&cbr=Chrome&hl=en_US&cver=4&ps=leanback&c=TVHTML5&video_id=$ID&cbrver=40.0.2214.115&width=1920&cosver=6.1&ssl_stream=1"
63                        NEWPAGE="https://www.youtube.com/watch?v=$ID"
64
65                        if [ -z "$TITLE" ];then
66                                TITLE=`echo $ROUND | cut -d"<" -f2 | cut -d">" -f2`
67                        fi
68
69                        if [ -z "$PIC" ]; then
70                                PIC="http://atemio.dyndns.tv/mediathek/menu/default.jpg"
71                        fi
72
73                        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'`
74
75                        if [ ! -z "$TITLE" ] && [ ! -z "$NEWPAGE" ];then
76                                if [ ! -e $TMP/$FILENAME.list ];then
77                                        touch $TMP/$FILENAME.list
78                                fi
79                                piccount=`expr $piccount + 1`
80#                               LINE="$TITLE#$URL#$PIC#$FILENAME_$piccount.jpg#$NAME#14"
81#                               LINE="$TITLE#$SRC $SRC hoster '$NEWPAGE'#$PIC#$FILENAME.$piccount.jpg#$NAME#111"
82#                               LINE="$TITLE#$SRC $SRC hosterlist '$NEWPAGE'#$PIC#$FILENAME.$piccount.jpg#$NAME#0"
83                                LINE="$TITLE#$SRC $SRC play '$NEWPAGE'#$PIC#$FILENAME.$piccount.jpg#$NAME#111"
84
85                                echo "$LINE" >> $TMP/$FILENAME.list
86                        fi
87
88                done 3<$TMP/cache.$FILENAME.2
89                rm $TMP/cache.* > /dev/null 2>&1
90        fi
91        echo "$TMP/$FILENAME.list"
92}
93
94hosterlist()
95{
96        if [ ! -e "$TMP/$FILENAME.list" ]; then
97                /tmp/localhoster/hoster.sh youtube_dl $PAGE > $TMP/cache.$FILENAME.1
98                piccount=0
99
100                while read -u 3 ROUND; do
101                        TITLE=`echo $ROUND | sed 's/mime=/\nfound=\&/g' | grep ^"found=&" | cut -d'&' -f2 | sed 's#%2F#/#g'`
102                        PIC="http://atemio.dyndns.tv/mediathek/menu/`echo $TITLE | tr '/' '.'`.jpg"
103                        NEWPAGE="$ROUND"
104
105                        if [ -z "$PIC" ] || [ "$PIC" = ".jpg" ]; then
106                                PIC="http://atemio.dyndns.tv/mediathek/menu/default.jpg"
107                        fi
108
109                        if [ ! -z "$TITLE" ] && [ ! -z "$NEWPAGE" ];then
110                                if [ ! -e $TMP/$FILENAME.list ];then
111                                        touch $TMP/$FILENAME.list
112                                fi
113                                piccount=`expr $piccount + 1`
114                                LINE="$TITLE#$SRC $SRC play '$NEWPAGE'#$PIC#$FILENAME.$piccount.jpg#$NAME#111"
115                                echo "$LINE" >> $TMP/$FILENAME.list
116                        fi
117
118                done 3<$TMP/cache.$FILENAME.1
119                rm $TMP/cache.* > /dev/null 2>&1
120        fi
121        echo "$TMP/$FILENAME.list"
122}
123
124play()
125{
126#       rm $TMP/cache.$PARSER.$INPUT.* > /dev/null 2>&1
127#       /tmp/localhoster/hoster.sh get $PAGE > $TMP/cache.$PARSER.$INPUT.1
128#       STREAMURL=`cat $TMP/cache.$PARSER.$INPUT.1`
129#       echo $STREAMURL
130        /tmp/localhoster/hoster.sh youtube_dl $PAGE
131}
132
133hoster()
134{
135# not used anymore
136#       rm $TMP/cache.$PARSER.$INPUT.* > /dev/null 2>&1
137        /tmp/localhoster/hoster.sh youtube_dl $PAGE > $TMP/cache.$PARSER.$INPUT.1
138        STREAMURL=`cat $TMP/cache.$PARSER.$INPUT.1`
139        echo $STREAMURL
140}
141
142case $INPUT in
143        init) $INPUT;;
144        mainmenu) $INPUT;;
145        hoster) $INPUT;;
146        hosterlist) $INPUT;;
147        play) $INPUT;;
148        search) $INPUT;;
149esac
Note: See TracBrowser for help on using the repository browser.