Get the music genres in YouTube

后端 未结 3 1814
醉话见心
醉话见心 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:17

    For anyone wondering about this now (2017) freebase is deprecated and so instead you should use the list currently provided here: https://gist.github.com/stpe/2951130dfc8f1d0d1a2ad736bef3b703

    Ikai Lan is still correct that the part is topicDetails to get this information from the API.

    0 讨论(0)
  • 2021-02-06 13:27

    In freebase you can ask for music genre mids. For example in: http://www.freebase.com/search?query=rock you get that /m/06by7 = rock. With this id you do a query on youtube and get videos regarding this genre;

    Try it https://developers.google.com/youtube/v3/docs/search/list#try-it with this conditions:

    part: snippet
    topicId: /m/06by7
    
    0 讨论(0)
  • 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.

    0 讨论(0)
提交回复
热议问题