Created
August 1, 2018 03:55
-
-
Save gnomon-/685280ebb26af6874912891ca008dd48 to your computer and use it in GitHub Desktop.
Grab the Seth Rogen TTC etiquette announcement WAVs and convert them to appropriately tagged and named FLAC files
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
#!/bin/bash | |
# http://twitter.com/bradTTC/status/1024344192061853696 | |
# blame gnomon | |
# prereqs: curl, awk, flac, metaflac, strings, grep | |
declare src='https://beta.ttc.ca/about-the-ttc/public-service-announcements' | |
declare alt='http://www.ttc.ca/sethrogen/index.jsp' | |
declare -i i=0 j=1 | |
for url in $( \ | |
curl -sL "$src" | \ | |
awk '/(wav|jpg)/ && match($0, /(href|src)="https:\/\/[^"]+"/) { | |
url=substr($0, RSTART, RLENGTH) | |
sub(/"$/,"",url) | |
sub(/^[^"]+"/,"",url) | |
print url | |
}' \ | |
) ; do | |
((i++)) | |
curl -vLOJ -D ".headers.${i}" --stderr ".log.${i}" "$url" & | |
done ; wait | |
i=1 | |
while [[ -e .headers.${i} ]] ; do | |
((i++)) | |
fn=$(grep -soE '"[^.]+\.wav"' ".headers.$((i-1))") || continue | |
fn=${fn##\"} | |
fn=${fn%%\"} | |
flac -8 -e -V \ | |
--tag="TITLE=${fn%%.wav}" \ | |
--tag="TRACKNUMBER=$j" \ | |
--tag="DATE=$(strings "$fn" | grep 2018)" \ | |
--output-prefix="$(printf '%02d' "$j"). " \ | |
"$fn" | |
((j++)) | |
done | |
metaflac \ | |
--set-tag "DESCRIPTION=$src / $alt" \ | |
--set-tag 'TOTALTRACKS=12' \ | |
--import-picture-from='SR-IMG_0789.jpg' \ | |
--add-replay-gain \ | |
*flac | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment