From a781fe5046c4b33cd1c860d284bd799b4ca38f2e Mon Sep 17 00:00:00 2001 From: pdp8 Date: Wed, 14 Feb 2024 14:47:10 +0100 Subject: picture import --- Makefile | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ html.rb | 25 ++++++++++++++++--------- media.sh | 12 ++++++++++++ pictures.nu | 26 ++++++++++++++++++++++++++ 4 files changed, 103 insertions(+), 9 deletions(-) create mode 100644 Makefile create mode 100755 media.sh create mode 100755 pictures.nu 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 += '
← prev | + faircamp webring | + random | + next →
' music.each do |dir| next if dir.match 'alfadeo' @@ -50,8 +54,9 @@ def music_html html += "

#{title}

" html += File.read(File.join(dir, 'README')).chomp.gsub("\n\n", '

').gsub("\n", '
') # + '

' 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 += "cover" + html += "#{alt}" html += '' 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 += "" html += "" html += '' @@ -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 += "

" html += lines.join('
') @@ -146,9 +153,9 @@ def climbing_html html += '

' html += "

#{post[:date]}

" html += "

" 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 -- cgit v1.2.3

#{name}