summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile49
-rwxr-xr-xhtml.rb25
-rwxr-xr-xmedia.sh12
-rwxr-xr-xpictures.nu26
4 files changed, 103 insertions, 9 deletions
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..19477c0
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,49 @@
+media_dir = /srv/media
+
+music_dir = $(media_dir)/music
+flac = $(wildcard $(music_dir)/*/*.flac)
+mp3 := $(subst flac,mp3,$(flac))
+
+img_dir = $(media_dir)/pictures
+src_dir = $(img_dir)/src
+thumb_dir = $(img_dir)/thumb
+www_dir = $(img_dir)/www
+img = $(wildcard $(src_dir)/*.jpeg)
+img_thumb := $(subst $(src_dir), $(thumb_dir), $(subst jpeg,webp, $(img)))
+img_www := $(subst $(src_dir), $(www_dir), $(subst jpeg,webp, $(img)))
+
+video_dir = /srv/media/videos
+video_webm = $(wildcard $(video_dir)/*/*.webm)
+video_mp4 := $(subst webm,mp4, $(video_webm))
+video_webp := $(subst webm,webp, $(video_webm))
+video_png := $(subst webm,png, $(video_webm))
+
+climbing_dir = /srv/media/climbing
+climbing_webm = $(wildcard $(climbing_dir)/*.webm)
+climbing_mp4 := $(subst webm,mp4, $(climbing_webm))
+climbing_webp := $(subst webm,webp, $(climbing_webm))
+
+all: music pictures videos climbing
+
+music: $(mp3)
+
+pictures: $(img_www) $(img_thumb)
+
+videos: $(video_mp4) $(video_webp)
+
+climbing: $(climbing_mp4) $(climbing_webp)
+
+%.mp3: %.flac
+ ffmpeg -i $< -ab 256k -map_metadata 0 -id3v2_version 3 $@
+
+%.webp: %.webm
+ ffmpeg -i $< -hide_banner -loglevel error -vf thumbnail -frames:v 1 -c:v png -f image2pipe - | convert - $@
+
+$(www_dir)/%.webp: $(src_dir)/%.jpeg
+ convert $< -resize 1536x1024 -quality 85 $@
+
+$(thumb_dir)/%.webp: $(src_dir)/%.jpeg
+ convert $< -resize 150x100 -quality 85 $@
+
+%.mp4: %.webm
+ ffmpeg -i $< -vf scale=1280:-2 -c:v h264 -c:a aac -b:a 128k -strict -2 -movflags faststart $@
diff --git a/html.rb b/html.rb
index 8ad6c07..171d487 100755
--- a/html.rb
+++ b/html.rb
@@ -41,6 +41,10 @@ def music_html
music = Dir[File.join(MEDIA_DIR, 'music', '*')].sort.reverse
html = File.read(File.join(SNIPPETS, 'head.html'))
html += nav 'music'
+ html += '<div class="post"><a href="https://faircamp.webr.ing/prev/pdp8.info/music.html">← prev</a> |
+ <a href="https://faircamp.webr.ing/">faircamp webring</a> |
+ <a href="https://faircamp.webr.ing/rand">random</a> |
+ <a href="https://faircamp.webr.ing/next/pdp8.info/music.html">next →</a></div>'
music.each do |dir|
next if dir.match 'alfadeo'
@@ -50,8 +54,9 @@ def music_html
html += "<h1>#{title}</h1>"
html += File.read(File.join(dir, 'README')).chomp.gsub("\n\n", '<p>').gsub("\n", '<br>') # + '<p>'
cover = File.join(MEDIA_URL, dir.sub(MEDIA_DIR, ''), 'cover.webp')
+ alt = File.read(File.join(dir, 'cover.txt')).chomp
w, h = `identify -format "%w %h" #{cover}`.chomp.split(' ')
- html += "<img class='cover' loading='lazy' width='#{w}' height='#{h}' src='#{cover}' alt='cover'>"
+ html += "<img class='cover' loading='lazy' width='#{w}' height='#{h}' src='#{cover}' alt='#{alt}'>"
html += '<table>'
copyrights_file = File.join(dir, 'copyrights')
copyrights = File.readlines(copyrights_file).collect { |l| l.chomp } if File.exist? copyrights_file
@@ -63,7 +68,8 @@ def music_html
html += "<td>#{name}</td>"
html += "<td>
<audio preload='none' controls>
- <source src='#{mp3}' type='audio/mpeg'>
+ <source src='#{mp3}' type='audio/mpeg'>
+ <a href=#{mp3}>#{mp3}</a>
</audio>
</td>"
html += '</tr>'
@@ -119,8 +125,9 @@ def video_html
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'>
+ <source src='#{webm}' type='video/webm'>
+ <source src='#{mp4}' type='video/mp4'>
+ <a href=#{mp4}>#{mp4}</a>
</video><p>
"
html += lines.join('<br>')
@@ -146,9 +153,9 @@ def climbing_html
html += '<div class="post">'
html += "<h1>#{post[:date]}</h1>"
html += "<video controls preload='none' width='#{w}' height='#{h}' poster=#{post[:webp]}>
- <source src='#{post[:webm]}' type='video/webm'>
- <source src='#{post[:mp4]}' type='video/mp4'>
- <a href=#{post[:mp4]}>#{post[:mp4]}</a>
+ <source src='#{post[:webm]}' type='video/webm'>
+ <source src='#{post[:mp4]}' type='video/mp4'>
+ <a href=#{post[:mp4]}>#{post[:mp4]}</a>
</video><p>
"
html += post[:text]
@@ -160,11 +167,11 @@ def climbing_html
end
music_html
-picture_html
+# picture_html
video_html
climbing_html
-%w[about code contact].each do |basename|
+%w[about code pictures contact].each do |basename|
file_html basename
end
diff --git a/media.sh b/media.sh
new file mode 100755
index 0000000..0c335df
--- /dev/null
+++ b/media.sh
@@ -0,0 +1,12 @@
+#!/bin/sh
+
+cd /srv/media
+export BORG_PASSCOMMAND="pass devices/u242757-sub2@u242757.your-storagebox.de.borg.key"
+borg_path="ssh://u242757-sub2@u242757.your-storagebox.de:23/./borg/"
+archive=$(borg list --last 1 --format '{archive}' $borg_path)
+#borg mount $borg_path::$archive ~/mnt /srv/media
+borg mount $borg_path::$archive ~/mnt /home/ch/img
+cd /home/ch/mnt/home/ch/img/
+nu -c "open meta.json | where rating == 3"
+cd ~
+umount ~/mnt
diff --git a/pictures.nu b/pictures.nu
new file mode 100755
index 0000000..c28974d
--- /dev/null
+++ b/pictures.nu
@@ -0,0 +1,26 @@
+#!/usr/bin/env nu
+
+let img_dir = '/home/ch/mnt/home/ch/img'
+let pub_dir = '/srv/media/pictures/src'
+
+$env.BORG_PASSCOMMAND = 'pass devices/u242757-sub2@u242757.your-storagebox.de.borg.key'
+let borg_path = 'ssh://u242757-sub2@u242757.your-storagebox.de:23/./borg/'
+let archive = (borg list --last 1 --format '{archive}' $borg_path)
+borg mount $'($borg_path)::($archive)' ~/mnt /home/ch/img
+cd $pub_dir
+let published = (ls | get name)
+cd $img_dir
+let all = (open meta.json | where rating == 3 | get id)
+let new = ($all | filter {|id| not ($id in $published) })
+#let remove = ($published | filter {|id| not ($id in $all)})
+cd original
+$new | each {|img|
+ let public = $'($pub_dir)/($img)'
+ echo $public
+ cp -uv $img $public
+ chmod u+w $public
+ exiv2 rm $public
+ exiv2 -M"set Xmp.dc.creator pdp8@pdp8.info" -M"set Xmp.dc.rights © pdp8@pdp8.info" -M"set Xmp.dc.license http://creativecommons.org/licenses/by-sa/4.0/" -M"set Xmp.xmpRights.UsageTerms Creative Commons Attribution-ShareAlike 4.0 International License" -M"set Xmp.xmpRights.Marked True" -M"set Xmp.dc.description Original artwork available from pdp8@pdp8.info" $public
+}
+cd ~
+umount ~/mnt