Created
December 25, 2018 09:50
-
-
Save bertfrees/1a375001fbae2760ccb4ad335a600bfe to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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