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

Last change on this file since 43022 was 42929, checked in by andyjetset, 5 years ago

fix youb

  • 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                curl "$URL/$PAGE" -o "$TMP/cache.$FILENAME.1"
56                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
57
58                while read -u 3 ROUND; do
59                        ID=`echo $ROUND | sed 's!"videoId": !\nvideoId=!g' | grep ^videoId= | cut -d'"' -f2 | tail -n1`
60                        PIC=`echo $ROUND | sed 's!"url": !\nurl=!g' | grep ^url= | cut -d'"' -f2 | tail -n1`
61                        TITLE=`echo $ROUND | sed 's!"title": !\ntitle=!g' | grep ^title= | cut -d'"' -f2 | tail -n1`
62#                       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"
63#                       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"
64                        NEWPAGE="https://www.youtube.com/watch?v=$ID"
65
66                        if [ -z "$TITLE" ];then
67                                TITLE=`echo $ROUND | cut -d"<" -f2 | cut -d">" -f2`
68                        fi
69
70                        if [ -z "$PIC" ]; then
71                                PIC="http://atemio.dyndns.tv/mediathek/menu/default.jpg"
72                        fi
73
74                        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'`
75
76                        if [ ! -z "$TITLE" ] && [ ! -z "$NEWPAGE" ];then
77                                if [ ! -e $TMP/$FILENAME.list ];then
78                                        touch $TMP/$FILENAME.list
79                                fi
80                                piccount=`expr $piccount + 1`
81#                               LINE="$TITLE#$URL#$PIC#$FILENAME_$piccount.jpg#$NAME#14"
82#                               LINE="$TITLE#$SRC $SRC hoster '$NEWPAGE'#$PIC#$FILENAME.$piccount.jpg#$NAME#111"
83#                               LINE="$TITLE#$SRC $SRC hosterlist '$NEWPAGE'#$PIC#$FILENAME.$piccount.jpg#$NAME#0"
84                                LINE="$TITLE#$SRC $SRC play '$NEWPAGE'#$PIC#$FILENAME.$piccount.jpg#$NAME#111"
85
86                                echo "$LINE" >> $TMP/$FILENAME.list
87                        fi
88
89                done 3<$TMP/cache.$FILENAME.2
90                rm $TMP/cache.* > /dev/null 2>&1
91        fi
92        echo "$TMP/$FILENAME.list"
93}
94
95hosterlist()
96{
97        if [ ! -e "$TMP/$FILENAME.list" ]; then
98                /tmp/localhoster/hoster.sh youtube_dl $PAGE > $TMP/cache.$FILENAME.1
99                piccount=0
100
101                while read -u 3 ROUND; do
102                        TITLE=`echo $ROUND | sed 's/mime=/\nfound=\&/g' | grep ^"found=&" | cut -d'&' -f2 | sed 's#%2F#/#g'`
103                        PIC="http://atemio.dyndns.tv/mediathek/menu/`echo $TITLE | tr '/' '.'`.jpg"
104                        NEWPAGE="$ROUND"
105
106                        if [ -z "$PIC" ] || [ "$PIC" = ".jpg" ]; then
107                                PIC="http://atemio.dyndns.tv/mediathek/menu/default.jpg"
108                        fi
109
110                        if [ ! -z "$TITLE" ] && [ ! -z "$NEWPAGE" ];then
111                                if [ ! -e $TMP/$FILENAME.list ];then
112                                        touch $TMP/$FILENAME.list
113                                fi
114                                piccount=`expr $piccount + 1`
115                                LINE="$TITLE#$SRC $SRC play '$NEWPAGE'#$PIC#$FILENAME.$piccount.jpg#$NAME#111"
116                                echo "$LINE" >> $TMP/$FILENAME.list
117                        fi
118
119                done 3<$TMP/cache.$FILENAME.1
120                rm $TMP/cache.* > /dev/null 2>&1
121        fi
122        echo "$TMP/$FILENAME.list"
123}
124
125play()
126{
127#       rm $TMP/cache.$PARSER.$INPUT.* > /dev/null 2>&1
128#       /tmp/localhoster/hoster.sh get $PAGE > $TMP/cache.$PARSER.$INPUT.1
129#       STREAMURL=`cat $TMP/cache.$PARSER.$INPUT.1`
130#       echo $STREAMURL
131        /tmp/localhoster/hoster.sh youtube_dl $PAGE
132}
133
134hoster()
135{
136# not used anymore
137#       rm $TMP/cache.$PARSER.$INPUT.* > /dev/null 2>&1
138        /tmp/localhoster/hoster.sh youtube_dl $PAGE > $TMP/cache.$PARSER.$INPUT.1
139        STREAMURL=`cat $TMP/cache.$PARSER.$INPUT.1`
140        echo $STREAMURL
141}
142
143case $INPUT in
144        init) $INPUT;;
145        mainmenu) $INPUT;;
146        hoster) $INPUT;;
147        hosterlist) $INPUT;;
148        play) $INPUT;;
149        search) $INPUT;;
150esac
Note: See TracBrowser for help on using the repository browser.