10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
# File 'lib/dragonfly_audio/processors/tag.rb', line 10
def call(content, properties)
raise UnsupportedFormat unless content.ext
raise UnsupportedFormat unless SUPPORTED_FORMATS.include?(content.ext.downcase)
properties = properties.each_with_object({}) { |(k, v), memo| memo[k.to_s] = v }
properties = properties.select { |key, _| PERMISSIBLE_PROPERTIES.include?(key) }
tempfile = Dragonfly::TempObject.new(content.tempfile)
TagLib::FileRef.open(tempfile.path) do |file|
return if file.null?
properties.each { |k, v| file.tag.send("#{k}=", v) }
file.save
end
content.update(tempfile)
end
|