mirror of
https://github.com/philomena-dev/philomena.git
synced 2024-11-27 13:47:58 +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)
|
{:ok, %Tesla.Env{status: 200, body: body}} = Philomena.Http.get(api_url)
|
||||||
|
|
||||||
json = Jason.decode!(body)
|
json = Jason.decode!(body)
|
||||||
|
tweet = json["tweet"]
|
||||||
|
|
||||||
images =
|
images =
|
||||||
Enum.map(json["tweet"]["media"]["photos"], fn p ->
|
Enum.map(tweet["media"]["photos"], fn p ->
|
||||||
%{
|
%{
|
||||||
url: "#{p["url"]}:orig",
|
url: "#{p["url"]}:orig",
|
||||||
camo_url: Camo.Image.image_url(p["url"])
|
camo_url: Camo.Image.image_url(p["url"])
|
||||||
|
@ -23,8 +24,9 @@ defmodule Philomena.Scrapers.Twitter do
|
||||||
end)
|
end)
|
||||||
|
|
||||||
%{
|
%{
|
||||||
source_url: "https://twitter.com/#{user}/status/#{status_id}",
|
source_url: tweet["url"],
|
||||||
author_name: user,
|
author_name: tweet["author"]["screen_name"],
|
||||||
|
description: tweet["text"],
|
||||||
images: images
|
images: images
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue