Youtube Data API: Retrieving multiple Video entries by IDs in a single request

后端 未结 5 1221
清歌不尽
清歌不尽 2021-02-02 16:09

I am wondering if there is a way to query YouTube for multiple random videos (video id\'s are known) in a single query? I am storing video id\'s in the local db and need to show

相关标签:
5条回答
  • 2021-02-02 16:38

    RobD's answer works well. You can add something like this to the end of the URL to only retrieve the data you actually need, saving some bandwidth:

    &fields=entry(id,title)

    eg:

    http://gdata.youtube.com/feeds/api/videos?q=h5jKcDH9s64|elzqvWXG1Y&fields=entry(id,title)

    0 讨论(0)
  • 2021-02-02 16:38

    Here's a clearer explanation for the non PHP people

    http://oktryitnow.com/?p=83

    0 讨论(0)
  • 2021-02-02 16:41

    I too had exactly the same problem, I needed a list of video objects related to an arbitrary list of video id's, i.e. not conforming to any of the feeds.

    The batch processing option is very tempting, but the implementation seems quite heavy for what should be pretty simple functionality.

    At the end of the day, doing a basic video search for the id's separated by pipe "|" achieves the required result:

    http://gdata.youtube.com/feeds/api/videos?q=h5jKcDH9s64|elzqvWXG1Y

    Hope this helps

    0 讨论(0)
  • 2021-02-02 16:47

    In Youtube Data API version 3.0 You can do it in a simple way like this.

    https://www.googleapis.com/youtube/v3/videos?key=API_KEY&part=snippet&id=video_id1,video_id2
    

    Just add your video ids separated by comma. It will fetch you the data for all videos in JSON

    I dont know what is the limit on this, will update the answer once I find it.

    0 讨论(0)
  • 2021-02-02 16:55

    You can send multiple requests to youtube data api wrapped in a single request. YouTube allows you to send at most 50 multiple requests in a single request. This kind of request is known as a batch processing request. I have developed a working piece of code specifically for this problem. I had to do same kind of thing for a website I was working on. Anyways you can see how to do it from here (sample code is also present for download): http://www.ovaistariq.net/2010/06/youtube-batch-processing-requests-made-less-costly/

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