diff options
author | EuAndreh <eu@euandre.org> | 2020-12-28 13:28:41 -0300 |
---|---|---|
committer | EuAndreh <eu@euandre.org> | 2020-12-28 13:39:23 -0300 |
commit | b253e4c16e9b8321debbcc79c464b4f6387c0493 (patch) | |
tree | 03ae9ce333e96fa5422e8a1c474099f0f3b8f30d /_plugins | |
parent | generate-torrent.rb: Assert torrent is in sync with media file (diff) | |
download | euandre.org-b253e4c16e9b8321debbcc79c464b4f6387c0493.tar.gz euandre.org-b253e4c16e9b8321debbcc79c464b4f6387c0493.tar.xz |
generate-media-files.rb: Assert Ogg is in sync with FLAC
Diffstat (limited to '_plugins')
-rw-r--r-- | _plugins/generate-media-files.rb | 12 | ||||
-rw-r--r-- | _plugins/generate-torrent.rb | 6 |
2 files changed, 15 insertions, 3 deletions
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 diff --git a/_plugins/generate-torrent.rb b/_plugins/generate-torrent.rb index 16779b9..1de9870 100644 --- a/_plugins/generate-torrent.rb +++ b/_plugins/generate-torrent.rb @@ -26,11 +26,11 @@ module Jekyll puts `mktorrent #{TRACKERS} -f -v -d -c '#{document.content}' -n #{file} -w #{webseed} -o #{torrent} #{media}` end - checksum_file = "resources/#{name}/#{file}.checksum" + checksum_file = "#{torrent}.checksum" checksum = `sha256sum #{media} #{torrent} | sha256sum | awk '{ print $1 }'` - if File.exist? checksum_file + if File.exist? checksum_file then unless checksum == File.read(checksum_file) - raise "Checksum mismatch for '#{media}'.\nRe-generate the torrent files and checksums with:\n\nfind . -type f -name '*.torrent' -or -name '*.checksum' -delete" + raise "Checksum mismatch for '#{media}'.\nRe-generate the torrent files and checksums with:\n\nrm '#{torrent}' '#{checksum_file}'" end else puts "Missing checksum for '#{media}', generating..." |