diff options
author | pdp8 <pdp8@pdp8.info> | 2023-08-16 15:25:17 +0200 |
---|---|---|
committer | pdp8 <pdp8@pdp8.info> | 2023-08-16 15:25:17 +0200 |
commit | ac90ab7c69b35546135cacf9ed2ed98261047dac (patch) | |
tree | 0eac8141030f85525ec56dbee3dea90ea4a5c600 | |
parent | a3ab009e96db2269dcf3f6dd1c103aa885186ee4 (diff) |
mail and social
-rw-r--r-- | .gitignore | 2 | ||||
-rwxr-xr-x | html.rb | 2 | ||||
-rw-r--r-- | html/540px-PDP-8_.jpg (renamed from snippets/540px-PDP-8_.jpg) | bin | 84238 -> 84238 bytes | |||
-rw-r--r-- | html/about.html (renamed from snippets/about.html) | 0 | ||||
-rw-r--r-- | html/code.html (renamed from snippets/code.html) | 0 | ||||
-rw-r--r-- | html/contact.html (renamed from snippets/contact.html) | 0 | ||||
-rw-r--r-- | html/head.html (renamed from snippets/head.html) | 0 | ||||
-rw-r--r-- | html/pdp8.png (renamed from snippets/pdp8.png) | bin | 723 -> 723 bytes | |||
-rw-r--r-- | html/pictures.html (renamed from snippets/pictures.html) | 0 | ||||
-rw-r--r-- | html/robots.txt (renamed from snippets/robots.txt) | 0 | ||||
-rw-r--r-- | html/slideshow.js (renamed from snippets/slideshow.js) | 0 | ||||
-rw-r--r-- | html/style.css (renamed from snippets/style.css) | 0 | ||||
-rw-r--r-- | html/tail.html (renamed from snippets/tail.html) | 0 | ||||
-rwxr-xr-x | mail.rb | 38 | ||||
-rwxr-xr-x | music.rb | 41 | ||||
-rwxr-xr-x | pictures.py | 52 | ||||
-rwxr-xr-x | social.rb | 31 | ||||
-rwxr-xr-x | video-metadata.rb | 31 |
18 files changed, 72 insertions, 125 deletions
diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..73baf4d --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +mail +cookies.txt @@ -4,7 +4,7 @@ require 'erb' MEDIA_DIR = '/srv/media' MEDIA_URL = 'https://media.pdp8.info' WWW_DIR = '/srv/www/pdp8-test' -SNIPPETS = File.join(File.dirname(__FILE__), 'snippets') +SNIPPETS = File.join(File.dirname(__FILE__), 'html') def nav(cat) html = '<nav>' diff --git a/snippets/540px-PDP-8_.jpg b/html/540px-PDP-8_.jpg Binary files differindex 1f67d13..1f67d13 100644 --- a/snippets/540px-PDP-8_.jpg +++ b/html/540px-PDP-8_.jpg diff --git a/snippets/about.html b/html/about.html index 55f6131..55f6131 100644 --- a/snippets/about.html +++ b/html/about.html diff --git a/snippets/code.html b/html/code.html index 6b43fee..6b43fee 100644 --- a/snippets/code.html +++ b/html/code.html diff --git a/snippets/contact.html b/html/contact.html index 4582664..4582664 100644 --- a/snippets/contact.html +++ b/html/contact.html diff --git a/snippets/head.html b/html/head.html index 78f38da..78f38da 100644 --- a/snippets/head.html +++ b/html/head.html diff --git a/snippets/pdp8.png b/html/pdp8.png Binary files differindex a11a860..a11a860 100644 --- a/snippets/pdp8.png +++ b/html/pdp8.png diff --git a/snippets/pictures.html b/html/pictures.html index 25bf1c2..25bf1c2 100644 --- a/snippets/pictures.html +++ b/html/pictures.html diff --git a/snippets/robots.txt b/html/robots.txt index eb05362..eb05362 100644 --- a/snippets/robots.txt +++ b/html/robots.txt diff --git a/snippets/slideshow.js b/html/slideshow.js index ea265e4..ea265e4 100644 --- a/snippets/slideshow.js +++ b/html/slideshow.js diff --git a/snippets/style.css b/html/style.css index 63fdb65..63fdb65 100644 --- a/snippets/style.css +++ b/html/style.css diff --git a/snippets/tail.html b/html/tail.html index 53ca8ca..53ca8ca 100644 --- a/snippets/tail.html +++ b/html/tail.html @@ -0,0 +1,38 @@ +#!/usr/bin/env ruby + +mailfile = if ARGV[1] and ARGV[1] == 'publish' + File.join(__dir__, 'mail', 'emails') + else + File.join(__dir__, 'mail', 'testmail') + end + +Dir.chdir ARGV[0] +date, title = File.basename(ARGV[0]).split('_', 2) +content = ["From: info@pdp8.info +Subject: [pdp8] #{title.gsub('_', ' ')} +Content-Type: text/plain +List-Unsubscribe: <mailto: info@pdp8.info?subject=unsubscribe>"] +content << '' +content << File.read('README') +content << '' +content << "https://pdp8.info/music.html\##{date}" +bc = if File.exist?('bandcamp') + File.read('bandcamp').chomp + else + "https://pdp8.bandcamp.com/album/#{title.gsub(' ', '-')}" + end +content << bc +content << '' +content << '==' +content << 'List-Unsubscribe: <mailto: info@pdp8.info?subject=unsubscribe>' +File.open('/tmp/mail.txt', 'w+') { |f| f.puts content.join("\n") } +# system 'hx /tmp/mail.txt' +content = File.read('/tmp/mail.txt') + +File.open(mailfile).each_line do |mail| + mail.chomp! + txt = "To: #{mail}\n" + content + cmd = "echo -e \"#{txt}\" | sendmail #{mail}" + # puts cmd + puts mail + `#{cmd}` +end diff --git a/music.rb b/music.rb deleted file mode 100755 index 60e487b..0000000 --- a/music.rb +++ /dev/null @@ -1,41 +0,0 @@ -#!/usr/bin/env ruby -require 'json' - -dir = ARGV[0] -Dir.chdir dir -input = JSON.load(File.read("config.json")) -input["album"] = File.basename(dir).gsub("_", " ") -input["artist"] ||= "pdp8@pdp8.info" -input["year"] ||= `date +%Y` -input["copyright"] ||= "Creative Commons Attribution-ShareAlike 4.0 International License (http://creativecommons.org/licenses/by-sa/4.0/)" -dest = File.join(ENV["HOME"], "pub", "music", `date +%Y-%m-%d_`.strip + input["album"].gsub(" ", "_")) -puts `mkdir -p '#{dest}'` -cover = File.join(dest, "cover" + File.extname(input["cover"])) -puts `cp -v '#{input["cover"]}' '#{cover}'` -puts `exiv2 rm #{cover}` -puts `exiv2 -M"set Xmp.dc.creator pdp8@pdp8.info" -M"set Xmp.dc.rights © pdp8@pdp8.info" -M"set Xmp.xmpRights.UsageTerms Creative Commons Attribution-ShareAlike 4.0 International License" -M"set Xmp.dc.license http://creativecommons.org/licenses/by-sa/4.0/)" -M"set Xmp.xmpRights.Marked True" #{cover}` -n = 1 -input["tracks"].each do |t, s| - File.open(File.join(dest, "README"), "w+") { |f| f.puts input["text"] } - flac = File.join(dest, sprintf("%02d-%s.flac", n, t)) - puts `cp -v '#{s}' '#{flac}'` - File.open("/tmp/meta", "w+") do |tmp| - tmp.puts "TITLE=#{t}" - tmp.puts "TRACK=#{n}" - [ - "artist", - "year", - "album", - "genre", - "copyright" - ].each do |tag| - tmp.puts "#{tag.upcase}=#{input[tag]}" - end - end - puts `metaflac --remove-all --dont-use-padding #{flac}` - puts `metaflac --import-tags-from=/tmp/meta #{flac}` - puts `metaflac --import-picture-from=#{cover} #{flac}` - mp3 = flac.sub("flac", "mp3") - puts `ffmpeg -i #{flac} -c:v copy -ab 256k -f mp3 #{mp3}` - n += 1 -end diff --git a/pictures.py b/pictures.py deleted file mode 100755 index dc93119..0000000 --- a/pictures.py +++ /dev/null @@ -1,52 +0,0 @@ -#!/usr/bin/env python3 - -import os -import numpy as np -import subprocess -import json - - -def descriptors(file): - npy = os.path.join( - os.path.dirname(file), - ".meta", - "descriptors", - os.path.basename(os.path.splitext(file)[0]) + ".npy", # TODO - ) - return np.load(npy, allow_pickle=False) - - -mail = "pdp8@pdp8.info" -cmd = "grep '3$' /home/ch/img/art/.meta/ratings|cut -f1" -favs = subprocess.check_output(cmd, shell=True, text=True).splitlines() -distances = {} -for fav in favs: - basename = os.path.basename(fav) - # out = os.path.join("/home/ch/pub/pictures/", basename) - out = os.path.join("/srv/www/pdp8-test/pictures/", basename) - cmd = "convert '" + fav + "' -strip -resize 1024x '" + out + "'" - os.system(cmd) - cmd = ( - "exiv2 -M'set Xmp.dc.creator " - + mail - + "' -M'set Xmp.dc.rights © " - + mail - + "' -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 " - + mail - + "' " - + out - ) - os.system(cmd) - """ - fav_d = descriptors(fav) - distances[basename] = {} - for img in favs: - if fav != img: - img_d = descriptors(img) - sim = np.dot(fav_d, img_d) / (np.linalg.norm(fav_d) * np.linalg.norm(img_d)) - img_basename = os.path.basename(img) - distances[basename][img_basename] = np.float64(1.0 - sim) -with open("/home/ch/pub/distances.js", "w") as f: - s = "distances = " + json.dumps(distances) - print(s, file=f) - """ diff --git a/social.rb b/social.rb new file mode 100755 index 0000000..06d5649 --- /dev/null +++ b/social.rb @@ -0,0 +1,31 @@ +#!/usr/bin/env ruby +require 'uri' +require 'json' + +Dir.chdir ARGV[0] +content = ['public', '', ''] +content << File.read('README') +content << '' +date, title = File.basename(ARGV[0]).split('_', 2) +content << "https://pdp8.info/music.html\##{date}" +content << '' +bc = if File.exist?('bandcamp') + File.read('bandcamp').chomp + else + "https://pdp8.bandcamp.com/album/#{title.gsub(' ', '-')}" + end +content << "Bandcamp: #{bc}" +content << '' +content << "#creativecommons \##{File.basename ARGV[0]}" +content << '==' +content << File.join("https://media.pdp8.info/music/#{File.basename ARGV[0]}", + 'cover.jpeg') + "\t" + `exiv2 -K Xmp.dc.description -P v /srv/media/music/2023-07-05_blurred_boundaries_of_perception/cover.jpeg`.chomp.sub( + /^lang=\S+ /, '' + ) + +Dir['*mp3'].each do |mp3| + content << File.join("https://media.pdp8.info/music/#{File.basename ARGV[0]}", "#{File.basename mp3}") +end +File.open('/tmp/content.txt', 'w+') { |f| f.puts content.join("\n") } +system 'hx /tmp/content.txt' +puts `curl -sb cookies.txt --data-binary @/tmp/content.txt -X POST https://social.pdp8.info/create` diff --git a/video-metadata.rb b/video-metadata.rb deleted file mode 100755 index be9e079..0000000 --- a/video-metadata.rb +++ /dev/null @@ -1,31 +0,0 @@ -#!/usr/bin/env ruby -require 'json' - -Dir[File.join(ARGV[0], "videos", "*", "*.mp4")].each do |mp4| - # tmp = File.join("/tmp", File.basename(mp4)) - tmp = mp4 + "~" - print `cp #{mp4} #{tmp}` - meta = { - "title" => File.basename(mp4, ".mp4").gsub("_", " "), - "date" => mp4.split("/")[-2].split("_")[0], - "artist" => "pdp8@pdp8.info", - "copyright" => "© pdp8@pdp8.info Creative Commons Attribution-ShareAlike 4.0 International License", - } - tmp = mp4 + "~" - print `cp #{mp4} #{tmp}` - cmd = "ffmpeg -i #{tmp} -c copy " - meta.each do |k, v| - cmd += "-metadata #{k}=\"#{v}\" " - end - cmd += " #{mp4}" - print `#{cmd}` - webm = mp4.sub(".mp4", ".webm") - tmp = webm + "~" - print `cp #{webm} #{tmp}` - cmd = "ffmpeg -i #{tmp} -c copy " - meta.each do |k, v| - cmd += "-metadata #{k}=\"#{v}\" " - end - cmd += " #{webm}" - print `#{cmd}` -end |