Get the music genres in YouTube

后端 未结 3 1863
醉话见心
醉话见心 2021-02-06 12:56

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 (th

3条回答
  •  滥情空心
    2021-02-06 13:30

    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.

提交回复
热议问题