Mercurial > rsstweet
changeset 237:961d362e42c7 legit-client
The url in entity media isn't unique as they all point to the same thing
author | nanaya <me@nanaya.net> |
---|---|
date | Sat, 15 Jul 2023 01:47:34 +0900 |
parents | 498043313523 |
children | a04b4830eef2 |
files | app/lib/legit_client.rb app/views/tweets/_tweet.html.erb |
diffstat | 2 files changed, 11 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/app/lib/legit_client.rb Sat Jul 15 01:40:31 2023 +0900 +++ b/app/lib/legit_client.rb Sat Jul 15 01:47:34 2023 +0900 @@ -62,9 +62,8 @@ val = {} if entity_media['type'] == 'photo' - val[:url] = entity_media['media_url_https'] + val[:image_url] = entity_media['media_url_https'] elsif entity_media['type'] == 'video' - val[:url] = entity_media['expanded_url'] val[:variants] = entity_media['video_info']['variants'] .filter { |variant| variant['bitrate'].present? } .map do |variant| @@ -76,11 +75,18 @@ end if !val.empty? + val[:url] = entity_media['expanded_url'] val[:type] = entity_media['type'] val[:id] = entity_media['media_key'] end - ret[entity_media['display_url']] = val + key = if ret[entity_media['display_url']].nil? + entity_media['display_url'] + else + entity_media['media_key'] + end + + ret[key] = val end ret
--- a/app/views/tweets/_tweet.html.erb Sat Jul 15 01:40:31 2023 +0900 +++ b/app/views/tweets/_tweet.html.erb Sat Jul 15 01:47:34 2023 +0900 @@ -43,8 +43,8 @@ <p> <% tweet[:entity_media].each do |_short_url, media| %> <% if media[:type] == 'photo' %> - <%= link_to "#{media[:url]}?name=orig" do %> - <%= image_tag "#{media[:url]}?name=small", :alt => "attachment #{media[:id]}" -%> + <%= link_to "#{media[:image_url]}?name=orig" do %> + <%= image_tag "#{media[:image_url]}?name=small", :alt => "attachment #{media[:id]}" -%> <% end %> <% elsif media[:type] == 'video' %> <%= video_tag media[:variants]