获取YouTube频道中所有视频的视频URL



我正在尝试获取特定YouTube频道的所有视频URL或ID。YouTube数据API不再支持它。https://developers.google.com/youtube/v3/docs/channels#invideopromotion转介到此链接,并知道它被剥夺了。任何帮助都非常感谢。

首先,您需要从Channel的JSON对象中获取属性'contentDetails.releatedPlaylists.uploads',它包含带有所有频道视频的播放列表的ID:/V3/docs/channels#contentdetails.relatedplaylists.uploads

接下来,您必须调用playlistItems()。列表(your_options).execute()'带上uploads ID和您想要的任何其他选项:https://developers.google.com/youtube/v3/docs/playlistItems/list

例如,在这里,我们获得了所有上传视频的播放列表:

channel = YOUR_YOUTUBE_KEY.channels().list(id=your_channel_id, part="contentOwnerDetails", maxResults=1).execute()
uploadsID = channel[0]["contentDetails"]["relatedPlaylists"]["uploads"]

和50个上传视频的列表:

videosList = YOUR_YOUTUBE_KEY.playlistItems().list(part='snippet', playlistId=uploadsID, maxResults=50).execute()

请记住,MaxResults选项的最大值为50,因此您必须构建周期并获取videoslist [" nextPagetoken"]的下一页token,以将下一个请求发送带有" Pagetoken"选项,该请求将允许您获得。下一个50个视频(当视频列表[" nextpagetoken"] ==")

时必须停止周期

最新更新