How can I list the uploads from a YouTube Channel?

后端 未结 1 1894
南笙
南笙 2020-12-22 03:00

I am writing this code to search youtube channels on my website and then list their uploads after clicking on them. However currently my links all on all channels to the las

相关标签:
1条回答
  • 2020-12-22 03:51

    Once you have the channel_id, change the highlighted letter as is shown:

    Channel: Microsoft Hololens

    Channel_id: UCT2rZIAL-zNqeK1OmLLUa6g

    Uploads (playlist): UUT2rZIAL-zNqeK1OmLLUa6g

    Once you have the uploads playlist, you can use this request for get the uploaded videos:

    https://www.googleapis.com/youtube/v3/playlistItems?part=snippet%2CcontentDetails&playlistId=<UPLOAD_PLAYLIST_ID>&fields=items(contentDetails(videoId%2CvideoPublishedAt)%2Csnippet(publishedAt%2Ctitle))&key={YOUR_API_KEY}
    

    And these are the results:

    {
     "nextPageToken": "CAUQAA",
     "pageInfo": {
      "totalResults": 61,
      "resultsPerPage": 5
     },
     "items": [
      {
       "snippet": {
        "publishedAt": "2019-02-24T17:38:51.000Z",
        "title": "Industry Partner Solutions for Microsoft HoloLens 2"
       },
       "contentDetails": {
        "videoId": "FWYcuHUgcng",
        "videoPublishedAt": "2019-02-24T17:38:51.000Z"
       }
      },
      {
       "snippet": {
        "publishedAt": "2019-02-24T17:32:14.000Z",
        "title": "Introducing Microsoft HoloLens 2 (Audio Description)"
       },
       "contentDetails": {
        "videoId": "NtRGESjKT6M",
        "videoPublishedAt": "2019-02-24T17:32:14.000Z"
       }
      },
      {
       "snippet": {
        "publishedAt": "2019-02-24T17:31:30.000Z",
        "title": "Introducing Microsoft HoloLens 2"
       },
       "contentDetails": {
        "videoId": "eqFqtAJMtYE",
        "videoPublishedAt": "2019-02-24T17:31:30.000Z"
       }
      },
      {
       "snippet": {
        "publishedAt": "2019-02-24T17:39:08.000Z",
        "title": "PACCAR is exploring Dynamics 365 Guides and HoloLens 2 to improve employee onboarding"
       },
       "contentDetails": {
        "videoId": "OQDhTtDgir0",
        "videoPublishedAt": "2019-02-24T17:39:08.000Z"
       }
      },
      {
       "snippet": {
        "publishedAt": "2019-02-24T17:41:16.000Z",
        "title": "Introducing Dynamics 365 Guides for HoloLens 2"
       },
       "contentDetails": {
        "videoId": "V8c3pDKdHEc",
        "videoPublishedAt": "2019-02-24T17:41:16.000Z"
       }
      }
     ]
    }
    

    This is the Google API Explorer demo I made.

    N.B, this channel has 61 uploaded videos and the maximun results per page are 50.

    This is the entire working jsfiddle.

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