aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/home/.local/bin/tokodi
blob: e8a2495e9d51b49200f0e5ca96ebc58202030885 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#!/usr/bin/env sh

if [ -z "$1" ]; then
    url=$(xclip -o -selection clipboard)
elif [ "$1" = "-" ]; then
    read -r url
else
    url="$1"
fi

case "$url" in
*.m3u8*)
  prefix=''
  ;;
*)
  prefix='plugin://plugin.video.sendtokodi/?'
  ;;
esac

payload="$(printf '{"jsonrpc":"2.0", "id": 1, "method":"Player.Open","params": {"item": {"file":"%s%s"}}}' "$prefix" "$url")"

curl -u kodi:kodi 'http://ruiflix.pulpo:8080/jsonrpc' -X POST --data-raw "$payload" -H 'Content-Type: application/json'