python - 根据 youtube api 中的区域获取视频点赞数
问题描述
我将 youtube api v3 用于研究目的,我可以获得喜欢、不喜欢、评论和更多统计信息,但我想根据地区或国家/地区获得喜欢和观看次数。例如,我想知道来自不同地区的任何特定视频有多少喜欢和观看。此选项在 youtube_api v3 中是否可用?
def get_channel_videos(channel_id):
res = youtube.channels().list(id=channel_id,
part='contentDetails').execute()
playlist_id = res['items'][0]['contentDetails']
['relatedPlaylists']['uploads']
videos = []
next_page_token = None
while True:
res = youtube.playlistItems().list(playlistId=playlist_id,
part='snippet',
maxResults=50,
pageToken=next_page_token).execute()
videos += res['items']
next_page_token = res.get('nextPageToken')
if next_page_token is None:
break
return videos
videos = get_channel_videos('UCqRTj-Nu_8to3jIBlXptOtA')
解决方案
我认为 youtube api 没有提供此功能,但您可以获取任何国家/地区的热门视频列表。如果有人有更好的建议,请告诉我们。
youtube.videos().list(part='snippet, recordingDetails, statistics',
regionCode='US', chart='mostPopular', maxResults=50)
推荐阅读
- javascript - 更新数组上的状态,除了该数组中的一个对象 ReactJS
- c++ - 在 C++ 中将 AVRational 数转换为 Double 的最佳方法
- php - PHP将查询字符串拆分为带有键/值的数组
- sql - 是否有任何 NHibernate 等效于 sql 'left' 函数?
- python - 如何修复:NameError:未定义名称“密码”
- php - 为什么使用 PHP 将 shell_exec 转换为变量不起作用?
- spring-boot - 为什么我的 mockMvc 没有提交任何内容?
- react-native - 配置 jetifier 后的 react-native run-android
- azure - 用于虚拟环境编排和生命周期管理的基于 Azure 云的管理系统
- javascript - 我有一个与 Visual Studio 测试页 .asmx 配合使用的 Web 服务 .asmx,但向客户端返回 500