~yerinalexey/dotfiles

bb286f78d2f5c93f44c6faae8f20b19d96b5cb6d — Alexey Yerin a month ago 8577e97
dl-music: "defer" the clean-up with trap
1 files changed, 3 insertions(+), 4 deletions(-)

M scripts/dl-music
M scripts/dl-music => scripts/dl-music +3 -4
@@ 17,10 17,9 @@ dest="$MUSIC_DIRECTORY"/"$video_title"
orig="$(youtube-dl --get-filename -f bestaudio -o "$dest.%(ext)s" "$video_url")"
youtube-dl -f bestaudio -o "$dest.%(ext)s" "$video_url"

# Convert to opus
ffmpeg -v 16 -i "$orig" "$dest".opus
# defer rm "$orig"
trap 'rm "$orig"' EXIT

# Clean up
rm "$orig"
ffmpeg -v 16 -i "$orig" "$dest".opus

opus-edit "$dest".opus