-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patharchive_extractor
More file actions
executable file
·28 lines (22 loc) · 976 Bytes
/
archive_extractor
File metadata and controls
executable file
·28 lines (22 loc) · 976 Bytes
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
#!/bin/sh -eu
ref_date="`date -Is -d "$1"`"
archive=~/archive/
artist=${artist-Instanssiradio `date +%Y`}
arch_file=`{
ls -U $archive
echo $ref_date
} | sort | grep -B 1 -x -- "$ref_date" | head -n 1`
arch_start=$(date +%s -d "`basename $arch_file .opus`")
cut_start=$(( `date +%s -d "$1"` - $arch_start))
cut_end=$(( `date +%s -d "$2"` - $arch_start))
# Generate safe filename based on the track name
outfile="`date -d "$1" '+%FT%R'`-`echo "$3" | iconv -f utf-8 -t ascii//TRANSLIT | tr '[:upper:]' '[:lower:]' |sed -sr -e 's/[^a-z0-9]+/-/g' -e 's/^-*//' -e 's/-*$//'`.opus"
echo "From: `date -d "$1"`"
echo "To: `date -d "$2"`"
echo "Source file: $arch_file"
echo "Cut start: $cut_start seconds"
echo "Cut end: $cut_end seconds"
echo "Title: $3"
echo "Target file: $outfile"
echo
nice ffmpeg -nostdin -i "$archive/$arch_file" -ss $cut_start -to $cut_end -c copy -metadata title="$3" -metadata "artist=$artist" "file:$outfile"