diff options
author | EuAndreh <eu@euandre.org> | 2020-12-27 23:41:13 -0300 |
---|---|---|
committer | EuAndreh <eu@euandre.org> | 2020-12-27 23:41:13 -0300 |
commit | e07ff2a1928be00bb7f7eb7fc82c8447a581c58f (patch) | |
tree | 4d0b3b37f73479cfc6d50d19e6f662d7b1ede596 /_plugins/linter.rb | |
parent | Add cover art to resources/podcasts/2020-12-19-a-test-entry.flac (diff) | |
download | euandre.org-e07ff2a1928be00bb7f7eb7fc82c8447a581c58f.tar.gz euandre.org-e07ff2a1928be00bb7f7eb7fc82c8447a581c58f.tar.xz |
linter.rb: Add assert_media_metadata
Diffstat (limited to '')
-rw-r--r-- | _plugins/linter.rb | 41 |
1 files changed, 41 insertions, 0 deletions
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 |