Order doesn't work when using youtube API v3

坚强是说给别人听的谎言 提交于 2019-12-02 08:04:46

Follow-up on issue #128673552, https://issuetracker.google.com/issues/128673552.

You can use a workaround. Instead using the search.list request, retrieve the uploaded videos.

By using the channel_id change the letter as is explained here:

channel_id: UCq-Fj5jknLsUf-MWSy4_brA

upload_playlist_id: UUq-Fj5jknLsUf-MWSy4_brA

Use the PlaylistItems.list request for retrieve the uploaded videos from a given channel.

This is the URL request:

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

And those are the results:

{
 "items": [
  {
   "snippet": {
    "title": "Notebook | Main Taare | Teaser | Salman Khan | Pranutan Bahl | Zaheer Iqbal | Vishal Mishra",
    "position": 0
   },
   "contentDetails": {
    "videoId": "_wXRw1BMifw",
    "videoPublishedAt": "2019-03-16T04:51:10.000Z"
   }
  },
  {
   "snippet": {
    "title": "Finito Full Song | AMAVAS | Sachiin J Joshi, Vivan, Navneet | Jubin Nautiyal, Sukriti Kakar, Ikka",
    "position": 1
   },
   "contentDetails": {
    "videoId": "dSzjNuV4R3g",
    "videoPublishedAt": "2019-03-15T19:30:00.000Z"
   }
  },
  {
   "snippet": {
    "title": "T-SERIES MIXTAPE SEASON 2 Trailer l Bhushan Kumar | Abhijit Vaghani | Ahmed Khan",
    "position": 2
   },
   "contentDetails": {
    "videoId": "5itcXsszOiA",
    "videoPublishedAt": "2019-03-15T09:27:59.000Z"
   }
  },
  {
   "snippet": {
    "title": "Bheege Bheege Full Video | AMAVAS | Sachiin J Joshi & Nargis Fakhri |  Ankit Tiwari",
    "position": 3
   },
   "contentDetails": {
    "videoId": "3pY845c95AE",
    "videoPublishedAt": "2019-03-16T11:00:01.000Z"
   }
  },
  {
   "snippet": {
    "title": "Jab Se Mera Dil Full Video | AMAVAS |Sachiin J Joshi & Nargis Fakhri |Armaan Malik,Palak Muchhal",
    "position": 4
   },
   "contentDetails": {
    "videoId": "XNPbW9BmBSo",
    "videoPublishedAt": "2019-03-15T14:00:05.000Z"
   }
  }
 ]
}

This is the Google API Explorer demo you can use for guide yourself.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!