How do I get a list of uploaded videos for a certain channel with the new YouTube Data API (V3)?

前端 未结 2 1616
你的背包
你的背包 2020-11-29 21:23

I am trying to get a list of video ids for all uploaded videos to a channel. I would also like to use the new version of the YouTube Data API (V3). How do I do this?

相关标签:
2条回答
  • 2020-11-29 21:54

    You have to get the upload playlist id to get each videos uploaded. To get that, you need to get the channel id. After you have the playlist id from the channel id, it is pretty simple. I have written out the steps for all three below.

    Also, we offer PubSubHubBub which allows you to be alerted every time a new video is added to a channel, or you could use SUP (V2) to see which resources have changed before making the calls.

    Instructions to get video ids for all uploaded videos for a channel in V3

    1. Get the channel id for the channel you want (you probably only need to do this once, then you can save it)

      • Use search.list
      • Set type to channel
      • Set q to the name of the channel you want
      • Grab the channel id (something like this: "channelId": "UC0X2VuXXXXXXXXXXXXXXXX")
    2. Get the playlist id for the channel uploads using the channel id from step 1 (you probably only need to do this once, then you can save it)

      • Use channels.list
      • Set id to UC0X2VuXXXXXXXXXXXXXXXX from step 1
      • Grab the uploads key from contentDetails (something like this: "uploads": "UU0XXXXXXXXXXXXXXXXXXXX")
    3. Get the videos via the playlistitems in the playlist using the playlist id from step 2

      • Use playlistItems.list
      • Set playlistId to UU0XXXXXXXXXXXXXXXXXXXX from step 2
      • Go through each PlaylistItem and pull out the video id
    0 讨论(0)
  • 2020-11-29 21:54

    In the meantime, there is a much easier way:

    • Use the channels.list
    • set forUsername = [CHANNELNAME]
    • set part = contentDetails

    grab $data->items[0]->contentDetails->relatedPlaylists->uploads --> [PLAYLISTID]

    • Use playlistItems.list
    • Set playlistId = [PLAYLISTID] from step 1
    • Go through each PlaylistItem and pull out the video ids
    0 讨论(0)
提交回复
热议问题