mirror of
https://github.com/philomena-dev/philomena.git
synced 2024-11-23 20:18:00 +01:00
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:
parent
5a6b2bd874
commit
2cfde149ef
1 changed files with 5 additions and 3 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue