#!/usr/bin/env bash

# exit if a command fails
set -o errexit

# exit if required variables are not set
set -o nounset

# if incorrect number of arguments are provided, output syntax and exit
if [ "$#" -lt 2 ]; then
  echo -e "\nUsage: cast.sh <chromecast ip> <url to cast>\n"
  exit 1
fi

# assign arguments to variables
CHROMECAST_IP="$1"
CAST_URL="$2"

# call the requested url
curl --data-urlencode "receiver=${CHROMECAST_IP}" --data-urlencode "mi=${CAST_URL}" https://cast.seedno.de/cast