From cd4b42a8f6490965eee3af0666b20aa69ff888bb Mon Sep 17 00:00:00 2001 From: Max Isom Date: Mon, 24 Aug 2020 14:53:18 -0500 Subject: Bump dependencies --- src/packages.d.ts | 16 ---------------- src/services/get-songs.ts | 4 ++-- src/services/player.ts | 2 +- 3 files changed, 3 insertions(+), 19 deletions(-) (limited to 'src') diff --git a/src/packages.d.ts b/src/packages.d.ts index ec0e629..ebb7b10 100644 --- a/src/packages.d.ts +++ b/src/packages.d.ts @@ -1,19 +1,3 @@ -declare module 'ytsr' { - interface VideoResult { - title: string; - duration: string; - link: string; - live: boolean; - type: string; - } - - interface SearchResult { - items: VideoResult[]; - } - - export default function (search: string, options: Record): Promise; -} - declare module 'array-shuffle' { export default function (arr: T[]): T[]; } diff --git a/src/services/get-songs.ts b/src/services/get-songs.ts index 8cbb60c..221a79c 100644 --- a/src/services/get-songs.ts +++ b/src/services/get-songs.ts @@ -188,14 +188,14 @@ export default class { const {items} = await ytsr(`"${track.name}" "${track.artists[0].name}" offical`, {limit: 5}); const video = items.find(item => item.type === 'video'); - if (!video) { + if (!video || video.type !== 'video') { throw new Error('No video found for query.'); } return { title: video.title, artist: track.artists[0].name, - length: parseTime(video.duration), + length: video.duration ? parseTime(video.duration) : 0, url: video.link, playlist, isLive: video.live diff --git a/src/services/player.ts b/src/services/player.ts index 6e4a9e9..0ba79c9 100644 --- a/src/services/player.ts +++ b/src/services/player.ts @@ -338,7 +338,7 @@ export default class { // Don't cache livestreams or long videos const MAX_CACHE_LENGTH_SECONDS = 30 * 60; // 30 minutes - shouldCacheVideo = !info.player_response.videoDetails.isLiveContent && parseInt(info.length_seconds, 10) < MAX_CACHE_LENGTH_SECONDS && !options.seek; + shouldCacheVideo = !info.player_response.videoDetails.isLiveContent && parseInt(info.videoDetails.lengthSeconds, 10) < MAX_CACHE_LENGTH_SECONDS && !options.seek; ffmpegInputOptions.push(...[ '-reconnect', -- cgit v1.2.3