mirror of
https://github.com/philomena-dev/philomena.git
synced 2025-04-11 05:57:37 +02:00
Update inkbunny.ex
This commit is contained in:
parent
90dad30309
commit
0c32bbf778
1 changed files with 6 additions and 9 deletions
|
@ -1,14 +1,11 @@
|
|||
defmodule Philomena.Scrapers.Inkbunny do
|
||||
@url_regex ~r|\Ahttps?://inkbunny\.net/s/([0-9]+)|
|
||||
|
||||
@spec can_handle?(URI.t(), String.t()) :: true | false
|
||||
def can_handle?(_uri, url) do
|
||||
String.match?(url, @url_regex)
|
||||
end
|
||||
|
||||
def scrape(_uri, url) do
|
||||
[submission_id] = Regex.run(@url_regex, url, capture: :all)
|
||||
def match_submission_id("https://inkbunny.net/s/" <> id), do: id
|
||||
def match_submission_id(_), do: nil
|
||||
|
||||
iex(1)> Test.match_submission_id("test")
|
||||
nil
|
||||
iex(2)> Test.match_submission_id("https://inkbunny.net/s/123456789")
|
||||
"123456789"
|
||||
api_url = "https://inkbunny.net/api_submissions.php?show_description=yes&sid=#{inkbunny_sid()}&submission_ids=#{submission_id}"
|
||||
{:ok, %Tesla.Env{status: 200, body: body}} = Philomena.Http.get(api_url)
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue