Fixing InkBunny to pull tags

This commit is contained in:
Chaska 2024-05-12 13:32:05 -05:00
parent 4ed4b6efd7
commit 37d6890f9c

View file

@ -17,8 +17,35 @@ defmodule Philomena.Scrapers.Inkbunny do
json = Jason.decode!(body)
[submission] = json["submissions"]
rating = if submission["rating_name"] == "General", do: "safe"
r = submission["ratings"]
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
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
%{
@ -31,8 +58,12 @@ defmodule Philomena.Scrapers.Inkbunny do
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