Don't silently fail

This commit is contained in:
Max Isom 2022-01-06 16:25:59 -06:00
parent dcdec2d49e
commit 65dd43ac68
No known key found for this signature in database
GPG key ID: 25C9B1A7F6798880
2 changed files with 39 additions and 49 deletions

View file

@ -5,6 +5,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [Unreleased]
### Changed
- Track lookups no longer fail silently (error is returned and logged)
## [0.3.1] - 2022-01-06
### Fixed

View file

@ -43,7 +43,6 @@ export default class {
}
async youtubeVideoSearch(query: string): Promise<QueuedSongWithoutChannel | null> {
try {
const {items} = await this.ytsrQueue.add(async () => this.cache.wrap(
ytsr,
query,
@ -68,14 +67,10 @@ export default class {
throw new Error('No video found.');
}
return await this.youtubeVideo(firstVideo.id);
} catch (_: unknown) {
return null;
}
return this.youtubeVideo(firstVideo.id);
}
async youtubeVideo(url: string): Promise<QueuedSongWithoutChannel | null> {
try {
const videoDetails = await this.cache.wrap(
this.youtube.videos.get,
cleanUrl(url),
@ -92,9 +87,6 @@ export default class {
playlist: null,
isLive: videoDetails.snippet.liveBroadcastContent === 'live',
};
} catch (_: unknown) {
return null;
}
}
async youtubePlaylist(listId: string): Promise<QueuedSongWithoutChannel[]> {
@ -280,10 +272,6 @@ export default class {
}
private async spotifyToYouTube(track: SpotifyApi.TrackObjectSimplified, _: QueuedPlaylist | null): Promise<QueuedSongWithoutChannel | null> {
try {
return await this.youtubeVideoSearch(`"${track.name}" "${track.artists[0].name}"`);
} catch (_: unknown) {
return null;
}
return this.youtubeVideoSearch(`"${track.name}" "${track.artists[0].name}"`);
}
}