Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get the music genres in YouTube

Tags:

youtube-api

When we view the YouTube page, and click Music, we are able to see them on different genre's like "Rap", "Rock", "Country", etc.

How can I retrieve this data (the genre-wise listing of videos) using the YouTube Apis.?

like image 529
Navaneeth Sen Avatar asked Oct 10 '22 16:10

Navaneeth Sen


1 Answers

One way to do this is using the Topics API integration with V3 of the API. Take a look at the videos.list() API call. Plug in these values:

  • part: topicDetails
  • id: fWNaR-rxAic
  • fields: items/topicDetails/topicIds

The ID of that video corresponds to Carly Rae Jepsen's "Call Me Maybe". When you look at the JSON response, you'll see a list of topic IDs:

[ "/m/015f7", "/m/0h55y27", "/m/0gkxzs6", "/m/064t9" ]

These are Freebase machine IDs. You would then make a Freebase API call to retrieve information about that particular topic. For instance, /m/064t9 corresponds to "Pop Music".

Thise method won't work for 100% of videos on YouTube; Metallica's "Whiskey in a Jar" only returns topics for the song and the band, however, Britney Spear's "I Want to Go" correctly returns a machine ID for "Pop Music".

The reason for this is that the Topic is often machine generated, not human curated (though we do quality checks). We did a Google I/O talk about how this works. The good news is that once you DO have a machine ID, it's very easy to find other videos by topic ID. Our samples demonstrate how to do this.

like image 129
Ikai Lan Avatar answered Oct 14 '22 03:10

Ikai Lan