Skip to content

Commit

Permalink
Twitter scraper description (#221)
Browse files Browse the repository at this point in the history
* 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"
  • Loading branch information
mdashlw authored Apr 5, 2024
1 parent 5a6b2bd commit 2cfde14
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions lib/philomena/scrapers/twitter.ex
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,20 @@ 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"])
}
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
Expand Down

0 comments on commit 2cfde14

Please sign in to comment.