mirror of
https://github.com/LuanRT/YouTube.js.git
synced 2026-06-24 07:11:48 +00:00
feat(ytmusic): add support for stations in search results, #78
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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 =
|
||||
|
||||
Reference in New Issue
Block a user