diff --git a/XCDYouTubeKit/XCDYouTubeVideoOperation.m b/XCDYouTubeKit/XCDYouTubeVideoOperation.m index ae021133..be4ce9ee 100644 --- a/XCDYouTubeKit/XCDYouTubeVideoOperation.m +++ b/XCDYouTubeKit/XCDYouTubeVideoOperation.m @@ -89,12 +89,12 @@ - (instancetype) initWithVideoIdentifier:(NSString *)videoIdentifier languageIde _videoIdentifier = videoIdentifier ?: @""; _languageIdentifier = languageIdentifier ?: @"en"; - _session = [NSURLSession sessionWithConfiguration:[NSURLSessionConfiguration ephemeralSessionConfiguration]]; + NSURLSessionConfiguration *configuration = [NSURLSessionConfiguration ephemeralSessionConfiguration]; _cookies = [cookies copy]; _customPatterns = [customPatterns copy]; for (NSHTTPCookie *cookie in _cookies) { - [_session.configuration.HTTPCookieStorage setCookie:cookie]; + [configuration.HTTPCookieStorage setCookie:cookie]; } NSString *cookieValue = [NSString stringWithFormat:@"f1=50000000&f6=8&hl=%@", _languageIdentifier]; @@ -107,7 +107,9 @@ - (instancetype) initWithVideoIdentifier:(NSString *)videoIdentifier languageIde NSHTTPCookieSecure:@"TRUE" }]; - [_session.configuration.HTTPCookieStorage setCookie:additionalCookie]; + [configuration.HTTPCookieStorage setCookie:additionalCookie]; + configuration.HTTPAdditionalHeaders = @{@"User-Agent": @"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/12.0 Safari/605.1.15"}; + _session = [NSURLSession sessionWithConfiguration:configuration]; _operationStartSemaphore = dispatch_semaphore_create(0); return self;