-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch '8-improved-search' into 'main'
Resolve "Improved Search" Closes #8 See merge request MrMysterius/mangasee-dl!8
- Loading branch information
Showing
2 changed files
with
17 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,28 @@ | ||
import { parse } from "https://deno.land/[email protected]/flags/mod.ts"; | ||
import * as Color from "https://deno.land/[email protected]/fmt/colors.ts"; | ||
import { searchAnime } from "./search.ts"; | ||
import { getBasicMetadata } from "./metadata.ts"; | ||
|
||
const ARGS = parse(Deno.args); | ||
|
||
switch (ARGS._[0] || undefined) { | ||
case "search": { | ||
if (ARGS._.length <= 1) break; | ||
const results = await searchAnime(ARGS._.slice(1, ARGS._.length).join(" ")); | ||
const results = await searchAnime(ARGS._.slice(1, ARGS._.length).join(" "), parseInt(ARGS.l) || parseInt(ARGS["limit"]) || 5); | ||
for (const result of results) { | ||
if (result.score > 0.05) continue; | ||
console.log(`${Color.white("-")} ${Color.green(result.item.s)} [ ${Color.blue(result.item.i)} ]`); | ||
if (result.score > (parseInt(ARGS.s) || parseInt(ARGS["score-threshold"]) || 0.05)) continue; | ||
let release_year = ""; | ||
let chapters_available = ""; | ||
if (!ARGS["no-metadata"] && !ARGS.n) { | ||
const metadata = await getBasicMetadata(result.item.i); | ||
release_year = metadata?.release_year || ""; | ||
chapters_available = metadata?.chapters_available.toString() || ""; | ||
} | ||
console.log( | ||
`${Color.white("-")} ${release_year != "" ? Color.cyan(release_year + " ") : ""}${Color.green(result.item.s)}${ | ||
chapters_available != "" ? Color.magenta(" #" + chapters_available) : "" | ||
} [ ${Color.yellow(result.item.i)} ]` | ||
); | ||
} | ||
break; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters