Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add category tag for Wallhaven. #3247

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions src/sites/WallHaven/model.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
function parseSearch(search: string): { query: string, purity: string, order: string, sort: string, ratios: string[] } {
function parseSearch(search: string): { query: string, purity: string, category: string, order: string, sort: string, ratios: string[] } {

Check warning on line 1 in src/sites/WallHaven/model.ts

View check run for this annotation

Codecov / codecov/patch

src/sites/WallHaven/model.ts#L1

Added line #L1 was not covered by tests
let query: string = "";
let purity: string = "111";
let category: string = "111";

Check warning on line 4 in src/sites/WallHaven/model.ts

View check run for this annotation

Codecov / codecov/patch

src/sites/WallHaven/model.ts#L4

Added line #L4 was not covered by tests
let order: string = "date_added";
let sort: string = "desc";
const ratios: string[] = [];
Expand All @@ -11,6 +12,9 @@
} else if (tag.indexOf("-rating:") === 0) {
const val = tag.substr(8);
purity = val === "s" || val === "safe" ? "011" : (val === "e" || val === "explicit" ? "110" : "101");
} else if (tag.indexOf("category_wallhaven:") === 0) {
const val = tag.substr(19);

Check warning on line 16 in src/sites/WallHaven/model.ts

View check run for this annotation

Codecov / codecov/patch

src/sites/WallHaven/model.ts#L16

Added line #L16 was not covered by tests
category = val === "anime" ? "010" : (val === "people" ? "001" : "100");
} else if (tag.indexOf("order:") === 0) {
const val = tag.substr(6);
if (val.substr(-5) === "_desc") {
Expand All @@ -29,12 +33,12 @@
query += (query ? " " : "") + tag;
}
}
return { query, purity, order, sort, ratios }
return { query, purity, category, order, sort, ratios }

Check warning on line 36 in src/sites/WallHaven/model.ts

View check run for this annotation

Codecov / codecov/patch

src/sites/WallHaven/model.ts#L36

Added line #L36 was not covered by tests
}

export const source: ISource = {
name: "WallHaven",
modifiers: ["rating:s", "rating:safe", "rating:q", "rating:questionable", "rating:e", "rating:explicit", "order:relevance", "order:random", "order:date_added", "order:views", "order:favorites", "order:toplist", "order:hot"],
modifiers: ["rating:s", "rating:safe", "rating:q", "rating:questionable", "rating:e", "rating:explicit", "order:relevance", "order:random", "order:date_added", "order:views", "order:favorites", "order:toplist", "order:hot", "category_wallhaven:general", "category_wallhaven:anime", "category_wallhaven:people"],
forcedTokens: ["tags"],
auth: {
url: {
Expand All @@ -58,6 +62,7 @@
const params: Record<string, any> = {
q: search.query,
purity: search.purity,
categories: search.category,
page: query.page,
sorting: search.order,
order: search.sort,
Expand Down
Loading