Twitter scraper description (#221)

* feat(scrapers/twitter): return received tweet text

Also: use url and username from received json for the sake of consistent capitalizaton

* fix: all fields are under "tweet"
This commit is contained in:
mdashlw 2024-04-05 19:59:16 +03:00 committed by GitHub
parent 5a6b2bd874
commit 2cfde149ef
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -13,9 +13,10 @@ defmodule Philomena.Scrapers.Twitter do
{:ok, %Tesla.Env{status: 200, body: body}} = Philomena.Http.get(api_url)
json = Jason.decode!(body)
tweet = json["tweet"]
images =
Enum.map(json["tweet"]["media"]["photos"], fn p ->
Enum.map(tweet["media"]["photos"], fn p ->
%{
url: "#{p["url"]}:orig",
camo_url: Camo.Image.image_url(p["url"])
@ -23,8 +24,9 @@ defmodule Philomena.Scrapers.Twitter do
end)
%{
source_url: "https://twitter.com/#{user}/status/#{status_id}",
author_name: user,
source_url: tweet["url"],
author_name: tweet["author"]["screen_name"],
description: tweet["text"],
images: images
}
end