#!/bin/sh

if (pidof kodi.bin);
then
	address=127.0.0.1
else
	address=$(grep htpc -A3 "$HOME/.ssh/config" | awk '/Hostname/ {print $2}')
fi

if [ -z "$1" ]
then
	kodi-send --host="$address" -a "PlayPause"
else
	url=$(yt-dlp -f b -g --no-playlist "$1")
	kodi-send --host="$address" -a "PlayMedia($url,[noresume])"
fi