Mercurial > rsstweet
comparison app/lib/legit_client.rb @ 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 |
comparison
equal
deleted
inserted
replaced
236:498043313523 | 237:961d362e42c7 |
---|---|
60 | 60 |
61 json.each do |entity_media| | 61 json.each do |entity_media| |
62 val = {} | 62 val = {} |
63 | 63 |
64 if entity_media['type'] == 'photo' | 64 if entity_media['type'] == 'photo' |
65 val[:url] = entity_media['media_url_https'] | 65 val[:image_url] = entity_media['media_url_https'] |
66 elsif entity_media['type'] == 'video' | 66 elsif entity_media['type'] == 'video' |
67 val[:url] = entity_media['expanded_url'] | |
68 val[:variants] = entity_media['video_info']['variants'] | 67 val[:variants] = entity_media['video_info']['variants'] |
69 .filter { |variant| variant['bitrate'].present? } | 68 .filter { |variant| variant['bitrate'].present? } |
70 .map do |variant| | 69 .map do |variant| |
71 { | 70 { |
72 bitrate: variant['bitrate'], | 71 bitrate: variant['bitrate'], |
74 } | 73 } |
75 end | 74 end |
76 end | 75 end |
77 | 76 |
78 if !val.empty? | 77 if !val.empty? |
78 val[:url] = entity_media['expanded_url'] | |
79 val[:type] = entity_media['type'] | 79 val[:type] = entity_media['type'] |
80 val[:id] = entity_media['media_key'] | 80 val[:id] = entity_media['media_key'] |
81 end | 81 end |
82 | 82 |
83 ret[entity_media['display_url']] = val | 83 key = if ret[entity_media['display_url']].nil? |
84 entity_media['display_url'] | |
85 else | |
86 entity_media['media_key'] | |
87 end | |
88 | |
89 ret[key] = val | |
84 end | 90 end |
85 | 91 |
86 ret | 92 ret |
87 end | 93 end |
88 | 94 |