Mercurial > rsstweet
comparison app/lib/legit_client.rb @ 240:c454ea4f7b34 legit-client
Add support for note tweets (with no formatting)
author | nanaya <me@nanaya.net> |
---|---|
date | Sat, 15 Jul 2023 03:24:56 +0900 |
parents | a04b4830eef2 |
children | 4bca1528675e |
comparison
equal
deleted
inserted
replaced
239:c800506ae799 | 240:c454ea4f7b34 |
---|---|
93 end | 93 end |
94 | 94 |
95 def self.normalize_entity_urls(json) | 95 def self.normalize_entity_urls(json) |
96 ret = {} | 96 ret = {} |
97 | 97 |
98 json.each do |entity_url| | 98 (json || {}).each do |entity_url| |
99 ret[entity_url['url']] = entity_url['expanded_url'] | 99 ret[entity_url['url']] = entity_url['expanded_url'] |
100 end | 100 end |
101 | 101 |
102 ret | 102 ret |
103 end | 103 end |
125 | 125 |
126 { | 126 { |
127 id: json['rest_id'], | 127 id: json['rest_id'], |
128 created_at: Time.parse(json['legacy']['created_at']), | 128 created_at: Time.parse(json['legacy']['created_at']), |
129 user: normalize_user(json['core']['user_results']['result']), | 129 user: normalize_user(json['core']['user_results']['result']), |
130 message: json['legacy']['full_text'], | 130 message: json.dig('note_tweet', 'note_tweet_results', 'result', 'text') || json['legacy']['full_text'], |
131 retweet: normalize_tweet(json.dig('legacy', 'retweeted_status_result', 'result')), | 131 retweet: normalize_tweet(json.dig('legacy', 'retweeted_status_result', 'result')), |
132 quote: normalize_tweet(json.dig('quoted_status_result', 'result')), | 132 quote: normalize_tweet(json.dig('quoted_status_result', 'result')), |
133 quote_id: json['legacy']['quoted_status_id_str'], | 133 quote_id: json['legacy']['quoted_status_id_str'], |
134 reply_to_id: json['legacy']['in_reply_to_status_id_str'], | 134 reply_to_id: json['legacy']['in_reply_to_status_id_str'], |
135 reply_to_user_id: json['legacy']['in_reply_to_user_id_str'], | 135 reply_to_user_id: json['legacy']['in_reply_to_user_id_str'], |
136 reply_to_username: json['legacy']['in_reply_to_screen_name'], | 136 reply_to_username: json['legacy']['in_reply_to_screen_name'], |
137 entity_urls: normalize_entity_urls(json['legacy']['entities']['urls']), | 137 entity_urls: { **normalize_entity_urls(json['legacy']['entities']['urls']), **normalize_entity_urls(json.dig('note_tweet', 'note_tweet_results', 'result', 'entity_set', 'urls')) }, |
138 entity_media: normalize_entity_media(json.dig('legacy', 'extended_entities', 'media') || []), | 138 entity_media: normalize_entity_media(json.dig('legacy', 'extended_entities', 'media') || []), |
139 } | 139 } |
140 end | 140 end |
141 | 141 |
142 def self.normalize_user(json) | 142 def self.normalize_user(json) |