【问题标题】:Get video likes count according to region in youtube api根据 youtube api 中的区域获取视频点赞数
【发布时间】:2020-06-10 12:16:33
【问题描述】:

我将 youtube api v3 用于研究目的,我可以获得喜欢、不喜欢、cmets 和更多统计信息,但我想根据地区或国家/地区获得喜欢和观看次数。例如,我想知道任何特定视频从不同地区获得了多少喜欢和观看。 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')

【问题讨论】:

    标签: python youtube-data-api


    【解决方案1】:

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

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

    【讨论】:

    • 根据您正在执行的请求的结果,再次请求视频以获取返回的视频的详细信息。查看this answer了解更多详情。
    猜你喜欢
    • 2014-11-07
    • 2012-11-07
    • 1970-01-01
    • 2013-06-12
    • 2013-09-20
    • 1970-01-01
    • 2014-11-20
    • 2016-04-26
    • 1970-01-01
    相关资源
    最近更新 更多