diff --git a/src/services/youtube-api.ts b/src/services/youtube-api.ts index 6d8c798..944d4d8 100644 --- a/src/services/youtube-api.ts +++ b/src/services/youtube-api.ts @@ -74,7 +74,7 @@ export default class { } async search(query: string, shouldSplitChapters: boolean): Promise { - const {items} = await this.ytsrQueue.add(async () => this.cache.wrap( + const {items}: ytsr.VideoResult | void = await this.ytsrQueue.add(async () => this.cache.wrap( ytsr, query, { @@ -85,6 +85,10 @@ export default class { }, )); + if (!items) { + return []; + } + let firstVideo: Video | undefined; for (const item of items) {