-
Notifications
You must be signed in to change notification settings - Fork 4
/
kast.sh
executable file
·173 lines (166 loc) · 6.38 KB
/
kast.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
#!/bin/bash
#Kast Variables
kasturl=$2
kodiport="8080" #kodi webserver port (default = 80)
kodiuser="kodi" #kodi webserver user (default = kodi)
kodipass="kodi" #kodi webserver password (default = kodi)
smbpath="smb://BAAL"
kodiipone="192.168.1.111" #kodi device IP (System -> System Info -> Summary)
kodiiptwo="192.168.1.101"
kodiipthree=""
kodiipfour=""
kodiipfive=""
if [ -z "$1" ];
then
OUTPUT=$(zenity --forms --title="Kast for Kodi" --text="" --separator=";" --add-entry="Device ID" --add-entry="URL / Path")
fi
zenid=$(awk -F";" '{print $1}' <<<$OUTPUT)
zenpath=$(awk -F";" '{print $2}' <<<$OUTPUT)
if [ -n "$zenid" ];
then
1=${zenid}
fi
if [ -n "$zenpath" ];
then
kasturl=${zenpath}
fi
if [[ "$1" == '1' ]]
then
kodiip=${kodiipone}
elif [[ "$1" == '2' ]]
then
kodiip=${kodiiptwo}
elif [[ "$1" == '3' ]]
then
kodiip=${kodiipthree}
elif [[ "$1" == '4' ]]
then
kodiip=${kodiipfour}
elif [[ "$1" == '5' ]]
then
kodiip=${kodiipfive}
elif [[ "$1" == *http* ]]
then
kodiip=${kodiipone}
kasturl=$1
else
kodiip=${kodiipone}
fi
if [[ "${kasturl}" == *youtube.com* ]]
then
vid=$( echo "${kasturl}" | tr '?&#' '\n\n' | grep -e '^v=' | cut -d'=' -f2 )
purl='plugin://plugin.video.youtube/?action=play_video&videoid='${vid}
elif [[ "${kasturl}" == *youtu.be* ]]
then
vid=$( echo "${kasturl}" | tr '?&#' '\n\n' | grep -e '/' | cut -d'/' -f4 )
purl='plugin://plugin.video.youtube/?action=play_video&videoid='${vid}
elif [[ "${kasturl}" == *vimeo.com* ]]
then
vid=$( echo "${kasturl}" | tr '?&#' '\n\n' | grep -e '/' | cut -d'/' -f4 )
purl='plugin://plugin.video.vimeo/?action=play_video&videoid='${vid}
elif [[ "${kasturl}" == *thedailyshow.com* ]]
then
vid=$( echo "${kasturl}" | perl -MURI::Escape -ne 'print uri_escape($_)' )
vname=$( echo "${kasturl}" | grep -e '/' | cut -d'/' -f5 )
if [[ "$" == *thedailyshow.com/watch* ]]
then
vname=$( echo "${kasturl}" | grep -e '/' | cut -d'/' -f6 )
fi
purl='plugin://plugin.video.the.daily.show/?url='${vid}'&mode=play&name='${vname}
elif [[ "${kasturl}" == *rt.com* ]]
then
if [[ "${kasturl}" == *on-air/rt-america-air/* ]]
then
purl='plugin://plugin.video.rt/?url=rtmp%3A%2F%2Frt.fms-04.visionip.tv%2Flive%2Frt-america-live-HD&mode=12'
elif [[ "${kasturl}" == *on-air/* ]]
then
purl='plugin://plugin.video.rt/?url=rtmp%3A%2F%2Frt.fms-04.visionip.tv%2Flive%2Frt-global-live-HD&mode=12'
elif [[ "${kasturl}" == *arabic*/live* ]]
then
purl='plugin://plugin.video.rt/?url=rtmp%3A%2F%2Frt.fms-04.visionip.tv%2Flive%2Frt-rusiyaalyaum-live-HD&mode=12'
elif [[ "${kasturl}" == *en_vivo* ]]
then
purl='plugin://plugin.video.rt/?url=rtmp%3A%2F%2Frt.fms-04.visionip.tv%2Flive%2Frt-enespanol-live-HD&mode=12'
else
vid=$( echo "${kasturl}" | perl -MURI::Escape -ne 'print uri_escape($_)' )
vname=$( echo "${kasturl}" | grep -e '/' | cut -d'/' -f6 )
purl='plugin://plugin.video.rt/?url=plugin%3A%2F%2Fplugin.video.rt%2F%3Furl%3D'${vid}'%26name%3D'${vname}'%26mode%3D19&mode=12'
fi
elif [[ "${kasturl}" == *colbertnation.com* ]]
then
vid=$( echo "${kasturl}" | perl -MURI::Escape -ne 'print uri_escape($_)' )
vname=$( echo "${kasturl}" | grep -e '/' | cut -d'/' -f5 )
purl='plugin://plugin.video.the.colbert.report/?url='${vid}'&mode=play&name='${vname}
elif [[ "${kasturl}" == *break.com* ]]
then
vid=$( echo "${kasturl}" | awk -F"-" '{print ($(NF))}' )
purl='plugin://plugin.video.break_com/?url='${vid}'&mode=playVideo'
elif [[ "${kasturl}" == *time.com* ]]
then
vid=$( echo "${kasturl}" | tr '_' '\n\n' | grep -e '/' | cut -d'/' -f7 | cut -d',' -f3 )
purl='plugin://plugin.video.time_com/?url='${vid}'&mode=playBrightCoveStream'
elif [[ "${kasturl}" == *collegehumor.com* ]]
then
vid=$( echo "${kasturl}" | cut -c29- | perl -MURI::Escape -ne 'print uri_escape($_)' )
purl='plugin://plugin.video.collegehumor/watch/'${vid}
elif [[ "${kasturl}" == *twitch.tv* ]]
then
vid=$( echo "${kasturl}" | cut -c22- )
purl='plugin://plugin.video.twitch/playLive/'${vid}'/'
elif [[ "${kasturl}" == *dailymotion.com* ]]
then
vid=$( echo "${kasturl}" | cut -c34-41 )
purl='plugin://plugin.video.dailymotion_com/?url='${vid}'&mode=playVideo'
elif [[ "${kasturl}" == *mixcloud.com* ]]
then
vid=$( echo "${kasturl}" | cut -c24- | perl -MURI::Escape -ne 'print uri_escape($_)' )
purl='plugin://plugin.audio.mixcloud/?mode=40&key='${vid}
elif [[ "${kasturl}" == *theonion.com* ]]
then
vid=$( echo "${kasturl}" | perl -MURI::Escape -ne 'print uri_escape($_)' )
purl='plugin://plugin.video.theonion_com/?url='${vid}'&mode=playVideo'
elif [[ "${kasturl}" == *cbsnews.com* ]]
then
vid=$( echo "${kasturl}" | perl -MURI::Escape -ne 'print uri_escape($_)' )
purl='plugin://plugin.video.cbsnews_com/?url='${vid}'&mode=playVideo'
elif [[ "${kasturl}" == *ign.com* ]]
then
vid=$( echo "${kasturl}" | perl -MURI::Escape -ne 'print uri_escape($_)' )
purl='plugin://plugin.video.ign_com/?url='${vid}'&mode=playVideo'
elif [[ "${kasturl}" == *howstuffworks.com* ]]
then
vid=$( echo "${kasturl}" | perl -MURI::Escape -ne 'print uri_escape($_)' )
purl='plugin://plugin.video.howstuffworks_com/?url='${vid}'&mode=playVideo'
elif [[ "${kasturl}" == *ustream.tv* ]]
then
vid=$( echo "${kasturl}" | tr '?&#' '\n\n' | grep -e 'socialstream/' | cut -d'/' -f5 )
purl='http://iphone-streaming.ustream.tv/ustreamVideo/'${vid}'/streams/live/playlist.m3u8'
elif [[ "${kasturl}" == *ebaumsworld.com* ]]
then
vid=$( echo "${kasturl}" | grep -e '/' | cut -d'/' -f6 )
purl='plugin://plugin.video.ebaumsworld_com/?url='${vid}'&mode=playVideo'
elif [[ "${kasturl}" == *roosterteeth.com* ]]
then
vid=$( echo "${kasturl}" | tr '?&#' '\n\n' | grep -e '^id=' | cut -d'=' -f2 )
purl='plugin://plugin.video.roosterteeth/?url='${vid}'&mode=3&name=Filename+Unvailable'
elif [[ "${kasturl}" == *aljazeera.com* ]]
then
purl='plugin://plugin.video.aljazeera/live/'
elif [[ "${kasturl}" == *magnet:* ]]
then
vid=$( echo "${kasturl}" | perl -MURI::Escape -ne 'print uri_escape($_)' )
purl='plugin://plugin.video.xbmctorrent/play/'${vid}
elif [[ "${kasturl}" == *file://* ]]
then
vid=$( echo "${kasturl}" | awk -F"file://$HOME" '{print ($(NF))}' )
purl=${smbpath}${vid}
elif [[ "${kasturl}" == */home/* ]]
then
vid=$( echo "${kasturl}" | awk -F"$HOME" '{print ($(NF))}' )
purl=${smbpath}${vid}
else
purl=${kasturl}
fi
payload='{"jsonrpc": "2.0", "method": "Player.Open", "params":{ "item": {"file" : "'${purl}'" }}, "id" : 1}'
kodipath="http://${kodiip}:${kodiport}/jsonrpc"
curl -v -u "${kodiuser}:${kodipass}" -d "${payload}" -H "Content-type:application/json" -X POST "${kodipath}"