问题
I am using the Google APIS explorer's youtube.playlistItems.list
.
I've set the part
parameter to "snippet"
, the maxResults
to 10
, the playlistId
to UUzoVCacndDCfGDf41P-z0iA
which is the uploads
id for the JSConf YouTube channel (the channelId
is UCzoVCacndDCfGDf41P-z0iA
), but for some reason I don't see some of the recent videos uploaded on the channel. I assume maybe because the videos are not returned in a particular order?... if so, how can I can make sure that I get the most recent uploaded videos that corresponds to a specific maxResults
value that I specify?
Update: the API works just fine with other channels & the videos are even returned in order which is what I would expect...
回答1:
Please note the fact that the PlaylistItems endpoint queried for the uploads list of a channel produces an items list which is ordered by upload date. But the items themselves contains publishedAt datetime properties attached.
publishedAt (datetime)
The date and time that the video was published. Note that this time might be different than the time that the video was uploaded. For example, if a video is uploaded as a private video and then made public at a later time, this property will specify the time that the video was made public.
Then the output obtained is fact correct:
$ youtube-data \
--playlist=UUzoVCacndDCfGDf41P-z0iA --videos \
--max-results=20 --page=- \
--table --relative-date
09V_JAGTs2E 2 days 14 hours ago What Tamagotchis Can Teach You About...
Mnc8ck_DuaE 2 days 14 hours ago How (Not) to Fail at Accessibility -...
UM-RhglTyKA 2 days 14 hours ago GraphQL, the Domain Way - Thais Corr...
NdKAUXAvt8E 2 days 14 hours ago The Teenage Mutant Ninja Turtle Guid...
g3jwd0kAIDU 2 days 14 hours ago Improving React Native Performance i...
HkRrJvvnlvU 2 days 14 hours ago JSParty Live at JSConf Hawaii 2019 o...
I4ugdJRCj9Q 2 days 14 hours ago Building Up the Electron Project: Te...
F4G2i4eS7x0 2 days 14 hours ago How to Make Your Website Not Ugly - ...
LFUnn-8IAjQ 2 days 14 hours ago Where Did All My Servers Go? - Garth...
VGcqkF2XDgA 2 days 14 hours ago Navigating Unconscious Bias - Emily ...
el9fhSbby5E 2 days 14 hours ago JavaScript is AsynchroWAT? - Crystal...
JybbgAz3meQ 2 days 14 hours ago How to Calculate the Phase of the Mo...
_0ij8vY2gzE 11 hours 4 mins ago Music and Art with ML by Monica Dinc...
Zyoztl_7l7g 5 days 13 hours ago Navigating the Wild Seas of Native E...
ZMZMMuXRFcE 1 day 11 hours ago Web Components and the AOM by Léoni...
pEVGAn2qNtU 4 days 13 hours ago Designing Components for Fun, Profit...
skml8SjOtKg 3 days 12 hours ago Real World Problems - Internet beyon...
v2Au9Rlj6XM 6 days 14 hours ago The Browser as a Modular, Networked ...
BBWMIxXqr-E 6 days 13 hours ago Variable Fonts and the Flexible Natu...
aQBYAkaABkU 5 days 13 hours ago artistic.css by Agnieszka Naplocha |...
If you want to obtain the latest published say 10 videos of a particular channel you should query the Search endpoint instead, passing to it proper parameters: channelId=...
, maxResults=10
and order=date
.
The output then would look like the one below:
$ youtube-data \
--channel=UCzoVCacndDCfGDf41P-z0iA --videos \
--max-results=10 --page=- \
--table
_0ij8vY2gzE 2019-06-27T02:44:21.000Z Music and Art with ML by Monica Dincu...
Vk9bPDaZELQ 2019-06-26T12:10:11.000Z Block, unblock, block! How ad blocker...
ZMZMMuXRFcE 2019-06-26T02:14:07.000Z Web Components and the AOM by Léonie ...
GhRE3rML9t4 2019-06-25T14:14:55.000Z CSS Houdini & The Future of Styling b...
JybbgAz3meQ 2019-06-24T22:54:47.000Z How to Calculate the Phase of the Moo...
UM-RhglTyKA 2019-06-24T22:54:47.000Z GraphQL, the Domain Way - Thais Corre...
g3jwd0kAIDU 2019-06-24T22:54:47.000Z Improving React Native Performance in...
I4ugdJRCj9Q 2019-06-24T22:54:47.000Z Building Up the Electron Project: Tea...
el9fhSbby5E 2019-06-24T22:54:46.000Z JavaScript is AsynchroWAT? - Crystal ...
NdKAUXAvt8E 2019-06-24T22:54:46.000Z The Teenage Mutant Ninja Turtle Guide...
来源:https://stackoverflow.com/questions/56788894/problem-getting-the-most-recent-uploaded-videos-of-a-channel-using-the-youtube-d