aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/dot_local/bin/executable_tokodi
blob: aec226c1e413081d276bba45f10acc67b7c9a512 (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=$(wl-paste)
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'