summaryrefslogtreecommitdiff
path: root/social.rb
blob: 97742bbe95c9a985d6d55e65135095dcc926d744 (plain)
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
#!/usr/bin/env ruby
require 'uri'
require 'json'

Dir.chdir ARGV[0]
content = ['public', '', '']
date, title = File.basename(ARGV[0]).split('_', 2)
title.gsub!('_', ' ')
content << title + ' LP'
content << File.read('README')
# content << ''
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 #electronic #music #techno'
content << '=='
content << File.join("https://media.pdp8.info/music/#{File.basename ARGV[0]}",
                     'cover.jpeg') + "\t" + `exiv2 -K Xmp.dc.description -P v 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`