fix(ytmusic): check if id is valid before proceeding

This commit is contained in:
LuanRT
2022-06-21 03:59:44 -03:00
parent 86291fe1f9
commit bb3f3cc584

View File

@@ -73,6 +73,7 @@ class Music {
* @returns {Promise.<Artist>}
*/
async getArtist(artist_id) {
if (!artist_id.startsWith('UC')) throw new InnertubeError('Invalid artist id', artist_id);
const response = await this.#actions.browse(artist_id, { client: 'YTMUSIC' });
return new Artist(response, this.#actions);
}
@@ -84,6 +85,7 @@ class Music {
* @returns {Promise.<Album>}
*/
async getAlbum(album_id) {
if (!album_id.startsWith('MPR')) throw new InnertubeError('Invalid album id', album_id);
const response = await this.#actions.browse(album_id, { client: 'YTMUSIC' });
return new Album(response, this.#actions);
}