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

Last change on this file since 44949 was 44503, checked in by obi, 4 years ago

opti next step

  • Property svn:executable set to *
File size: 5.7 KB
Line 
1#!/bin/sh
2# first sh box parser for titannit mfg obi
3
4SRC=$1
5INPUT=$2
6PAGE=$3
7NEXT=$4
8PARSER=`echo $SRC | tr '/' '\n' | tail -n1 | sed 's/.sh//'`
9
10URL=https://www.googleapis.com
11NAME=Youtube
12
13case $2 in
14        init)   ;;
15        *)      . /tmp/localhoster/hoster.sh
16                mkdir $TMP > /dev/null 2>&1
17                FILENAME="$PARSER $INPUT $PAGE $NEXT"
18                FILENAME=$(echo $FILENAME | tr '&' '.' | tr '/' '.' | tr '?' '.' | tr '=' '.' | sed -e 's/\&\+/./g' -e 's#\/\+#.#g' -e 's/\?\+/./g' -e 's/;\+/./g' -e 's/=\+/./g' -e 's/ \+/./g' -e 's/\.\+/./g')
19                if [ -z "$FILENAME" ]; then FILENAME=none;fi
20                PICNAME="$FILENAME"
21                ;;
22esac
23
24if [ `echo $SRC | grep ^"/mnt/parser" | wc -l` -gt 0 ];then
25        TYPE="$SRC - Shell script"
26elif [ `echo $SRC | grep ^"/var/swap" | wc -l` -gt 0 ];then
27        TYPE="Swap - Shell script"
28elif [ `echo $SRC | grep ^"/mnt/swapextensions" | wc -l` -gt 0 ];then
29        TYPE="Mnt - Shell script"
30else
31        TYPE="Flash - Shell script"
32fi
33
34init()
35{
36        rm -rf $TMP > /dev/null 2>&1
37        echo "$NAME ($TYPE)#$SRC $SRC mainmenu#http://atemio.dyndns.tv/mediathek/menu/$PARSER.jpg#$PARSER.jpg#TiThek#0"
38}
39
40mainmenu()
41{
42        echo "Search 10#$SRC $SRC search '/youtube/v3/search?q=%search%&regionCode=US&part=snippet&hl=en_US&key=AIzaSyAL9jCDWvRD2G5nUgBrLEgEhZTQsRvzt80&type=video&maxResults=10'#http://atemio.dyndns.tv/mediathek/menu/search.jpg#search.jpg#$NAME#112" >$TMP/$FILENAME.list
43        echo "Search 50#$SRC $SRC search '/youtube/v3/search?q=%search%&regionCode=US&part=snippet&hl=en_US&key=AIzaSyAL9jCDWvRD2G5nUgBrLEgEhZTQsRvzt80&type=video&maxResults=50'#http://atemio.dyndns.tv/mediathek/menu/search.jpg#search.jpg#$NAME#112" >>$TMP/$FILENAME.list
44        echo "$TMP/$FILENAME.list"
45}
46
47search()
48{
49        if [ ! -e "$TMP/$FILENAME.list" ]; then
50                piccount=0
51#               $curlbin "$URL/$PAGE" -o "$TMP/cache.$FILENAME.1"
52                curl "$URL/$PAGE" -o "$TMP/cache.$FILENAME.1"
53                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
54
55                while read -u 3 ROUND; do
56                        ID=`echo $ROUND | sed 's!"videoId": !\nvideoId=!g' | grep ^videoId= | cut -d'"' -f2 | tail -n1`
57                        PIC=`echo $ROUND | sed 's!"url": !\nurl=!g' | grep ^url= | cut -d'"' -f2 | tail -n1`
58                        TITLE=`echo $ROUND | sed 's!"title": !\ntitle=!g' | grep ^title= | cut -d'"' -f2 | tail -n1`
59#                       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"
60#                       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"
61                        NEWPAGE="https://www.youtube.com/watch?v=$ID"
62
63                        if [ -z "$TITLE" ];then
64                                TITLE=`echo $ROUND | cut -d"<" -f2 | cut -d">" -f2`
65                        fi
66
67                        if [ -z "$PIC" ]; then
68                                PIC="http://atemio.dyndns.tv/mediathek/menu/default.jpg"
69                        fi
70
71                        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'`
72
73                        if [ ! -z "$TITLE" ] && [ ! -z "$NEWPAGE" ];then
74                                if [ ! -e $TMP/$FILENAME.list ];then
75                                        touch $TMP/$FILENAME.list
76                                fi
77                                piccount=`expr $piccount + 1`
78#                               LINE="$TITLE#$URL#$PIC#$FILENAME_$piccount.jpg#$NAME#14"
79#                               LINE="$TITLE#$SRC $SRC hoster '$NEWPAGE'#$PIC#$FILENAME.$piccount.jpg#$NAME#111"
80#                               LINE="$TITLE#$SRC $SRC hosterlist '$NEWPAGE'#$PIC#$FILENAME.$piccount.jpg#$NAME#0"
81                                LINE="$TITLE#$SRC $SRC play '$NEWPAGE'#$PIC#$FILENAME.$piccount.jpg#$NAME#111"
82
83                                echo "$LINE" >> $TMP/$FILENAME.list
84                        fi
85
86                done 3<$TMP/cache.$FILENAME.2
87                rm $TMP/cache.* > /dev/null 2>&1
88        fi
89        echo "$TMP/$FILENAME.list"
90}
91
92hosterlist()
93{
94        if [ ! -e "$TMP/$FILENAME.list" ]; then
95                /tmp/localhoster/hoster.sh youtube_dl $PAGE > $TMP/cache.$FILENAME.1
96                piccount=0
97
98                while read -u 3 ROUND; do
99                        TITLE=`echo $ROUND | sed 's/mime=/\nfound=\&/g' | grep ^"found=&" | cut -d'&' -f2 | sed 's#%2F#/#g'`
100                        PIC="http://atemio.dyndns.tv/mediathek/menu/`echo $TITLE | tr '/' '.'`.jpg"
101                        NEWPAGE="$ROUND"
102
103                        if [ -z "$PIC" ] || [ "$PIC" = ".jpg" ]; then
104                                PIC="http://atemio.dyndns.tv/mediathek/menu/default.jpg"
105                        fi
106
107                        if [ ! -z "$TITLE" ] && [ ! -z "$NEWPAGE" ];then
108                                if [ ! -e $TMP/$FILENAME.list ];then
109                                        touch $TMP/$FILENAME.list
110                                fi
111                                piccount=`expr $piccount + 1`
112                                LINE="$TITLE#$SRC $SRC play '$NEWPAGE'#$PIC#$FILENAME.$piccount.jpg#$NAME#111"
113                                echo "$LINE" >> $TMP/$FILENAME.list
114                        fi
115
116                done 3<$TMP/cache.$FILENAME.1
117                rm $TMP/cache.* > /dev/null 2>&1
118        fi
119        echo "$TMP/$FILENAME.list"
120}
121
122play()
123{
124#       rm $TMP/cache.$PARSER.$INPUT.* > /dev/null 2>&1
125#       /tmp/localhoster/hoster.sh get $PAGE > $TMP/cache.$PARSER.$INPUT.1
126#       STREAMURL=`cat $TMP/cache.$PARSER.$INPUT.1`
127#       echo $STREAMURL
128        /tmp/localhoster/hoster.sh youtube_dl $PAGE
129}
130
131hoster()
132{
133# not used anymore
134#       rm $TMP/cache.$PARSER.$INPUT.* > /dev/null 2>&1
135        /tmp/localhoster/hoster.sh youtube_dl $PAGE > $TMP/cache.$PARSER.$INPUT.1
136        STREAMURL=`cat $TMP/cache.$PARSER.$INPUT.1`
137        echo $STREAMURL
138}
139
140case $INPUT in
141        init) $INPUT;;
142        mainmenu) $INPUT;;
143        hoster) $INPUT;;
144        hosterlist) $INPUT;;
145        play) $INPUT;;
146        search) $INPUT;;
147esac
Note: See TracBrowser for help on using the repository browser.