I am trying to get the last 10 videos of a channel. When I run the following code:
from apiclient.discovery import build
API_SERVICE_NAME = "youtube"
API_VERSION = "v3"
def youtubeTest():
KEY = "my key here"
service = build(API_SERVICE_NAME, API_VERSION , developerKey=KEY)
args = {}
args['part']='snippet'
args['maxResults']='10'
args['channelId']='UCq-Fj5jknLsUf-MWSy4_brA'
args['order']='date'
args['type']='video'
results = service.search().list(**args).execute()
items = results['items']
for item in items:
print item['snippet']['publishedAt']
youtubeTest()
This is the result I am getting
2018-03-13T10:33:45.000Z
2018-03-07T10:19:59.000Z
2017-11-22T04:30:00.000Z
2012-05-06T07:47:37.000Z
2014-10-08T13:26:35.000Z
2017-08-10T13:39:17.000Z
2018-07-28T08:45:00.000Z
2018-12-26T05:53:46.000Z
2014-07-11T13:36:08.000Z
2018-07-12T05:30:09.000Z
I want the last ten videos but this is not the correct order. This piece of code was working for last few months but I am having the problem recently.
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:Use the
PlaylistItems.list
request for retrieve the uploaded videos from a given channel.This is the URL request:
And those are the results:
This is the Google API Explorer demo you can use for guide yourself.
Follow-up on issue #128673552, https://issuetracker.google.com/issues/128673552.