diff --git a/XCDYouTubeKit/XCDYouTubeClient.h b/XCDYouTubeKit/XCDYouTubeClient.h index dd7ecf0f..941d6f45 100644 --- a/XCDYouTubeKit/XCDYouTubeClient.h +++ b/XCDYouTubeKit/XCDYouTubeClient.h @@ -125,7 +125,21 @@ NS_ASSUME_NONNULL_BEGIN * @return A newly initialized`` object for canceling the asynchronous query operation. If you call the `cancel` method before the operation is finished, the completion handler will not be called. */ - (XCDYouTubeVideoQueryOperation *) queryVideo:(XCDYouTubeVideo *)video cookies:(nullable NSArray *)cookies completionHandler:(void (^)(NSDictionary * __nullable streamURLs, NSError * __nullable error, NSDictionary * __nullable streamErrors))completionHandler; - +/** + * Starts an asynchronous operation for the specified `XCDYouTubeVide` object`, stream URLs to query and cookies, then calls a handler upon completion. + * + * @param video The `` object that this operation will query. Passing a `nil` video will throw an `NSInvalidArgumentException` exception. + * @param streamURLsToQuery The specific stream URLs to query, can be nil. These URLs and keys must be contained in the `streamURLs` property of the `video` object, if none of the values in `streamURLsToQuery` match then all of the `streamURLs` will be queried. + * @param options Options that are reserved for future use. + * @param cookies An array of `NSHTTPCookie` objects, can be nil. These cookies can be used for certain videos that require a login. + * @param completionHandler A block to execute when the client finishes the operation. The completion handler is executed on the main thread. If the completion handler is nil, this method throws an exception. + * @discussion If the query operation completes successfully (i.e. at least one URL stream is reachable), the `streamURLs` parameter of the completion handler block contains a `NSDictionary` object, and the error parameter is nil. If the operation fails, the `streamURLs` parameter is nil and the error parameter contains information about the failure. The error's domain is always `XCDYouTubeVideoErrorDomain`. The `streamErrors` does not indicate that the operation failed but can contain detailed information on why a specific stream failed.In addition, this parameter is dictionary of `NSError` objects. The keys are the YouTube [itag](https://en.wikipedia.org/wiki/YouTube#Quality_and_formats) values as `NSNumber` objects. In some cases the errors within this dictionary may contain `NSError` objects with the code `NSURLErrorNetworkConnectionLost`—this may indicate that the file stored on YouTube's server is incomplete—furthermore, the error will make this suggestion via the`NSLocalizedRecoverySuggestionErrorKey` key of the error's `userInfo`. + * + * @see XCDYouTubeVideoQueryOperation + * + * + * @return A newly initialized`` object for canceling the asynchronous query operation. If you call the `cancel` method before the operation is finished, the completion handler will not be called. + */ - (XCDYouTubeVideoQueryOperation *) queryVideo:(XCDYouTubeVideo *)video streamURLsToQuery:(NSDictionary * __nullable)streamURLsToQuery options:(NSDictionary * __nullable)options cookies:(nullable NSArray *)cookies completionHandler:(void (^)(NSDictionary *__nullable streamURLs, NSError * __nullable error, NSDictionary *__nullable streamErrors))completionHandler; diff --git a/XCDYouTubeKit/XCDYouTubeVideoQueryOperation.h b/XCDYouTubeKit/XCDYouTubeVideoQueryOperation.h index c81dade2..71308a0a 100644 --- a/XCDYouTubeKit/XCDYouTubeVideoQueryOperation.h +++ b/XCDYouTubeKit/XCDYouTubeVideoQueryOperation.h @@ -28,6 +28,11 @@ NS_ASSUME_NONNULL_BEGIN /// @param cookies An array of `NSHTTPCookie` objects, can be nil. These cookies can be used for certain videos that require a login. - (instancetype) initWithVideo:(XCDYouTubeVideo *)video cookies:(nullable NSArray *)cookies; +/// Initializes a video query operation with the specified video, stream URLs to query and cookies. +/// @param video The `` object that this operation will query. Passing a `nil` video will throw an `NSInvalidArgumentException` exception. +/// @param streamURLsToQuery The specific stream URLs to query, can be nil. These URLs and keys must be contained in the `streamURLs` property of the `video` object, if none of the values in `streamURLsToQuery` match then all of the `streamURLs` will be queried. +/// @param options Options that are reserved for future use. +/// @param cookies An array of `NSHTTPCookie` objects, can be nil. These cookies can be used for certain videos that require a login. - (instancetype) initWithVideo:(XCDYouTubeVideo *)video streamURLsToQuery:(nullable NSDictionary*)streamURLsToQuery options:(nullable NSDictionary *)options cookies:(nullable NSArray *)cookies NS_DESIGNATED_INITIALIZER; /// The `video` object that the operation initialized initialized with.