mirror of
https://github.com/e621ng/dtext_rb.git
synced 2025-03-04 03:03:03 -05:00
18 lines
499 B
Ruby
18 lines
499 B
Ruby
require "dtext/dtext"
|
|
require "json"
|
|
require "zlib"
|
|
|
|
Zlib::GzipWriter.open("dtext_reference.json.gz") do |output|
|
|
Zlib::GzipReader.open("dtext.json.gz") do |file|
|
|
file.each_line.with_index do |line, i|
|
|
puts i if i % 10_000 == 0
|
|
json = JSON.parse(line)
|
|
|
|
allow_color = %w(wp ua ui).include?(json["id"][0..1])
|
|
dtext = DText.parse(json["body"], allow_color: allow_color)[0]
|
|
|
|
output.puts({ id: json["id"], i: json["body"], o: dtext }.to_json + "\n")
|
|
end
|
|
end
|
|
end
|