diff options
author | EuAndreh <eu@euandre.org> | 2022-01-11 15:52:28 -0300 |
---|---|---|
committer | EuAndreh <eu@euandre.org> | 2022-01-11 15:52:28 -0300 |
commit | 83aae38bd1b73fb27a816f2eaeb137f5add8c614 (patch) | |
tree | 6a1a7ed3050c6c60c30936620488c0d578d791bc /_plugins | |
parent | _plugins/generate-media-files.rb: Remove in favor of Makefile (diff) | |
download | euandre.org-83aae38bd1b73fb27a816f2eaeb137f5add8c614.tar.gz euandre.org-83aae38bd1b73fb27a816f2eaeb137f5add8c614.tar.xz |
_plugins/generate-torrent.rb: Remove in favor of Makefile
Diffstat (limited to '')
-rw-r--r-- | _plugins/generate-torrent.rb | 42 |
1 files changed, 0 insertions, 42 deletions
diff --git a/_plugins/generate-torrent.rb b/_plugins/generate-torrent.rb deleted file mode 100644 index 580bcf8..0000000 --- a/_plugins/generate-torrent.rb +++ /dev/null @@ -1,42 +0,0 @@ -module Jekyll - class TorrentGenerator < Generator - safe true - - MEDIA_EXTENSION = { - 'podcasts' => 'ogg', - 'screencasts' => 'webm' - } - - def generate(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'] - extension = MEDIA_EXTENSION[name] - file = "#{date}-#{slug}.#{extension}" - media = "resources/#{name}/#{file}" - torrent = "#{media}.torrent" - - unless File.exist? torrent then - webseed = "#{site.config['url']}/#{media}" - puts "Missing '#{torrent}' file, generating..." - puts `mktorrent -f -v -d -c '#{document.content}' -n #{file} -w #{webseed} -o #{torrent} #{media}` - end - - checksum_file = "#{torrent}.checksum" - checksum = `sha256sum #{media} #{torrent} | sha256sum | awk '{ print $1 }'` - 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\nrm '#{torrent}' '#{checksum_file}'" - end - else - puts "Missing checksum for '#{media}', generating..." - File.write(checksum_file, checksum) - end - end - end - end - end - end -end |