#!/usr/bin/env ruby require_relative 'lib' videos = Dir[File.join(MEDIA_DIR, 'videos', '*')].sort.reverse html = File.read(File.join(SNIPPETS, 'head.html')) html += nav 'videos' videos.each_with_index do |dir, _i| date = File.basename(dir).split('_')[0] html += "
" title = File.basename(dir).split('_')[1..-1].join(' ') html += "

#{title}

" txt = File.read(File.join(dir, 'README')) txt = txt.gsub(/(http\S*)/, '\1') lines = txt.split("\n") html += lines.shift + '

' mp4 = File.join(MEDIA_URL, 'videos', File.basename(dir), title.gsub(' ', '_') + '.mp4') webm = File.join(MEDIA_URL, 'videos', File.basename(dir), title.gsub(' ', '_') + '.webm') poster = File.join(MEDIA_URL, 'videos', File.basename(dir), title.gsub(' ', '_') + '.webp') w, h = `ffprobe -v error -select_streams v:0 -show_entries stream=width,height -of csv=p=0 #{webm}`.chomp.split(',') html += "

" html += lines.join('
') html += '

' end html += '

 © pdp8 Creative Commons Attribution 4.0 International License' html += File.read(File.join(SNIPPETS, 'tail.html')) print_html 'videos', html