1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
#!/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 += "<div class='post' id='#{date}'>"
title = File.basename(dir).split('_')[1..-1].join(' ')
html += "<h1>#{title}</h1>"
txt = File.read(File.join(dir, 'README'))
txt = txt.gsub(/(http\S*)/, '<a href="\1">\1</a>')
lines = txt.split("\n")
html += lines.shift + '<p>'
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 += "<video controls preload='none' width='#{w}' height='#{h}' poster='#{poster}'>
<source src='#{webm}' type='video/webm'>
<source src='#{mp4}' type='video/mp4'>
<a href=#{mp4}>#{mp4}</a>
</video><p>
"
html += lines.join('<br>')
html += '</div>'
end
html += '<p> © pdp8 <a rel="license" href="http://creativecommons.org/licenses/by/4.0/">Creative Commons Attribution 4.0 International License</a>'
html += File.read(File.join(SNIPPETS, 'tail.html'))
print_html 'videos', html
|