rinov/YoutubeKit

SearchListRequest can't filter videoCaption

anhhtchy opened this issue · 1 comments

When I create a SearchListRequest to filter video has the caption:

let request = SearchListRequest(
                          part: [.snippet], 
                          channelID: channelId, 
                          maxResults: maxCountResult, 
                          order: .rating, 
                          pageToken: self.pageToken, 
                          resourceType: [.video], 
                          videoCaption: .closedCaption
                      )

I received an error:

error =     {
        code = 400;
        errors =         (
                        {
                domain = "youtube.search";
                location = "";
                locationType = parameter;
                message = "The request contains an invalid combination of search filters and/or restrictions. Note that you must set the <code>type</code> parameter to <code>video</code> if you set either the <code>forContentOwner</code> or <code>forMine</code> parameters to <code>true</code>. You must also set the <code>type</code> parameter to <code>video</code> if you set a value for the <code>eventType</code>, <code>videoCaption</code>, <code>videoCategoryId</code>, <code>videoDefinition</code>, <code>videoDimension</code>, <code>videoDuration</code>, <code>videoEmbeddable</code>, <code>videoLicense</code>, <code>videoSyndicated</code>, or <code>videoType</code> parameters.";
                reason = invalidSearchFilter;
            }
        );
        message = "The request contains an invalid combination of search filters and/or restrictions. Note that you must set the <code>type</code> parameter to <code>video</code> if you set either the <code>forContentOwner</code> or <code>forMine</code> parameters to <code>true</code>. You must also set the <code>type</code> parameter to <code>video</code> if you set a value for the <code>eventType</code>, <code>videoCaption</code>, <code>videoCategoryId</code>, <code>videoDefinition</code>, <code>videoDimension</code>, <code>videoDuration</code>, <code>videoEmbeddable</code>, <code>videoLicense</code>, <code>videoSyndicated</code>, or <code>videoType</code> parameters.";
    };
rinov commented

The error message suggests that there is an invalid combination of search filters and/or restrictions in your SearchListRequest. Specifically, it states that if you set the videoCaption parameter to a value like .closedCaption, you must also set the videoType parameter like this:

let request = SearchListRequest(
    part: [.snippet],
    channelID: channelId,
    maxResults: maxCountResult,
    order: .rating,
    pageToken: self.pageToken,
    resourceType: [.video],
    videoCaption: .closedCaption,
    videoType: .any // Add this line
)