ugoira: store frame delays in MediaMetadata model.

Store Ugoira frame delays in the MediaMetadata model as a fake EXIF
field instead of in the PixivUgoiraFrameData model. This way we can get
rid of the PixivUgoiraFrameData model completely. This is a step towards
fixing #5264.
This commit is contained in:
evazion
2022-10-09 22:08:37 -05:00
parent 73cc0f65c2
commit 01d10a54f8
5 changed files with 35 additions and 0 deletions

View File

@@ -0,0 +1,21 @@
#!/usr/bin/env ruby
require_relative "base"
with_confirmation do
MediaMetadata.joins(:media_asset).where(media_asset: { file_ext: "zip" }).find_each do |meta|
frame_data = PixivUgoiraFrameData.find_by(md5: meta.media_asset.md5)
if frame_data.nil?
puts "Missing frame data: #{meta.media_asset.md5}"
next
elsif meta.metadata["Ugoira:FrameDelays"] == frame_data.frame_delays
next
end
json = meta.metadata.as_json.merge("Ugoira:FrameDelays" => frame_data.frame_delays)
meta.update!(metadata: json) if ENV.fetch("FIX", "false").truthy?
puts meta.as_json
end
end