Closed LuanRT closed 2 years ago
Hi, do you mind if I work on this issue?
No problem, go ahead @neeoll
@LuanRT apologies for getting back to you so late, but unless I'm mistaken I think something is wrong with the payload being passed into the /browse
endpoint. When I attempt to get a response from the endpoint using the provided browseId
, it fails and returns with a 400 status code. Should I commit the current changes as is so that they can be double checked or is there something obvious that I might have forgotten to look at?
That error usually means there's something wrong with the context
in the payload, since it's for YouTube Music you should deep copy the original context
and make a few changes to it so YouTube Music accepts it.
Example:
//...
const context = JSON.parse(JSON.stringify(session.context));
context.client.originalUrl = Constants.URLS.YT_MUSIC;
context.client.clientVersion = Constants.YTMUSIC_VERSION;
context.client.clientName = 'WEB_REMIX';
data.context = context;
I hope I haven't been taking too long, but at this point I think I've finished retrieving and parsing the feed contents. Before I make my PR however, I just want to make sure I'm returning everything I need to. Is this acceptable or is there more you'd like to have returned:
{
id: 'VLRDCLAK5uy_nZiG9ehz_MQoWQxY5yElsLHCcG0tv9PRg',
title: 'Classic Rock's Greatest Hits',
subtitle: 'Led Zeppelin, The Beatles, The Rolling Stones, Tom Petty',
thumbnail: [
{
url: 'https://lh3.googleusercontent.com/w8QDcpITg-64iylxia0Z4oWzbmlkHdSeSNyGslc_0ZcJgCtgLHkhugunsDRh_t87UQadn_si6-gPpvI=w226-h226-l90-rj',
width: 226,
height: 226
},
{
url: 'https://lh3.googleusercontent.com/w8QDcpITg-64iylxia0Z4oWzbmlkHdSeSNyGslc_0ZcJgCtgLHkhugunsDRh_t87UQadn_si6-gPpvI=w544-h544-l90-rj',
width: 544,
height: 544
}
]
}
I hope I haven't been taking too long
No problem, take your time.
Is this acceptable or is there more you'd like to have returned:
Awesome! Looks great, just one question; is it returning songs, playlists, and other categories such as “Listen again” and “Your favorites”? If so, it would be nice to add something like this so we'd be able to know the type of each item: https://github.com/LuanRT/YouTube.js/blob/6bdccb89e5bece8daa19961fa415835824ae8aca/lib/parser/ytmusic/search/TopResultItem.js#L26
If you don't have the time/don't want to do that then no worries, just submit the PR and I can work on that later.
Unfortunately there weren't any songs or anything like that returned after checking again. I don't think it would be that much of an issue however if users can use playlistId
on another endpoint to get the relevant data. However, I may have ignored something else that I didn't think was important, so I'll submit my PR and let you finish it up. Thanks for both your time and allowing me to work on this.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
Expected Behavior
The library should be able to retrieve YouTube Music's home feed and parse all of its contents.
Current Behavior
Only YouTube's home feed is supported.
Sample Code
It can be done by sending the following payload to the
/browse
endpoint: