Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[nyarlathotep] Convert podcast m4a files to mp3 #242

Merged
merged 1 commit into from
Nov 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion hosts/nyarlathotep/configuration.nix
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@ in
enable = true;
description = "Automatically tag new podcast files";
wantedBy = [ "multi-user.target" ];
path = with pkgs; [ inotifyTools id3v2 ];
path = with pkgs; [ ffmpeg inotifyTools id3v2 ];
unitConfig.RequiresMountsFor = "/mnt/nas";
serviceConfig = {
WorkingDirectory = "/mnt/nas/music/Podcasts/";
Expand Down
12 changes: 12 additions & 0 deletions hosts/nyarlathotep/jobs/tag-podcasts.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,18 @@ set -e

sleep 60

for m4afile in */in/*.m4a; do
if [[ ! -f "$m4afile" ]]; then
break
fi

bitrate=$(ffprobe -v quiet -of flat=s=_ -show_entries format=bit_rate "${m4afile}" | sed 's/[^0-9]*//g')
destination="$(echo "$m4afile" | sed 's:m4a$:mp3:')"
echo "m4a: ${m4afile} -> ${destination}" >&2
ffmpeg -y -i "$m4afile" -codec:a libmp3lame -b:a "$bitrate" -q:a 2 "$destination"
rm "$m4afile"
done

for mp3file in */in/*.mp3; do
if [[ ! -f "$mp3file" ]]; then
break
Expand Down