Mercurial > rsstweet
diff app/lib/legit_client.rb @ 253:d726e8b92dd1
Support animated gif (same as video)
author | nanaya <me@nanaya.net> |
---|---|
date | Mon, 25 Mar 2024 02:49:50 +0900 |
parents | 151bc6d97d39 |
children |
line wrap: on
line diff
--- a/app/lib/legit_client.rb Tue Oct 17 00:04:11 2023 +0900 +++ b/app/lib/legit_client.rb Mon Mar 25 02:49:50 2024 +0900 @@ -56,17 +56,18 @@ json.each do |entity_media| val = {} - if entity_media['type'] == 'photo' - val[:image_url] = entity_media['media_url_https'] - elsif entity_media['type'] == 'video' - val[:variants] = entity_media['video_info']['variants'] - .filter { |variant| variant['bitrate'].present? } - .map do |variant| - { - bitrate: variant['bitrate'], - url: variant['url'], - } - end + case entity_media['type'] + when 'animated_gif', 'video' + val[:variants] = entity_media['video_info']['variants'] + .filter { |variant| variant['bitrate'].present? } + .map do |variant| + { + bitrate: variant['bitrate'], + url: variant['url'], + } + end + when 'photo' + val[:image_url] = entity_media['media_url_https'].sub(/\.([^.]+)$/, '?format=\1') end if !val.empty?