无法提供图表作为youtube搜索API的参数

问题描述 投票:1回答:1

我尝试根据youtube search API来按国家对youtube进行趋势分析,我可以将图表设置为“ mostPopular”,该图表本应返回趋势分析视频的详细信息,但该方法无效,并返回了错误

enter image description here

from googleapiclient.discovery import build

DEVELOPER_KEY = "XXXXXXXXX"
YOUTUBE_API_SERVICE_NAME = "youtube"
YOUTUBE_API_VERSION = "v3"


def youtube_search(max_results=5, order="relevance", token=None, location=None, location_radius=None,
                   regionCode=None):
    youtube = build(YOUTUBE_API_SERVICE_NAME, YOUTUBE_API_VERSION, developerKey=DEVELOPER_KEY)

    search_response = youtube.search().list(
        type="video",
        pageToken=token,
        order=order,
        part="id,snippet",  # Part signifies the different types of data you want
        chart="mostPopular",
        maxResults=max_results,
        location=location,
        locationRadius=location_radius,
        regionCode = regionCode,
        ).execute()

    print(search_response)

youtube_search(regionCode='IE')

任何人都可以帮忙吗?

python youtube youtube-data-api
1个回答
0
投票

图表是Videos resource上的参数,在搜索资源上不可用。

© www.soinside.com 2019 - 2024. All rights reserved.