Method: Zencodable::Encoder::Job#thumbnails

Defined in:
lib/zencodable.rb

#thumbnailsObject

ZC gives thumbnails for each output file format, but gives them the same name and overwrites them at the same S3 location. So if we have f formats, and ask for x thumbnails, we get x*f files described in the details API, but there are actually only x on the S3 server. So, the inject() here is done to pare that down to unique URLs, and give us the cols/vals that paperclip in VideoThumbnail is going to want



225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
# File 'lib/zencodable.rb', line 225

def thumbnails
  if thumbs = self.details['thumbnails']

    thumbs.inject([]) do |res,th|
      unless res.map{ |r| r[:thumbnail_file_name] }.include?(th['url'])
        res << { :thumbnail_file_name =>   th['url'],
                 :thumbnail_content_type =>th['format'],
                 :thumbnail_file_size =>   th['file_size_bytes'],
                 :thumbnail_updated_at =>  th['created_at']
               }
      end
      res
    end

  end
end