问题
I am trying to get the latest, up to date videos from a channel on youtube. Not sure why, but order: 'date', , publishedAfter: '2019-03-13T19:14:31.000Z', and publishedBefore: '2019-02-13T19:14:31.000Z', don't seem to have an effect.
The full code of what I'm using is here below:
baseURL: 'https://www.googleapis.com/youtube/v3',
params: {
part: 'snippet',
publishedAfter: '2019-03-13T19:14:31.000Z',
publishedBefore: '2019-02-13T19:14:31.000Z',
order: 'date',
maxResults: 10,
key: KEY,
channelId: 'UCzQUP1qoWDoEbmsQxvdjxgQ'
}
Is youtube messing around with the API? Is there a special way we are meant to be doing this? Maybe my ordering is wrong? I'm quite confused
回答1:
This is a temporary issue, as per the Google forums : https://support.google.com/youtube/thread/2494861?msgid=2520468
YouTube is aware the search/sorting functions aren't working as expected – this is temporary and part of our efforts to better respond, review and remove graphic, violative content from YouTube.
回答2:
This issue is related to the following ones:
- Order doesn't work when using youtube API v3;
- publishedAfter parameter appears to be broken now;
- Youtube Data API v3: Sort by date not working.
See also Google's issue #128673552, https://issuetracker.google.com/issues/128673552.
A workaround for this issue: use PlaylistItems endpoint instead, queried for a channel's uploads list. However your should be aware of the difference between a video's published time and upload time (https://developers.google.com/youtube/v3/docs/videos#snippet.publishedAt).
来源:https://stackoverflow.com/questions/55244167/youtubes-api-for-getting-the-latest-videos-from-a-channel