为什么我使用youtube api v3只能获得我的四个Youtube播放列表中的三个?

时间:2014-09-05 08:50:59

标签: java youtube youtube-api

在使用Youtube API v3期间出现以下情况。我请求搜索以获取我的所有播放列表,但结果只包含4个中的3个,缺少最新的播放列表。 但是当我在开发者页面中尝试API时,我得到了所有四个播放列表。

开发者页面: https://developers.google.com/youtube/v3/docs/playlists/list?hl=fr#try-it

我的要求:
https://www.googleapis.com/youtube/v3/playlists?part=id&channelId=UCtEV5D0j6LwV0MqCnZ7H1AA&key= {YOUR_API_KEY}

在java应用程序中,我使用API​​来执行相同的操作,这里是我的代码,只传递4个播放列表中的3个:

public int execute(PipelineDictionary dict)
throws PipeletExecutionException
{
    // Initialize the search
    YouTube.Search.List search = null;
    // Response item
    SearchListResponse response = null;
    // Create the youtube object
    YouTube youtube = new YouTube.Builder(HTTP_TRANSPORT, JSON_FACTORY, new HttpRequestInitializer() {
        public void initialize(HttpRequest request) throws IOException{}}).setApplicationName("GartenXXL").build();

    try
    {
        search = youtube.search().list("id,snippet");
    }
    catch(IOException e1)
    {
        throw new PipeletExecutionException("Failure during sending youtube search request");
    }

    // Set API-Key
    search.setKey(cfg_apiKey);
    search.setChannelId(cfg_channelId);
    // Set Request Query
    // search.setQ(queryTerm);

    // search.type("playlist"); oder  search.type("channel");
    search.setType("playlist");
    // Set Fields, filters onle the filds that are defined
    search.setFields("items(id/playlistId,snippet(title))");
    search.setMaxResults(50L);

    try
    {
        response = search.execute();
        //System.out.println(response.toPrettyString());
    }
    catch(IOException e)
    {
        e.printStackTrace();
    }

    dict.put(DN_YOUTUBE_LISTS, response);
    return PIPELET_NEXT;
}

结果Json看起来像:

 {
"items": [
    {
        "id": {
            "playlistId": "PLWWeimUpYTkhXubzYoPSqetvhCYZocaVj"
        },
        "snippet": {
            "title": "GartenXXL Ratgeber"
        }
    },
    {
        "id": {
            "playlistId": "PLWWeimUpYTkjCabIwPo0NuvMV_BPkC981"
        },
        "snippet": {
            "title": "Produktvideos - Top-Produkte von GartenXXL"
        }
    },
    {
        "id": {
            "playlistId": "PLWWeimUpYTkgEBjIryCrqms640yy4D_1d"
        },
        "snippet": {
            "title": "Rasenmäher-Videos"
        }
    }
]

}

0 个答案:

没有答案