-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathvideo2huffduffer
executable file
·42 lines (33 loc) · 968 Bytes
/
video2huffduffer
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#!/usr/bin/env sh
# Need youtube-dl and ffmpeg to run this script. Install them via homebrew
# with:
#
# brew install youtube-dl
# brew install ffmpeg
# exit on any error
set -o errexit
# give help if no arguments
if [ $# -ne 1 ]; then
echo "syntax: $0 YOUTUBE-URL"
exit 1
fi
# https://www.youtube.com/watch?v=YltEym9H0x4
# http://vimeo.com/114046349
if echo $1 | grep "youtube.com" > /dev/null; then
CODE=`echo $1 | grep -o -e "=.*"`
CODE=${CODE:1}
FILENAME=$CODE.mp3
echo "YouTube video found: $CODE"
else
CODE=`echo $1 | egrep -o -e "[0-9]+"`
CODE=${CODE:1}
FILENAME=$CODE.mp3
echo "Vimeo video found: $CODE"
fi
youtube-dl -x --audio-format mp3 -o "$CODE.%(ext)s" $1 || { echo "Download failed"; exit 1;}
echo "Uploading $FILENAME to data.idldev.com/audio..."
scp $FILENAME idldev.com:~/data.idldev.com/audio
URL=http://data.idldev.com/audio/$FILENAME
HUFFDUFFER=http://huffduffer.com/add?page=$URL
open $HUFFDUFFER
rm -f $FILENAME