mirror of
https://github.com/philomena-dev/philomena.git
synced 2025-03-28 06:17:46 +01:00
Fixing InkBunny to pull tags
This commit is contained in:
parent
4ed4b6efd7
commit
37d6890f9c
1 changed files with 44 additions and 13 deletions
|
@ -17,22 +17,53 @@ defmodule Philomena.Scrapers.Inkbunny do
|
|||
json = Jason.decode!(body)
|
||||
[submission] = json["submissions"]
|
||||
|
||||
description = "##\s#{submission["title"]}\n#{submission["description"]}"
|
||||
rating = if submission["rating_name"] == "General", do: "safe"
|
||||
r = submission["ratings"]
|
||||
|
||||
images =
|
||||
for x <- submission["files"] do
|
||||
%{
|
||||
url: "#{x["file_url_full"]}",
|
||||
camo_url: Camo.Image.image_url(x["file_url_screen"])
|
||||
}
|
||||
rating =
|
||||
cond do
|
||||
[] = r ->
|
||||
rating
|
||||
|
||||
Enum.find(r, fn x -> x["name"] == "Strong Violence" end) ->
|
||||
false
|
||||
|
||||
Enum.find(r, fn x -> x["name"] == "Sexual Themes" end) ->
|
||||
"explicit"
|
||||
|
||||
Enum.find(r, fn x -> x["name"] == "Violence" end) ->
|
||||
"grimdark"
|
||||
|
||||
Enum.find(r, fn x -> x["name"] == "Nudity" end) ->
|
||||
"nude only"
|
||||
end
|
||||
|
||||
%{
|
||||
source_url: url,
|
||||
author_name: submission["username"],
|
||||
description: description,
|
||||
images: images
|
||||
}
|
||||
if rating do
|
||||
description = "##\s#{submission["title"]}\n#{submission["description"]}"
|
||||
|
||||
tags =
|
||||
for x <- submission["keywords"], x["contributed"] == "f" do
|
||||
x["keyword_name"]
|
||||
end
|
||||
|
||||
images =
|
||||
for x <- submission["files"] do
|
||||
%{
|
||||
url: "#{x["file_url_full"]}",
|
||||
camo_url: Camo.Image.image_url(x["file_url_screen"])
|
||||
}
|
||||
end
|
||||
|
||||
%{
|
||||
source_url: url,
|
||||
author_name: submission["username"],
|
||||
description: description,
|
||||
tags: [rating | tags],
|
||||
images: images
|
||||
}
|
||||
else
|
||||
%{errors: ["Requested image does not have an acceptable rating for submission."]}
|
||||
end
|
||||
end
|
||||
|
||||
defp inkbunny_sid do
|
||||
|
|
Loading…
Add table
Reference in a new issue