Update inkbunny.ex

This commit is contained in:
Chaska 2024-04-20 20:25:11 -05:00 committed by GitHub
parent 90dad30309
commit 0c32bbf778
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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)