首页 > 解决方案 > 根据 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')

标签: pythonyoutube-data-api

解决方案


我认为 youtube api 没有提供此功能,但您可以获取任何国家/地区的热门视频列表。如果有人有更好的建议,请告诉我们。

     youtube.videos().list(part='snippet, recordingDetails, statistics',
                           regionCode='US', chart='mostPopular', maxResults=50)

推荐阅读