mirror of
https://github.com/philomena-dev/philomena.git
synced 2025-03-31 00:37:45 +02:00
Adding Derpibooru
This commit is contained in:
parent
53f2694650
commit
d499726636
3 changed files with 33 additions and 2 deletions
|
@ -8,6 +8,7 @@ defmodule Philomena.Scrapers do
|
||||||
Philomena.Scrapers.E621,
|
Philomena.Scrapers.E621,
|
||||||
Philomena.Scrapers.Furaffinity,
|
Philomena.Scrapers.Furaffinity,
|
||||||
Philomena.Scrapers.Pixiv,
|
Philomena.Scrapers.Pixiv,
|
||||||
|
Philomena.SCrapers.Derpibooru,
|
||||||
Philomena.Scrapers.Raw
|
Philomena.Scrapers.Raw
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
30
lib/philomena/scrapers/derpibooru.ex
Normal file
30
lib/philomena/scrapers/derpibooru.ex
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
defmodule Philomena.Scrapers.Inkbunny do
|
||||||
|
@url_regex ~r|\Ahttps?://derpibooru\.org/images/([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)
|
||||||
|
api_url = "https://derpibooru.org/api/v1/json/images/#{submission_id}"
|
||||||
|
{:ok, %Tesla.Env{status: 200, body: body}} = Philomena.Http.get(api_url)
|
||||||
|
|
||||||
|
json = Jason.decode!(body)
|
||||||
|
submission = json["image"]
|
||||||
|
|
||||||
|
tags = submission["tags"]
|
||||||
|
|
||||||
|
%{
|
||||||
|
source_url: url,
|
||||||
|
tags: tags,
|
||||||
|
sources: submission["source_url"],
|
||||||
|
description: submission["description"],
|
||||||
|
images: [%{
|
||||||
|
url: "#{submission["representations"]["full"]}",
|
||||||
|
camo_url: Camo.Image.image_url(submission["representations"]["medium"])
|
||||||
|
}]
|
||||||
|
}
|
||||||
|
end
|
||||||
|
end
|
|
@ -7,7 +7,7 @@ html lang="en"
|
||||||
|
|
||||||
title
|
title
|
||||||
=> @status
|
=> @status
|
||||||
| - Philomena
|
| - CubFur.gay
|
||||||
link rel="stylesheet" href=stylesheet_path(@conn, nil)
|
link rel="stylesheet" href=stylesheet_path(@conn, nil)
|
||||||
link rel="stylesheet" href=dark_stylesheet_path(@conn) media="(prefers-color-scheme: dark)"
|
link rel="stylesheet" href=dark_stylesheet_path(@conn) media="(prefers-color-scheme: dark)"
|
||||||
link rel="icon" href="/favicon.ico" type="image/x-icon"
|
link rel="icon" href="/favicon.ico" type="image/x-icon"
|
||||||
|
@ -17,7 +17,7 @@ html lang="en"
|
||||||
.minimal__message
|
.minimal__message
|
||||||
h1.minimal__message__header
|
h1.minimal__message__header
|
||||||
i.fa.fw.favicon-home>
|
i.fa.fw.favicon-home>
|
||||||
' Philomena
|
' CubFur.gay
|
||||||
|
|
||||||
h3 = @short_msg
|
h3 = @short_msg
|
||||||
p = @long_msg
|
p = @long_msg
|
||||||
|
|
Loading…
Add table
Reference in a new issue