@@ -3,6 +3,7 @@ import isSameOrAfter from "dayjs/plugin/isSameOrAfter"
33import isSameOrBefore from "dayjs/plugin/isSameOrBefore"
44import { Program } from "../@types/plugin"
55import { SayaDefinitionChannel } from "../miraktest-saya/types"
6+ import { wait } from "../shared/utils"
67import { AnnictRESTAPI } from "./annictAPI"
78import { SyobocalAPI } from "./syobocalAPI"
89import { ARM } from "./types"
@@ -88,25 +89,32 @@ export const detectProgramInfo = async ({
8889 const season = `${ syobocalWork . FirstYear } -${ getAnnictSeasonByMonth (
8990 syobocalWork . FirstMonth
9091 ) } `
91- for ( const term of [
92- syobocalWork . Title ,
93- syobocalWork . TitleYomi ,
94- syobocalWork . ShortTitle ,
95- syobocalWork . TitleEN ,
96- ] . filter ( ( s ) : s is string => ! ! s ) ) {
97- const annictWorkSearchReq = await rest . getWorks ( {
98- filter_title : [ term . replace ( / \( \d + \) / g, "" ) ] ,
99- filter_season : [ season ] ,
100- } )
101- const annictWork = annictWorkSearchReq . data . works . slice ( 0 ) . shift ( )
102- if ( annictWork ) {
103- return {
104- annictId : annictWork . id ,
105- episode : {
106- title : syobocalProgram . SubTitle ,
107- number : syobocalProgram . Count ,
108- } ,
92+ for ( const seasonSpec of [
93+ season ,
94+ `${ syobocalWork . FirstYear } -all` ,
95+ null ,
96+ ] ) {
97+ for ( const term of [
98+ syobocalWork . Title ,
99+ syobocalWork . TitleYomi ,
100+ syobocalWork . ShortTitle ,
101+ syobocalWork . TitleEN ,
102+ ] . filter ( ( s ) : s is string => ! ! s ) ) {
103+ const annictWorkSearchReq = await rest . getWorks ( {
104+ filter_title : [ term . replace ( / \( \d + \) / g, "" ) ] ,
105+ filter_season : seasonSpec !== null ? [ seasonSpec ] : undefined ,
106+ } )
107+ const annictWork = annictWorkSearchReq . data . works . slice ( 0 ) . shift ( )
108+ if ( annictWork ) {
109+ return {
110+ annictId : annictWork . id ,
111+ episode : {
112+ title : syobocalProgram . SubTitle ,
113+ number : syobocalProgram . Count ,
114+ } ,
115+ }
109116 }
117+ await wait ( 100 )
110118 }
111119 }
112120 }
0 commit comments