-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.rb
executable file
·31 lines (26 loc) · 1.16 KB
/
build.rb
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
#!/usr/bin/env ruby
require 'shellwords'
system %(rm -rf drugsandwires.fail.cbz drugsandwires.fail; mkdir drugsandwires.fail)
# https://www.drugsandwires.fail/contents/
# on each chapter's page:
# copy($x('//article/div[1]/div/a/img/@src').map(a => a.value).join("\n"))
File.open('index.txt') do |f|
f.each_line.map(&:strip).reject { |url| url.empty? }.each_with_index do |url, i|
filename = "#{i}_#{File.basename(url)}"
filename_cli = Shellwords.shellescape(filename)
format = File.extname(filename)
puts filename
unless File.exists?(filename)
system %(curl #{Shellwords.shellescape(url)} --retry 5 -o #{filename_cli})
end
system %(ln -f #{filename_cli} drugsandwires.fail/#{i.to_s.rjust(4, '0')}#{format})
if format.downcase == '.gif'
filename_preview = "#{filename_cli[0..-4]}jpg"
unless File.exists?(filename_preview)
system %(ffmpeg -i #{filename_cli} -i gif-mark.png -filter_complex "overlay=0:0" -frames:v 1 -qscale:v 3 -y #{filename_preview})
end
system %(ln -f #{filename_preview} drugsandwires.fail/#{i.to_s.rjust(4, '0')}.jpg)
end
end
end
system %(zip -r drugsandwires.fail.cbz drugsandwires.fail)