aboutsummaryrefslogtreecommitdiff
path: root/_plugins/generate-media-files.rb
diff options
context:
space:
mode:
Diffstat (limited to '_plugins/generate-media-files.rb')
-rw-r--r--_plugins/generate-media-files.rb20
1 files changed, 20 insertions, 0 deletions
diff --git a/_plugins/generate-media-files.rb b/_plugins/generate-media-files.rb
new file mode 100644
index 0000000..2ef92db
--- /dev/null
+++ b/_plugins/generate-media-files.rb
@@ -0,0 +1,20 @@
+module Jekyll
+ class MediaFilesGenerator < Generator
+ safe true
+ priority :high
+
+ def generate(site)
+ site.collections['podcasts'].docs.each do |document|
+ date = document.data['date'].strftime('%Y-%m-%d')
+ 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
+ end
+ end
+ end
+end