diff options
Diffstat (limited to '')
-rw-r--r-- | _plugins/generate-torrent.rb | 2 | ||||
-rw-r--r-- | _plugins/linter.rb | 41 | ||||
-rw-r--r-- | default.nix | 1 |
3 files changed, 43 insertions, 1 deletions
diff --git a/_plugins/generate-torrent.rb b/_plugins/generate-torrent.rb index 1c642f4..a2077bc 100644 --- a/_plugins/generate-torrent.rb +++ b/_plugins/generate-torrent.rb @@ -11,7 +11,7 @@ module Jekyll def generate(site) site.collections.each do |name, collection| - if ['podcasts', 'screencasts'].include? name + if ['podcasts', 'screencasts'].include? name then collection.docs.each do |document| date = document.data['date'].strftime('%Y-%m-%d') slug = document.data['slug'] diff --git a/_plugins/linter.rb b/_plugins/linter.rb index 5d78c17..aa55c8c 100644 --- a/_plugins/linter.rb +++ b/_plugins/linter.rb @@ -134,9 +134,50 @@ module Jekyll end end + def assert_media_metadata(site) + site.collections.each do |name, collection| + if ['podcasts', 'screencasts'].include? name then + collection.docs.each do |document| + date = document.data['date'].strftime('%Y-%m-%d') + slug = document.data['slug'] + file = "resources/#{name}/#{date}-#{slug}.flac" + if name == 'podcasts' + stdout = `metaflac --export-tags-to=- #{file}` + file_metadata = stdout.strip.split("\n") + expected = [ + "COMMENTS=#{site.config['url']}/#{file}", + 'ARTIST=EuAndreh', + "DATE=#{date}", + "TITLE=#{document.data['title']}", + "ALBUM=#{site.config['t']['podcasts']['feed']['title'][document.data['lang']]}" + ] + expected.each do |metadata| + unless file_metadata.include? metadata + tags = expected.join('\\n').gsub(/'/, "'\"'\"'") + add_metadata_cmd = "metaflac --remove-all #{file}\nprintf '#{tags}\\n' | metaflac --import-tags-from=- #{file}" + check_metadata_cmd = "metaflac --export-tags-to=- #{file}" + raise "Missing metadata entry '#{metadata}' in '#{file}'.\nAdd it with:\n\n#{add_metadata_cmd}\n\nCheck with:\n #{check_metadata_cmd}" + end + end + + check_cover_cmd = "metaflac #{file} --export-picture-to=- | diff - static/favicon.svg" + `#{check_cover_cmd}` + unless $?.success? then + add_cover_cmd = "metaflac #{file} --import-picture-from='3|image/svg+xml||420x420x24|static/favicon.svg'" + raise "Cover art from '#{file}' doesn't match 'static/favicon.svg'.\nFix it with:\n\n#{add_cover_cmd}\n\nCheck with:\n #{check_cover_cmd}" + end + elsif name == 'screencasts' then + p document + end + end + end + end + end + def generate(site) assert_unique_ids(site) assert_frontmatter(site) + assert_media_metadata(site) assert_git_annex(site) end diff --git a/default.nix b/default.nix index 067f0f1..fc84d6e 100644 --- a/default.nix +++ b/default.nix @@ -26,6 +26,7 @@ let pkgs-next.mdpo mktorrent-newer ffmpeg + flac perl graphviz |