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

Last change on this file since 40146 was 40146, checked in by obi, 3 years ago

fix

  • Property svn:executable set to *
File size: 4.6 KB
Line 
1#!/bin/sh
2# first sh box parser for titannit mfg obi
3
4. /tmp/localhoster/hoster.sh
5
6SRC=$1
7INPUT=$2
8PAGE=$3
9NEXT=$4
10PARSER=`echo $SRC | tr '/' '\n' | tail -n1 | sed 's/.sh//'`
11
12FILENAME="$PARSER $INPUT $PAGE $NEXT"
13FILENAME=`echo $FILENAME | tr '&' '.' | tr '/' '.' | tr '?' '.' | tr ';' '.' | tr '=' '.' | sed 's/ \+/./g' | sed 's/\.\+/./g'`
14
15if [ -z "$FILENAME" ]; then
16        FILENAME=none
17fi
18
19URL=https://www.googleapis.com
20NAME=Youtube
21
22mkdir $TMP > /dev/null 2>&1
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 "Category#$SRC $SRC category#http://atemio.dyndns.tv/mediathek/menu/category.jpg#category.jpg#$NAME#0" > $TMP/$FILENAME.list
43        echo "Search 10#$SRC $SRC search '/youtube/v3/search?q=%search%&regionCode=US&part=snippet&hl=en_US&key=AIzaSyAd-YEOqZz9nXVzGtn3KWzYLbLaajhqIDA&type=video&maxResults=10'#http://atemio.dyndns.tv/mediathek/menu/search.jpg#search.jpg#$NAME#112" >$TMP/$FILENAME.list
44        echo "Search 50#$SRC $SRC search '/youtube/v3/search?q=%search%&regionCode=US&part=snippet&hl=en_US&key=AIzaSyAd-YEOqZz9nXVzGtn3KWzYLbLaajhqIDA&type=video&maxResults=50'#http://atemio.dyndns.tv/mediathek/menu/search.jpg#search.jpg#$NAME#112" >>$TMP/$FILENAME.list
45        echo "Search 100#$SRC $SRC search '/youtube/v3/search?q=%search%&regionCode=US&part=snippet&hl=en_US&key=AIzaSyAd-YEOqZz9nXVzGtn3KWzYLbLaajhqIDA&type=video&maxResults=100'#http://atemio.dyndns.tv/mediathek/menu/search.jpg#search.jpg#$NAME#112" >>$TMP/$FILENAME.list
46        echo "$TMP/$FILENAME.list"
47}
48
49search()
50{
51        if [ ! -e "$TMP/$FILENAME.list" ]; then
52                piccount=0
53                $curlbin "$URL/$PAGE" -o "$TMP/cache.$FILENAME.1"
54                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
55
56                while read -u 3 ROUND; do
57                        ID=`echo $ROUND | sed 's!"videoId": !\nvideoId=!g' | grep ^videoId= | cut -d'"' -f2 | tail -n1`
58                        PIC=`echo $ROUND | sed 's!"url": !\nurl=!g' | grep ^url= | cut -d'"' -f2 | tail -n1`
59                        TITLE=`echo $ROUND | sed 's!"title": !\ntitle=!g' | grep ^title= | cut -d'"' -f2 | tail -n1`
60#                       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"
61                        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"
62                        NEWPAGE="https://www.youtube.com/watch?v=$ID"
63
64                        if [ -z "$TITLE" ];then
65                                TITLE=`echo $ROUND | cut -d"<" -f2 | cut -d">" -f2`
66                        fi
67
68                        if [ -z "$PIC" ]; then
69                                PIC="http://atemio.dyndns.tv/mediathek/menu/default.jpg"
70                        fi
71
72                        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'`
73
74                        if [ ! -z "$TITLE" ] && [ ! -z "$NEWPAGE" ];then
75                                if [ ! -e $TMP/$FILENAME.list ];then
76                                        touch $TMP/$FILENAME.list
77                                fi
78                                piccount=$[$piccount+1]
79#                               LINE="$TITLE#$SRC $SRC list '$URL'#$PIC#$FILENAME_$piccount.jpg#$NAME#0"
80#                               LINE="$TITLE#$URL#$PIC#$FILENAME_$piccount.jpg#$NAME#14"
81                                LINE="$TITLE#$SRC $SRC hoster '$NEWPAGE'#$PIC#$FILENAME.$piccount.jpg#$NAME#111"
82                                echo "$LINE" >> $TMP/$FILENAME.list
83                        fi
84
85                done 3<$TMP/cache.$FILENAME.2
86                rm $TMP/cache.* > /dev/null 2>&1
87        fi
88        echo "$TMP/$FILENAME.list"
89}
90
91hoster()
92{
93        rm $TMP/cache.$FILENAME.* > /dev/null 2>&1
94        /tmp/localhoster/hoster.sh youtube_dl $PAGE > $TMP/cache.$FILENAME.1
95        STREAMURL=`cat $TMP/cache.$FILENAME.1 | head -n1`
96        echo $STREAMURL
97}
98
99case $INPUT in
100        init) $INPUT;;
101        mainmenu) $INPUT;;
102        hoster) $INPUT;;
103        search) $INPUT;;
104esac
Note: See TracBrowser for help on using the repository browser.