Fix search for various artists
This commit is contained in:
parent
8dcb1cbecc
commit
78d635a002
1 changed files with 21 additions and 12 deletions
|
@ -31,7 +31,7 @@ export async function search(data, original = {}) {
|
|||
let query;
|
||||
const various = data.artist.name === 'Various Artists' || data.artist.name === 'Various';
|
||||
if (various) {
|
||||
data.artist.name = undefined;
|
||||
data.artist.name = "";
|
||||
}
|
||||
if (data.type == "track") {
|
||||
query = [data.name, data.artist.name, data.albumName]
|
||||
|
@ -43,8 +43,8 @@ export async function search(data, original = {}) {
|
|||
// Add "" to try and make the search better, works for stuff like "The beatles" to reduce noise
|
||||
query = query.filter(String).map((entry) => '"' + entry + '"').join(" ")
|
||||
|
||||
let param = base_filter + (data.type == "track" ? tracks_filter : albums_filter) + exact_search_filter
|
||||
let request_body = {query, param, ...standard_body }
|
||||
let params = base_filter + (data.type == "track" ? tracks_filter : albums_filter) + exact_search_filter
|
||||
let request_body = {query, params, ...standard_body }
|
||||
|
||||
const { body } = await request.post("https://music.youtube.com/youtubei/v1/search")
|
||||
.set(standard_headers)
|
||||
|
@ -57,8 +57,12 @@ export async function search(data, original = {}) {
|
|||
return { service: 'ytmusic' };
|
||||
}
|
||||
|
||||
// I ignore the tabbedSearchResultsRenderer case from ytmusicapi, because we're always selecting a tab.
|
||||
const results = body.contents.sectionListRenderer.contents
|
||||
let results;
|
||||
if (body.contents.tabbedSearchResultsRenderer !== undefined) {
|
||||
results = body.contents.tabbedSearchResultsRenderer.tabs[0].tabRenderer.content
|
||||
} else {
|
||||
results = body.contents.sectionListRenderer.contents
|
||||
}
|
||||
|
||||
// no results
|
||||
if (results.length == 1 && results.itemSectionRenderer !== undefined) {
|
||||
|
@ -156,14 +160,19 @@ async function lookupAlbum(id) {
|
|||
}
|
||||
return false
|
||||
}).payload.musicAlbumRelease;
|
||||
let artists = data.filter((entry) => {
|
||||
if (entry.payload.musicArtist !== undefined) {
|
||||
if (album_data.primaryArtists.includes(entry.entityKey)) {
|
||||
return true
|
||||
let artists;
|
||||
if (album_data.primaryArtists) {
|
||||
artists= data.filter((entry) => {
|
||||
if (entry.payload.musicArtist !== undefined) {
|
||||
if (album_data.primaryArtists.includes(entry.entityKey)) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
}
|
||||
return false
|
||||
}).map((entry) => entry.payload.musicArtist.name);
|
||||
return false
|
||||
}).map((entry) => entry.payload.musicArtist.name);
|
||||
} else { // Various artists, most likely
|
||||
artists = [album_data.artistDisplayName];
|
||||
}
|
||||
|
||||
const artwork = {
|
||||
small: album_data.thumbnailDetails.thumbnails[0].url,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue