Skip to content

Commit

Permalink
Merge pull request #242 from barrucadu/nya/m4a-mp3
Browse files Browse the repository at this point in the history
[nyarlathotep] Convert podcast m4a files to mp3
  • Loading branch information
barrucadu authored Nov 9, 2023
2 parents a094c3c + 0eb0722 commit 439aa09
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
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

0 comments on commit 439aa09

Please sign in to comment.