mirror of
https://github.com/philomena-dev/philomena.git
synced 2025-04-11 05:57:37 +02:00
whoops
This commit is contained in:
parent
8f5b248e57
commit
5286da3cfa
1 changed files with 9 additions and 12 deletions
|
@ -1,5 +1,5 @@
|
|||
defmodule Philomena.Scrapers.Furaffinity do
|
||||
@url_regex ~r|\Ahttps?://furaffinity\.net/view/([0-9]+)|
|
||||
@url_regex ~r|\Ahttps?://www.furaffinity\.net/view/([0-9]+)|
|
||||
|
||||
@spec can_handle?(URI.t(), String.t()) :: true | false
|
||||
def can_handle?(_uri, url) do
|
||||
|
@ -7,25 +7,22 @@ defmodule Philomena.Scrapers.Furaffinity do
|
|||
end
|
||||
|
||||
def scrape(_uri, url) do
|
||||
[_, submission_id] = Regex.run(@url_regex, url, capture: :all)
|
||||
[_, submission_id] = Regex.run(@url_regex, url, capture: :all)
|
||||
api_url = "https://faexport.spangle.org.uk/submission/#{submission_id}.json"
|
||||
{:ok, %Tesla.Env{status: 200, body: body}} = Philomena.Http.get(api_url)
|
||||
|
||||
json = Jason.decode!(body)
|
||||
[submission] = json
|
||||
|
||||
images = for x <- submission do
|
||||
%{
|
||||
url: "#{x["download"]}",
|
||||
camo_url: Camo.Image.image_url(x["thumbnail"])
|
||||
}
|
||||
end
|
||||
submission = Jason.decode!(body)
|
||||
|
||||
%{
|
||||
source_url: url,
|
||||
author_name: submission["name"],
|
||||
description: submission["description"],
|
||||
images: images
|
||||
images: [
|
||||
%{
|
||||
url: "#{submission["download"]}",
|
||||
camo_url: Camo.Image.image_url(submission["thumbnail"])
|
||||
}
|
||||
]
|
||||
}
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Reference in a new issue