Skip to content

Instantly share code, notes, and snippets.

@bertfrees
Created December 25, 2018 09:50
Show Gist options
  • Save bertfrees/1a375001fbae2760ccb4ad335a600bfe to your computer and use it in GitHub Desktop.
Save bertfrees/1a375001fbae2760ccb4ad335a600bfe to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
SERVER=192.168.0.12:8080
upload() {
curl -X POST -F track=@"$1" http://$SERVER
}
if [ $# -ne 1 ]; then
echo "Usage: $0 FILE|URL" >&2
else
if [ -f "$1" ]; then
upload "$1"
else
case "$1" in
http://*|https://*|www.*)
case "$1" in
*youtube*)
tmpfile=/tmp/xwax-load-track/from-youtube.m4a
rm -f $tmpfile
youtube-dl -f 140 "$1" -o $tmpfile
upload $tmpfile
;;
*)
echo "URL not recognized: $1" >&2
;;
esac
;;
*)
echo "No such file: $1" >&2
;;
esac
fi
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment