summaryrefslogtreecommitdiff
path: root/yt2mp3
blob: 4982bcfab920f2f0b0dd64884dc77f3cc3800ee1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#!/bin/sh


usage()
{
  echo "$0 <yt link> <mp3 file>"
  exit 1
}

if [ -z $1 ] || [ -z $2 ]; then usage; fi

TMP_FN=/tmp/youtube-dl-$RANDOM
while [ -a $TMP_FN ]; do
  TMP_FN=/tmp/youtube-dl-$RANDOM
done
echo $TMP_FN

youtube-dl --output=$TMP_FN --format=18 "$1"
ffmpeg -i $TMP_FN -acodec libmp3lame -ac 2 -ab 128k -vn -y "$2"
rm $TMP_FN