-
Notifications
You must be signed in to change notification settings - Fork 183
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fetch song metadata by videoId #42
Comments
This should be possible. YouTube Music uses a different API (www.youtube.com/get_video_info) than the one usually used in ytmusicapi for this purpose (music.youtube.com). But I believe the request should work using the same cookies that the rest of ytmusicapi uses. The endpoint was reverse engineered here: https://tyrrrz.me/blog/reverse-engineering-youtube The response needs to be URL decoded, afterwards you can find the interesting parts in player_response (JSON containing all the info), more specifically the key The individual items probably need to be processed a bit, since they still contain '+' instead of spaces.
|
That’s pretty close. The disadvantage I see here is that you have to parse the video ‘title’ to “best guess” the song ‘name’ and ‘artist’. Versus being able to retrieve these values explicitly in a response from the json. Maybe the namings of YTMusic videos are better standardized than YouTube’s? Or maybe they’re one in the same. I’m still familiarizing myself with the platform. |
I think you actually get that info if it's a song (and not a video as above). I tried with a public track from YTMusic:
and a private track
The Here's the full response: get_video_info_json.txt |
I did some more research and it seems YTMusic actually uses the next() endpoint (https://music.youtube.com/youtubei/v1/next) to get the info shown in the player. However, the info provided by that endpoint is even less structured as get_video_info, as it simply provides the "bylines" shown at the bottom, without specifying whether the info is artist, like, views, album etc. Here's an example for a music video:
and another for a regular song:
I do believe that the |
Good find! Yeah, it does seem the youtube api would be better suited for this with how unstructured the youtube nusic api response is. Probably makes this feature out of this project's scope? I haven't actually gotten the chance yet to follow the reverse engineered steps, but I skimmed it over and it looked straightforward enough. Just need to get some spare time again to tinker with it. |
I already made some progress on the Let me know what you think. Feel free to add or change things if necessary |
Are you still interested in this issue @JGMEYER ? Otherwise I'll go ahead and merge it into master |
Please feel free to merge. I managed to use one of the youtube endpoints
for my project from the blog you posted, but I’d be happy to test out any
release that contains these changes :)
On Mon, Jul 20, 2020 at 04:35 sigmatics ***@***.***> wrote:
Are you still interested in this issue @JGMEYER
<https://github.com/JGMEYER> ? Otherwise I'll go ahead and merge it into
master
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#42 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAEKYXLV4HX4BQ5JSO46AZLR4P6VBANCNFSM4OVRZQDQ>
.
--
*Justian Meyer*
*Georgia Institute of Technology*
Computer Science '14
|
[Creating ticket per CONTRIBUTING.rst]
Context:
YouTube Music urls already provide the id to the video. It would be nice to be able to fetch a video's metdata, e.g. name, artists from this videoId. Similar to get_album() for albums.
get_song(self, videoId)
could return a song's metadata.How this feature is missing:
From reading the documentation, there doesn't seem to be an endpoint to retrieve this information or a set of chained function calls to achieve this use case.
Acceptance criteria:
This ticket is to gather information on the set of requirements and to implement the method in class
YTMusic
, if currently feasible.This ticket can be closed under any of the following conditions:
get_song(self, videoId)
has been implemented inYTMusic
(with corresponding unit/integration tests) for fetching song metadataI'm not yet sure about the limitations on the api for fetching this information, or futhermore if this would somehow be blocked by #10. I (@JGMEYER) am open to help develop this feature, but may need some guidance.
The text was updated successfully, but these errors were encountered: