From b253e4c16e9b8321debbcc79c464b4f6387c0493 Mon Sep 17 00:00:00 2001 From: EuAndreh Date: Mon, 28 Dec 2020 13:28:41 -0300 Subject: generate-media-files.rb: Assert Ogg is in sync with FLAC --- _plugins/generate-media-files.rb | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to '_plugins/generate-media-files.rb') diff --git a/_plugins/generate-media-files.rb b/_plugins/generate-media-files.rb index 2ef92db..388168c 100644 --- a/_plugins/generate-media-files.rb +++ b/_plugins/generate-media-files.rb @@ -9,11 +9,23 @@ module Jekyll slug = document.data['slug'] flac = "resources/podcasts/#{date}-#{slug}.flac" ogg = "resources/podcasts/#{date}-#{slug}.ogg" + unless File.exist? ogg then puts "Missing '#{ogg}' file, generating..." puts `ffmpeg -i #{flac} -ar 48000 -vn -c:a libvorbis -b:a 320k #{ogg}` site.static_files << Jekyll::StaticFile.new(site, site.source, '', ogg) end + + checksum_file = "#{ogg}.checksum" + checksum = `sha256sum #{flac} #{ogg} | sha256sum | awk '{ print $1 }'` + if File.exist? checksum_file then + unless checksum == File.read(checksum_file) + raise "Checksum mismatch for '#{flac}'.\nRe-generate the Ogg files and checksums with:\n\nrm '#{ogg}' '#{checksum_file}'" + end + else + puts "Missing checksum for '#{flac}', generating..." + File.write(checksum_file, checksum) + end end end end -- cgit v1.2.3