From d43bdb18c0b377ef1a78064efd8e3ff956f614ff Mon Sep 17 00:00:00 2001 From: Daniel Odendahl Jr Date: Thu, 21 Feb 2019 22:42:32 +0000 Subject: [PATCH] Exact anime matches --- commands/search/anime.js | 14 ++++++++++++-- package.json | 2 +- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/commands/search/anime.js b/commands/search/anime.js index 3ad4dda6..432903aa 100644 --- a/commands/search/anime.js +++ b/commands/search/anime.js @@ -5,8 +5,14 @@ const { stripIndents } = require('common-tags'); const { cleanAnilistHTML } = require('../../util/Util'); const searchGraphQL = stripIndents` query ($search: String, $type: MediaType, $isAdult: Boolean) { - anime: Page (perPage: 1) { - results: media (type: $type, isAdult: $isAdult, search: $search) { id } + anime: Page (perPage: 10) { + results: media (type: $type, isAdult: $isAdult, search: $search) { + id + title { + english + userPreferred + } + } } } `; @@ -100,6 +106,10 @@ module.exports = class AnimeCommand extends Command { query: searchGraphQL }); if (!body.data.anime.results.length) return null; + const found = body.data.anime.results.find( + anime => anime.title.english.toLowerCase() === query || anime.title.userPreferred.toLowerCase() === query + ); + if (found) return found.id; return body.data.anime.results[0].id; } diff --git a/package.json b/package.json index 7b19dd25..1ed5b3cf 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "xiao", - "version": "101.9.0", + "version": "101.9.1", "description": "Your personal server companion.", "main": "Xiao.js", "scripts": {