Skip to content

Commit

Permalink
Merge branch 'release/2.15.2'
Browse files Browse the repository at this point in the history
  • Loading branch information
SoneeJohn committed Dec 8, 2020
2 parents 18537a0 + 9e629ff commit 23f7659
Show file tree
Hide file tree
Showing 16 changed files with 343 additions and 170 deletions.
4 changes: 2 additions & 2 deletions .jazzy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ source_directory: XCDYouTubeKit
framework_root: .
umbrella_header: XCDYouTubeKit/XCDYouTubeKit.h
module: XCDYouTubeKit
module_version: 2.15.1
module_version: 2.15.2

author: Cédric Luthi
author_url: https://twitter.com/0xced

readme: README.md
github_url: https://github.com/0xced/XCDYouTubeKit
github_file_prefix: https://github.com/0xced/XCDYouTubeKit/tree/2.15.1/XCDYouTubeKit
github_file_prefix: https://github.com/0xced/XCDYouTubeKit/tree/2.15.2/XCDYouTubeKit
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
#### Version 2.15.2

* Adaptation to YouTube API change (#510)

#### Version 2.15.1

* Adaptation to YouTube API change (#507, #504)
Expand Down
28 changes: 27 additions & 1 deletion XCDYouTubeKit Demo/OS X Demo/AppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
//

#import "AppDelegate.h"

#import "VCR.h"
@import AVFoundation;

#import <CocoaLumberjack/CocoaLumberjack.h>
Expand All @@ -18,14 +18,40 @@ - (void) applicationDidFinishLaunching:(NSNotification *)aNotification
[DDLog addLogger:[DDASLLogger sharedInstance]];
}

- (BOOL) shouldSaveRequests
{
return [[NSProcessInfo processInfo].environment[@"XCDYouTubeKitSaveRequest"] boolValue];
}

- (NSString *)requestsDirectoryPath
{
NSString *requestsDirectoryPath = [[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES)firstObject] stringByAppendingPathComponent:@"XCDYouTubeKit Demo"];
[[NSFileManager defaultManager]createDirectoryAtPath:requestsDirectoryPath withIntermediateDirectories:YES attributes:nil error:nil];
return requestsDirectoryPath;
}

- (IBAction) playVideo:(id)sender
{
if ([self shouldSaveRequests])
{
[VCR setRecording:YES];
}

self.playerView.player = nil;

[self.progressIndicator startAnimation:sender];
[[XCDYouTubeClient defaultClient] getVideoWithIdentifier:[sender stringValue] completionHandler:^(XCDYouTubeVideo *video, NSError *error)
{

if ([self shouldSaveRequests])
{
[VCR setRecording:NO];
NSString *filePath = [[[self requestsDirectoryPath] stringByAppendingPathComponent:[sender stringValue]] stringByAppendingPathExtension:@"json"];
[[NSFileManager defaultManager]removeItemAtPath:filePath error:nil];
[VCR save:filePath];

}

if (video)
{

Expand Down
75 changes: 73 additions & 2 deletions XCDYouTubeKit Demo/XCDYouTubeKit Demo.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,16 @@
/* Begin PBXBuildFile section */
019AFA1E2361E9CD00B03F57 /* DemoFullScreenViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 019AFA1D2361E9CC00B03F57 /* DemoFullScreenViewController.swift */; };
019AFA202361F10D00B03F57 /* Utilities.swift in Sources */ = {isa = PBXBuildFile; fileRef = 019AFA1F2361F10D00B03F57 /* Utilities.swift */; };
01D6A808257E89CE0017AD5A /* VCR.m in Sources */ = {isa = PBXBuildFile; fileRef = 01D6A7F3257E89CE0017AD5A /* VCR.m */; };
01D6A809257E89CF0017AD5A /* VCRRecordingURLProtocol.m in Sources */ = {isa = PBXBuildFile; fileRef = 01D6A7F5257E89CE0017AD5A /* VCRRecordingURLProtocol.m */; };
01D6A80A257E89CF0017AD5A /* VCRReplayingURLProtocol.m in Sources */ = {isa = PBXBuildFile; fileRef = 01D6A7F6257E89CE0017AD5A /* VCRReplayingURLProtocol.m */; };
01D6A80B257E89CF0017AD5A /* VCRRecording.m in Sources */ = {isa = PBXBuildFile; fileRef = 01D6A7F8257E89CE0017AD5A /* VCRRecording.m */; };
01D6A80C257E89CF0017AD5A /* VCRErrorSerialization.m in Sources */ = {isa = PBXBuildFile; fileRef = 01D6A7FA257E89CE0017AD5A /* VCRErrorSerialization.m */; };
01D6A80D257E89CF0017AD5A /* VCRCassette.m in Sources */ = {isa = PBXBuildFile; fileRef = 01D6A7FD257E89CE0017AD5A /* VCRCassette.m */; };
01D6A80E257E89CF0017AD5A /* VCR+NSURLSessionConfiguration.m in Sources */ = {isa = PBXBuildFile; fileRef = 01D6A802257E89CE0017AD5A /* VCR+NSURLSessionConfiguration.m */; };
01D6A80F257E89CF0017AD5A /* VCROrderedMutableDictionary.m in Sources */ = {isa = PBXBuildFile; fileRef = 01D6A804257E89CE0017AD5A /* VCROrderedMutableDictionary.m */; };
01D6A810257E89CF0017AD5A /* VCRCassetteManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 01D6A805257E89CE0017AD5A /* VCRCassetteManager.m */; };
01D6A811257E89CF0017AD5A /* VCRRequestKey.m in Sources */ = {isa = PBXBuildFile; fileRef = 01D6A807257E89CE0017AD5A /* VCRRequestKey.m */; };
01E88BD523690B75002523D1 /* AVPlayerViewControllerManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01E88BD423690B75002523D1 /* AVPlayerViewControllerManager.swift */; };
0ADD88CC5EC5E9D286D8A8E0 /* libPods-XCDYouTubeKit iOS Demo.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 5B3DDE49D0638521AD03AA01 /* libPods-XCDYouTubeKit iOS Demo.a */; };
6941B80FC7AE87BA698FDD61 /* libPods-XCDYouTubeKit OS X Demo.a in Frameworks */ = {isa = PBXBuildFile; fileRef = CF61ADAFAE5A8C5F8C082438 /* libPods-XCDYouTubeKit OS X Demo.a */; };
Expand Down Expand Up @@ -93,6 +103,27 @@
019AFA1C2361E9CC00B03F57 /* XCDYouTubeKit iOS Demo-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "XCDYouTubeKit iOS Demo-Bridging-Header.h"; sourceTree = "<group>"; };
019AFA1D2361E9CC00B03F57 /* DemoFullScreenViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DemoFullScreenViewController.swift; sourceTree = "<group>"; };
019AFA1F2361F10D00B03F57 /* Utilities.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Utilities.swift; sourceTree = "<group>"; };
01D6A7F3257E89CE0017AD5A /* VCR.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = VCR.m; sourceTree = "<group>"; };
01D6A7F4257E89CE0017AD5A /* VCRCassette.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = VCRCassette.h; sourceTree = "<group>"; };
01D6A7F5257E89CE0017AD5A /* VCRRecordingURLProtocol.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = VCRRecordingURLProtocol.m; sourceTree = "<group>"; };
01D6A7F6257E89CE0017AD5A /* VCRReplayingURLProtocol.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = VCRReplayingURLProtocol.m; sourceTree = "<group>"; };
01D6A7F7257E89CE0017AD5A /* VCROrderedMutableDictionary.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = VCROrderedMutableDictionary.h; sourceTree = "<group>"; };
01D6A7F8257E89CE0017AD5A /* VCRRecording.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = VCRRecording.m; sourceTree = "<group>"; };
01D6A7F9257E89CE0017AD5A /* VCR+NSURLSessionConfiguration.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "VCR+NSURLSessionConfiguration.h"; sourceTree = "<group>"; };
01D6A7FA257E89CE0017AD5A /* VCRErrorSerialization.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = VCRErrorSerialization.m; sourceTree = "<group>"; };
01D6A7FB257E89CE0017AD5A /* VCRRequestKey.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = VCRRequestKey.h; sourceTree = "<group>"; };
01D6A7FC257E89CE0017AD5A /* VCRCassetteManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = VCRCassetteManager.h; sourceTree = "<group>"; };
01D6A7FD257E89CE0017AD5A /* VCRCassette.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = VCRCassette.m; sourceTree = "<group>"; };
01D6A7FE257E89CE0017AD5A /* VCR.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = VCR.h; sourceTree = "<group>"; };
01D6A7FF257E89CE0017AD5A /* VCRReplayingURLProtocol.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = VCRReplayingURLProtocol.h; sourceTree = "<group>"; };
01D6A800257E89CE0017AD5A /* VCRRecordingURLProtocol.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = VCRRecordingURLProtocol.h; sourceTree = "<group>"; };
01D6A801257E89CE0017AD5A /* VCRErrorSerialization.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = VCRErrorSerialization.h; sourceTree = "<group>"; };
01D6A802257E89CE0017AD5A /* VCR+NSURLSessionConfiguration.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "VCR+NSURLSessionConfiguration.m"; sourceTree = "<group>"; };
01D6A803257E89CE0017AD5A /* VCRRecording.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = VCRRecording.h; sourceTree = "<group>"; };
01D6A804257E89CE0017AD5A /* VCROrderedMutableDictionary.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = VCROrderedMutableDictionary.m; sourceTree = "<group>"; };
01D6A805257E89CE0017AD5A /* VCRCassetteManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = VCRCassetteManager.m; sourceTree = "<group>"; };
01D6A806257E89CE0017AD5A /* VCRCassette_Private.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = VCRCassette_Private.h; sourceTree = "<group>"; };
01D6A807257E89CE0017AD5A /* VCRRequestKey.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = VCRRequestKey.m; sourceTree = "<group>"; };
01E88BD423690B75002523D1 /* AVPlayerViewControllerManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AVPlayerViewControllerManager.swift; sourceTree = "<group>"; };
044E71F373F947A64C774319 /* Pods-XCDYouTubeKit iOS Demo.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-XCDYouTubeKit iOS Demo.debug.xcconfig"; path = "Pods/Target Support Files/Pods-XCDYouTubeKit iOS Demo/Pods-XCDYouTubeKit iOS Demo.debug.xcconfig"; sourceTree = "<group>"; };
4805F31947DAD8E88035A44A /* Pods-XCDYouTubeKit OS X Demo.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-XCDYouTubeKit OS X Demo.release.xcconfig"; path = "Pods/Target Support Files/Pods-XCDYouTubeKit OS X Demo/Pods-XCDYouTubeKit OS X Demo.release.xcconfig"; sourceTree = "<group>"; };
Expand Down Expand Up @@ -196,9 +227,39 @@
/* End PBXFrameworksBuildPhase section */

/* Begin PBXGroup section */
01D6A7F2257E89CE0017AD5A /* VCRURLConnection */ = {
isa = PBXGroup;
children = (
01D6A7F3257E89CE0017AD5A /* VCR.m */,
01D6A7F4257E89CE0017AD5A /* VCRCassette.h */,
01D6A7F5257E89CE0017AD5A /* VCRRecordingURLProtocol.m */,
01D6A7F6257E89CE0017AD5A /* VCRReplayingURLProtocol.m */,
01D6A7F7257E89CE0017AD5A /* VCROrderedMutableDictionary.h */,
01D6A7F8257E89CE0017AD5A /* VCRRecording.m */,
01D6A7F9257E89CE0017AD5A /* VCR+NSURLSessionConfiguration.h */,
01D6A7FA257E89CE0017AD5A /* VCRErrorSerialization.m */,
01D6A7FB257E89CE0017AD5A /* VCRRequestKey.h */,
01D6A7FC257E89CE0017AD5A /* VCRCassetteManager.h */,
01D6A7FD257E89CE0017AD5A /* VCRCassette.m */,
01D6A7FE257E89CE0017AD5A /* VCR.h */,
01D6A7FF257E89CE0017AD5A /* VCRReplayingURLProtocol.h */,
01D6A800257E89CE0017AD5A /* VCRRecordingURLProtocol.h */,
01D6A801257E89CE0017AD5A /* VCRErrorSerialization.h */,
01D6A802257E89CE0017AD5A /* VCR+NSURLSessionConfiguration.m */,
01D6A803257E89CE0017AD5A /* VCRRecording.h */,
01D6A804257E89CE0017AD5A /* VCROrderedMutableDictionary.m */,
01D6A805257E89CE0017AD5A /* VCRCassetteManager.m */,
01D6A806257E89CE0017AD5A /* VCRCassette_Private.h */,
01D6A807257E89CE0017AD5A /* VCRRequestKey.m */,
);
name = VCRURLConnection;
path = "../../XCDYouTubeKit Tests/VCRURLConnection/VCRURLConnection";
sourceTree = "<group>";
};
C2428AD7191C3C1400065504 /* OS X Demo */ = {
isa = PBXGroup;
children = (
01D6A7F2257E89CE0017AD5A /* VCRURLConnection */,
C2428AE3191C3C1400065504 /* AppDelegate.h */,
C2428AE4191C3C1400065504 /* AppDelegate.m */,
C2428AE6191C3C1400065504 /* MainMenu.xib */,
Expand Down Expand Up @@ -623,8 +684,18 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
01D6A808257E89CE0017AD5A /* VCR.m in Sources */,
01D6A809257E89CF0017AD5A /* VCRRecordingURLProtocol.m in Sources */,
C2428B07191C3DE400065504 /* main.m in Sources */,
01D6A80B257E89CF0017AD5A /* VCRRecording.m in Sources */,
01D6A80A257E89CF0017AD5A /* VCRReplayingURLProtocol.m in Sources */,
01D6A80C257E89CF0017AD5A /* VCRErrorSerialization.m in Sources */,
01D6A80F257E89CF0017AD5A /* VCROrderedMutableDictionary.m in Sources */,
01D6A80E257E89CF0017AD5A /* VCR+NSURLSessionConfiguration.m in Sources */,
C2428AE5191C3C1400065504 /* AppDelegate.m in Sources */,
01D6A80D257E89CF0017AD5A /* VCRCassette.m in Sources */,
01D6A810257E89CF0017AD5A /* VCRCassetteManager.m in Sources */,
01D6A811257E89CF0017AD5A /* VCRRequestKey.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -760,7 +831,7 @@
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
COPY_PHASE_STRIP = NO;
CURRENT_PROJECT_VERSION = 2.15.1;
CURRENT_PROJECT_VERSION = 2.15.2;
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_TESTABILITY = YES;
GCC_C_LANGUAGE_STANDARD = gnu99;
Expand Down Expand Up @@ -804,7 +875,7 @@
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
COPY_PHASE_STRIP = YES;
CURRENT_PROJECT_VERSION = 2.15.1;
CURRENT_PROJECT_VERSION = 2.15.2;
ENABLE_STRICT_OBJC_MSGSEND = YES;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_NO_COMMON_BLOCKS = YES;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,13 @@
ReferencedContainer = "container:XCDYouTubeKit Demo.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
<AdditionalOptions>
</AdditionalOptions>
<EnvironmentVariables>
<EnvironmentVariable
key = "XCDYouTubeKitSaveRequest"
value = "YES"
isEnabled = "NO">
</EnvironmentVariable>
</EnvironmentVariables>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
Expand Down

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

20 changes: 20 additions & 0 deletions XCDYouTubeKit Tests/XCDYouTubeClientTestCase.m
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,26 @@ - (void) testVideo1
[self waitForExpectationsWithTimeout:5 handler:nil];
}

- (void) testVideo2
{
//Add www.youtube.com path:/get_video_info to blacklist in Charles Proxy
__weak XCTestExpectation *expectation = [self expectationWithDescription:@""];
[[XCDYouTubeClient defaultClient] getVideoWithIdentifier:@"CHqg6qOn4no" completionHandler:^(XCDYouTubeVideo *video, NSError *error)
{
XCTAssertNil(error);
XCTAssertNotNil(video.title);
XCTAssertTrue(video.viewCount > 0);
XCTAssertNotNil(video.thumbnailURLs.firstObject);
XCTAssertTrue(video.streamURLs.count > 0);
XCTAssertTrue(video.duration > 0);
[video.streamURLs enumerateKeysAndObjectsUsingBlock:^(NSNumber *key, NSURL *streamURL, BOOL *stop) {
XCTAssertTrue([streamURL.query rangeOfString:@"signature="].location != NSNotFound || [streamURL.query rangeOfString:@"sig="].location != NSNotFound);
}];
[expectation fulfill];
}];
[self waitForExpectationsWithTimeout:5 handler:nil];
}

// See https://github.com/0xced/XCDYouTubeKit/issues/420#issue-400541618

- (void) testVideo1IsPlayable
Expand Down
8 changes: 4 additions & 4 deletions XCDYouTubeKit Tests/XCDYouTubeProtectedVideosTestCase.m
Original file line number Diff line number Diff line change
Expand Up @@ -488,11 +488,11 @@ - (void) testProtectedVideoWithoutSignatureFunction_offline
[self waitForExpectationsWithTimeout:5 handler:nil];
}

// Edit testProtectedVideoWithoutJavaScriptPlayerURL.json by replacing `\"js\":` with `\"xs\":` and and `jsUrl` with `jsXUrl`
- (void) testProtectedVideoWithoutJavaScriptPlayerURL_offline
// Disable (when replacing mutiple values the other values revert back to the original)
- (void) _testProtectedVideoWithoutJavaScriptPlayerURL_offline
{
__weak XCTestExpectation *expectation = [self expectationWithDescription:@""];
[[XCDYouTubeClient defaultClient] getVideoWithIdentifier:@"Pgum6OT_VH8" completionHandler:^(XCDYouTubeVideo *video, NSError *error)
[[XCDYouTubeClient defaultClient] getVideoWithIdentifier:@"nfWlot6h_JM" completionHandler:^(XCDYouTubeVideo *video, NSError *error)
{
XCTAssertNil(video);
XCTAssertEqualObjects(error.domain, XCDYouTubeVideoErrorDomain);
Expand Down Expand Up @@ -520,7 +520,7 @@ - (void) testProtectedVideoWithNonAnonymousJavaScriptPlayerFunction_offline
[self waitForExpectationsWithTimeout:5 handler:nil];
}

// With Charles: Tools -> Black List... -> Add host:www.youtube.com and path:embed/* to simulate connection error on the web page and replace and `jsUrl` with `jsXUrl` in testAgeRestrictedVEVOVideoWithEmbedWebPageConnectionError.json
// With Charles: Tools -> Black List... -> Add host:www.youtube.com and path:embed/* to simulate connection error on the web page and replace and `jsUrl` with `jsXUrl` and `<script` with `<Xcript` in testAgeRestrictedVEVOVideoWithEmbedWebPageConnectionError.json
- (void) testAgeRestrictedVEVOVideoWithEmbedWebPageConnectionError_offline
{
__weak XCTestExpectation *expectation = [self expectationWithDescription:@""];
Expand Down
2 changes: 1 addition & 1 deletion XCDYouTubeKit.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = "XCDYouTubeKit"
s.version = "2.15.1"
s.version = "2.15.2"
s.summary = "YouTube video player for iOS and OS X."
s.homepage = "https://github.com/0xced/XCDYouTubeKit"
s.screenshot = "https://raw.github.com/0xced/XCDYouTubeKit/#{s.version}/Screenshots/XCDYouTubeVideoPlayerViewController.png"
Expand Down
8 changes: 4 additions & 4 deletions XCDYouTubeKit.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -663,10 +663,10 @@
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
COMBINE_HIDPI_IMAGES = YES;
COPY_PHASE_STRIP = NO;
CURRENT_PROJECT_VERSION = 51;
CURRENT_PROJECT_VERSION = 52;
DEFINES_MODULE = YES;
DYLIB_COMPATIBILITY_VERSION = 2.0.0;
DYLIB_CURRENT_VERSION = 2.15.1;
DYLIB_CURRENT_VERSION = 2.15.2;
DYLIB_INSTALL_NAME_BASE = "@rpath";
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_TESTABILITY = YES;
Expand Down Expand Up @@ -741,10 +741,10 @@
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
COMBINE_HIDPI_IMAGES = YES;
COPY_PHASE_STRIP = YES;
CURRENT_PROJECT_VERSION = 51;
CURRENT_PROJECT_VERSION = 52;
DEFINES_MODULE = YES;
DYLIB_COMPATIBILITY_VERSION = 2.0.0;
DYLIB_CURRENT_VERSION = 2.15.1;
DYLIB_CURRENT_VERSION = 2.15.2;
DYLIB_INSTALL_NAME_BASE = "@rpath";
ENABLE_NS_ASSERTIONS = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
Expand Down
18 changes: 16 additions & 2 deletions XCDYouTubeKit/XCDYouTubeVideoOperation.m
Original file line number Diff line number Diff line change
Expand Up @@ -89,13 +89,27 @@ - (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];

NSHTTPCookie *additionalCookie = [NSHTTPCookie cookieWithProperties:@{
NSHTTPCookiePath: @"/",
NSHTTPCookieName: @"PREF",
NSHTTPCookieValue: cookieValue,
NSHTTPCookieDomain:@".youtube.com",
NSHTTPCookieSecure:@"TRUE"
}];

[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;
Expand Down
Loading

0 comments on commit 23f7659

Please sign in to comment.