feat(ytmusic): add support for stations in search results, #78

This commit is contained in:
LuanRT
2022-06-22 05:46:33 -03:00
parent 1681a9b84c
commit 20556970a7
2 changed files with 11 additions and 5 deletions

View File

@@ -9,8 +9,13 @@ class MusicPlayButton {
this.endpoint = new NavigationEndpoint(data.playNavigationEndpoint);
this.play_icon_type = data.playIcon.iconType;
this.pause_icon_type = data.pauseIcon.iconType;
this.play_label = data.accessibilityPlayData.accessibilityData.label;
this.pause_label = data.accessibilityPauseData.accessibilityData.label;
data.accessibilityPlayData &&
(this.play_label = data.accessibilityPlayData.accessibilityData.label);
data.accessibilityPlayData &&
(this.pause_label = data.accessibilityPauseData?.accessibilityData.label);
this.icon_color = data.iconColor;
}
}

View File

@@ -25,7 +25,7 @@ class MusicResponsiveListItem {
this.endpoint = data.navigationEndpoint &&
new NavigationEndpoint(data.navigationEndpoint) || null;
switch (this.endpoint?.browse.page_type) {
switch (this.endpoint?.browse?.page_type) {
case 'MUSIC_PAGE_TYPE_ALBUM':
this.type = 'album';
this.#parseAlbum();
@@ -35,6 +35,7 @@ class MusicResponsiveListItem {
this.#parsePlaylist();
break;
case 'MUSIC_PAGE_TYPE_ARTIST':
case 'MUSIC_PAGE_TYPE_USER_CHANNEL':
this.type = 'artist';
this.#parseArtist();
break;
@@ -56,7 +57,7 @@ class MusicResponsiveListItem {
#parseVideoOrSong() {
const is_video = this.#flex_columns[1].title.runs
?.some((run) => run.text.match(/(.*?) views/));
if (is_video) {
this.type = 'video';
this.#parseVideo();
@@ -67,7 +68,7 @@ class MusicResponsiveListItem {
}
#parseSong() {
this.id = this.#playlist_item_data.video_id;
this.id = this.#playlist_item_data.video_id || this.endpoint.watch.video_id;
this.title = this.#flex_columns[0].title.toString();
const duration_text =