Skip to content

Commit

Permalink
🎨 [annict] season指定を3段階でより引っかかりやすいように
Browse files Browse the repository at this point in the history
秋アニメのstartが9月なことがある(しっぽな)
  • Loading branch information
ci7lus committed Oct 7, 2022
1 parent 9acdeda commit 213f4e7
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 19 deletions.
2 changes: 1 addition & 1 deletion src/miraktest-annict/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export const ANNICT_META = {
id: ANNICT_PLUGIN_ID,
name: "Annict",
author: "ci7lus",
version: "0.3.6",
version: "0.3.7",
description: "視聴中の番組をAnnictで記録する",
authorUrl: "https://github.com/ci7lus",
url: "https://github.com/ci7lus/miraktest-plugins/tree/master/src/miraktest-annict",
Expand Down
44 changes: 26 additions & 18 deletions src/miraktest-annict/findWork.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import isSameOrAfter from "dayjs/plugin/isSameOrAfter"
import isSameOrBefore from "dayjs/plugin/isSameOrBefore"
import { Program } from "../@types/plugin"
import { SayaDefinitionChannel } from "../miraktest-saya/types"
import { wait } from "../shared/utils"
import { AnnictRESTAPI } from "./annictAPI"
import { SyobocalAPI } from "./syobocalAPI"
import { ARM } from "./types"
Expand Down Expand Up @@ -88,25 +89,32 @@ export const detectProgramInfo = async ({
const season = `${syobocalWork.FirstYear}-${getAnnictSeasonByMonth(
syobocalWork.FirstMonth
)}`
for (const term of [
syobocalWork.Title,
syobocalWork.TitleYomi,
syobocalWork.ShortTitle,
syobocalWork.TitleEN,
].filter((s): s is string => !!s)) {
const annictWorkSearchReq = await rest.getWorks({
filter_title: [term.replace(/\(\d+\)/g, "")],
filter_season: [season],
})
const annictWork = annictWorkSearchReq.data.works.slice(0).shift()
if (annictWork) {
return {
annictId: annictWork.id,
episode: {
title: syobocalProgram.SubTitle,
number: syobocalProgram.Count,
},
for (const seasonSpec of [
season,
`${syobocalWork.FirstYear}-all`,
null,
]) {
for (const term of [
syobocalWork.Title,
syobocalWork.TitleYomi,
syobocalWork.ShortTitle,
syobocalWork.TitleEN,
].filter((s): s is string => !!s)) {
const annictWorkSearchReq = await rest.getWorks({
filter_title: [term.replace(/\(\d+\)/g, "")],
filter_season: seasonSpec !== null ? [seasonSpec] : undefined,
})
const annictWork = annictWorkSearchReq.data.works.slice(0).shift()
if (annictWork) {
return {
annictId: annictWork.id,
episode: {
title: syobocalProgram.SubTitle,
number: syobocalProgram.Count,
},
}
}
await wait(100)
}
}
}
Expand Down

0 comments on commit 213f4e7

Please sign in to comment.