Skip to content

Commit

Permalink
Merge branch 'release/2.1.2'
Browse files Browse the repository at this point in the history
  • Loading branch information
0xced committed Apr 28, 2015
2 parents 646cba4 + c7533fd commit 2756be0
Show file tree
Hide file tree
Showing 20 changed files with 367 additions and 65 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
#### Version 2.1.2

* Fixed playback of some protected videos. (#122)
* Fixed playback of some age restricted videos. (#137)

#### Version 2.1.1

* Adaptation to YouTube API change. (#116)
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@ XCDYouTubeKit is available through CocoaPods and Carthage.

CocoaPods:
```ruby
pod "XCDYouTubeKit", "~> 2.1.1"
pod "XCDYouTubeKit", "~> 2.1.2"
```

Carthage:
```objc
github "0xced/XCDYouTubeKit" ~> 2.1.1
github "0xced/XCDYouTubeKit" ~> 2.1.2
```

Alternatively, you can manually use the provided static library on iOS or dynamic framework on OS X. In order to use the iOS static library, you must:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,7 @@
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
COPY_PHASE_STRIP = NO;
CURRENT_PROJECT_VERSION = 2.1.1;
CURRENT_PROJECT_VERSION = 2.1.2;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_DYNAMIC_NO_PIC = NO;
GCC_OPTIMIZATION_LEVEL = 0;
Expand Down Expand Up @@ -478,7 +478,7 @@
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
COPY_PHASE_STRIP = YES;
CURRENT_PROJECT_VERSION = 2.1.1;
CURRENT_PROJECT_VERSION = 2.1.2;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_PREPROCESSOR_DEFINITIONS = "NS_BLOCK_ASSERTIONS=1";
GCC_WARN_ABOUT_RETURN_TYPE = YES;
Expand Down
3 changes: 2 additions & 1 deletion XCDYouTubeKit Demo/iOS Demo/DemoInlineViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ - (IBAction) load:(id)sender
{
[self.videoContainerView.subviews makeObjectsPerformSelector:@selector(removeFromSuperview)];

self.videoPlayerViewController = [[XCDYouTubeVideoPlayerViewController alloc] initWithVideoIdentifier:@"VpZmIiIXuZ0"];
NSString *videoIdentifier = [[NSUserDefaults standardUserDefaults] objectForKey:@"VideoIdentifier"];
self.videoPlayerViewController = [[XCDYouTubeVideoPlayerViewController alloc] initWithVideoIdentifier:videoIdentifier];
self.videoPlayerViewController.moviePlayer.backgroundPlaybackEnabled = [[NSUserDefaults standardUserDefaults] boolForKey:@"PlayVideoInBackground"];
[self.videoPlayerViewController presentInView:self.videoContainerView];

Expand Down
3 changes: 2 additions & 1 deletion XCDYouTubeKit Demo/iOS Demo/DemoThumbnailViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ @implementation DemoThumbnailViewController

- (IBAction) loadThumbnail:(id)sender
{
self.videoPlayerViewController = [[XCDYouTubeVideoPlayerViewController alloc] initWithVideoIdentifier:@"VpZmIiIXuZ0"];
NSString *videoIdentifier = [[NSUserDefaults standardUserDefaults] objectForKey:@"VideoIdentifier"];
self.videoPlayerViewController = [[XCDYouTubeVideoPlayerViewController alloc] initWithVideoIdentifier:videoIdentifier];
self.videoPlayerViewController.moviePlayer.backgroundPlaybackEnabled = [[NSUserDefaults standardUserDefaults] boolForKey:@"PlayVideoInBackground"];

NSNotificationCenter *defaultCenter = [NSNotificationCenter defaultCenter];
Expand Down
8 changes: 8 additions & 0 deletions XCDYouTubeKit Demo/iOS Demo/PlayerEventLogger.m
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,15 @@ - (void) setEnabled:(BOOL)enabled
[defaultCenter addObserver:self selector:@selector(moviePlayerPlaybackDidFinish:) name:MPMoviePlayerPlaybackDidFinishNotification object:nil];
[defaultCenter addObserver:self selector:@selector(moviePlayerPlaybackStateDidChange:) name:MPMoviePlayerPlaybackStateDidChangeNotification object:nil];
[defaultCenter addObserver:self selector:@selector(moviePlayerLoadStateDidChange:) name:MPMoviePlayerLoadStateDidChangeNotification object:nil];
[defaultCenter addObserver:self selector:@selector(moviePlayerNowPlayingMovieDidChange:) name:MPMoviePlayerNowPlayingMovieDidChangeNotification object:nil];
}
else
{
[defaultCenter removeObserver:self name:XCDYouTubeVideoPlayerViewControllerDidReceiveVideoNotification object:nil];
[defaultCenter removeObserver:self name:MPMoviePlayerPlaybackDidFinishNotification object:nil];
[defaultCenter removeObserver:self name:MPMoviePlayerPlaybackStateDidChangeNotification object:nil];
[defaultCenter removeObserver:self name:MPMoviePlayerLoadStateDidChangeNotification object:nil];
[defaultCenter removeObserver:self name:MPMoviePlayerNowPlayingMovieDidChangeNotification object:nil];
}
}

Expand Down Expand Up @@ -104,6 +106,12 @@ - (void) moviePlayerLoadStateDidChange:(NSNotification *)notification
NSLog(@"Load State: %@", loadState.length > 0 ? [loadState substringFromIndex:3] : @"N/A");
}

- (void) moviePlayerNowPlayingMovieDidChange:(NSNotification *)notification
{
MPMoviePlayerController *moviePlayerController = notification.object;
NSLog(@"Now Playing %@", moviePlayerController.contentURL);
}

- (void) videoPlayerViewControllerDidReceiveVideo:(NSNotification *)notification
{
NSLog(@"Video: %@", notification.userInfo[XCDYouTubeVideoUserInfoKey]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,13 @@
<string>EdeVaT-zZt4</string>
</dict>
<dict>
<key>VEVO</key>
<key>VEVO (Mumford &amp; Sons)</key>
<string>rId6PKlDXeU</string>
</dict>
<dict>
<key>VEVO (Rihanna)</key>
<string>tg00YEETFzg</string>
</dict>
<dict>
<key>Age Restricted</key>
<string>zKovmts2KSk</string>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
"uri" : "https:\/\/www.youtube.com\/get_video_info?el=embedded&hl=en&ps=default&video_id=tooShort"
},
{
"body" : "errorcode=2&status=fail&reason=invalid+or+missing+video+id",
"body" : "errorcode=2&status=fail&reason=Invalid+parameters.",
"headers" : {
"x-content-type-options" : "nosniff",
"Content-Type" : "application\/x-www-form-urlencoded",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
"uri" : "https:\/\/s.ytimg.com\/yts\/jsbin\/html5player-en_US-vflKjOTVq\/html5player.js"
},
{
"body" : "status=fail&errorcode=2&reason=invalid+or+missing+video+id",
"body" : "status=fail&errorcode=2&reason=Invalid+parameters.",
"headers" : {
"x-content-type-options" : "nosniff",
"Content-Type" : "application\/x-www-form-urlencoded",
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
"uri" : "https:\/\/s.ytimg.com\/yts\/jsbin\/html5player-en_US-vflKjOTVq\/html5player.js"
},
{
"body" : "errorcode=2&status=fail&reason=invalid+or+missing+video+id",
"body" : "errorcode=2&status=fail&reason=Invalid+parameters.",
"headers" : {
"x-content-type-options" : "nosniff",
"Content-Type" : "application\/x-www-form-urlencoded",
Expand Down

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions XCDYouTubeKit Tests/XCDYouTubeClientTestCase.m
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ - (void) testRestrictedVideo
XCTAssertNil(video);
XCTAssertEqualObjects(error.domain, XCDYouTubeVideoErrorDomain);
XCTAssertEqual(error.code, XCDYouTubeErrorRestrictedPlayback);
XCTAssertEqualObjects(error.localizedDescription, @"This video is currently unavailable. We are working to bring it back.");
XCTAssertEqualObjects(error.localizedDescription, @"This video contains content from Youtube test content owner, who has blocked it on copyright grounds.");
[expectation fulfill];
}];
[self waitForExpectationsWithTimeout:5 handler:nil];
Expand Down Expand Up @@ -150,7 +150,7 @@ - (void) testInvalidVideoIdentifier
XCTAssertNil(video);
XCTAssertEqualObjects(error.domain, XCDYouTubeVideoErrorDomain);
XCTAssertEqual(error.code, XCDYouTubeErrorInvalidVideoIdentifier);
XCTAssertEqualObjects(error.localizedDescription, @"invalid or missing video id");
XCTAssertEqualObjects(error.localizedDescription, @"Invalid parameters.");
[expectation fulfill];
}];
[self waitForExpectationsWithTimeout:5 handler:nil];
Expand Down Expand Up @@ -192,7 +192,7 @@ - (void) testNilVideoIdentifier
XCTAssertNil(video);
XCTAssertEqualObjects(error.domain, XCDYouTubeVideoErrorDomain);
XCTAssertEqual(error.code, XCDYouTubeErrorInvalidVideoIdentifier);
XCTAssertEqualObjects(error.localizedDescription, @"invalid or missing video id");
XCTAssertEqualObjects(error.localizedDescription, @"Invalid parameters.");
[expectation fulfill];
}];
[self waitForExpectationsWithTimeout:5 handler:nil];
Expand All @@ -206,7 +206,7 @@ - (void) testSpaceVideoIdentifier
XCTAssertNil(video);
XCTAssertEqualObjects(error.domain, XCDYouTubeVideoErrorDomain);
XCTAssertEqual(error.code, XCDYouTubeErrorInvalidVideoIdentifier);
XCTAssertEqualObjects(error.localizedDescription, @"invalid or missing video id");
XCTAssertEqualObjects(error.localizedDescription, @"Invalid parameters.");
[expectation fulfill];
}];
[self waitForExpectationsWithTimeout:5 handler:nil];
Expand Down
47 changes: 46 additions & 1 deletion XCDYouTubeKit Tests/XCDYouTubeProtectedVideosTestCase.m
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,28 @@ - (void) testAgeRestrictedVideo
[self waitForExpectationsWithTimeout:5 handler:nil];
}

- (void) testAgeRestrictedUnratedVideo
{
__weak XCTestExpectation *expectation = [self expectationWithDescription:@""];
[[XCDYouTubeClient defaultClient] getVideoWithIdentifier:@"KGZzuVNwJHY" completionHandler:^(XCDYouTubeVideo *video, NSError *error)
{
XCTAssertNil(error);
XCTAssertNotNil(video.title);
XCTAssertNotNil(video.expirationDate);
XCTAssertNotNil(video.smallThumbnailURL);
XCTAssertNotNil(video.mediumThumbnailURL);
XCTAssertNotNil(video.largeThumbnailURL);
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);
}];
[expectation fulfill];
}];
[self waitForExpectationsWithTimeout:5 handler:nil];
}

- (void) testProtectedVEVOVideo1
{
__weak XCTestExpectation *expectation = [self expectationWithDescription:@""];
Expand Down Expand Up @@ -65,7 +87,6 @@ - (void) testProtectedVEVOVideo2
XCTAssertNotNil(video.expirationDate);
XCTAssertNotNil(video.smallThumbnailURL);
XCTAssertNotNil(video.mediumThumbnailURL);
XCTAssertNotNil(video.largeThumbnailURL);
XCTAssertTrue(video.streamURLs.count > 0);
XCTAssertTrue(video.duration > 0);
[video.streamURLs enumerateKeysAndObjectsUsingBlock:^(NSNumber *key, NSURL *streamURL, BOOL *stop)
Expand Down Expand Up @@ -99,6 +120,30 @@ - (void) testProtectedVEVOVideo3
[self waitForExpectationsWithTimeout:5 handler:nil];
}

- (void) testProtectedVEVOIsPlayable
{
__weak XCTestExpectation *expectation = [self expectationWithDescription:@""];
[[XCDYouTubeClient defaultClient] getVideoWithIdentifier:@"tg00YEETFzg" completionHandler:^(XCDYouTubeVideo *video, NSError *error)
{
XCTAssertNil(error);
XCTAssertNotNil(video.title);
XCTAssertNotNil(video.expirationDate);
XCTAssertNotNil(video.smallThumbnailURL);
XCTAssertNotNil(video.mediumThumbnailURL);
XCTAssertNotNil(video.largeThumbnailURL);
XCTAssertTrue(video.streamURLs.count > 0);
XCTAssertTrue(video.duration > 0);
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:video.streamURLs[@(XCDYouTubeVideoQualityHD720)]];
request.HTTPMethod = @"HEAD";
[NSURLConnection sendAsynchronousRequest:request queue:[NSOperationQueue mainQueue] completionHandler:^(NSURLResponse *response, NSData *data, NSError *connectionError)
{
XCTAssertEqual([(NSHTTPURLResponse *)response statusCode], 200);
[expectation fulfill];
}];
}];
[self waitForExpectationsWithTimeout:5 handler:nil];
}

- (void) testAgeRestrictedVEVOVideo
{
__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.1.1"
s.version = "2.1.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
6 changes: 3 additions & 3 deletions XCDYouTubeKit.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -833,7 +833,7 @@
COPY_PHASE_STRIP = NO;
CURRENT_PROJECT_VERSION = "$(DYLIB_CURRENT_VERSION)";
DYLIB_COMPATIBILITY_VERSION = 2.0.0;
DYLIB_CURRENT_VERSION = 2.1.1;
DYLIB_CURRENT_VERSION = 2.1.2;
DYLIB_INSTALL_NAME_BASE = "@rpath";
ENABLE_STRICT_OBJC_MSGSEND = YES;
GCC_C_LANGUAGE_STANDARD = gnu99;
Expand Down Expand Up @@ -885,7 +885,7 @@
COPY_PHASE_STRIP = YES;
CURRENT_PROJECT_VERSION = "$(DYLIB_CURRENT_VERSION)";
DYLIB_COMPATIBILITY_VERSION = 2.0.0;
DYLIB_CURRENT_VERSION = 2.1.1;
DYLIB_CURRENT_VERSION = 2.1.2;
DYLIB_INSTALL_NAME_BASE = "@rpath";
ENABLE_STRICT_OBJC_MSGSEND = YES;
GCC_C_LANGUAGE_STANDARD = gnu99;
Expand Down Expand Up @@ -950,7 +950,7 @@
COPY_PHASE_STRIP = NO;
CURRENT_PROJECT_VERSION = "$(DYLIB_CURRENT_VERSION)";
DYLIB_COMPATIBILITY_VERSION = 2.0.0;
DYLIB_CURRENT_VERSION = 2.1.1;
DYLIB_CURRENT_VERSION = 2.1.2;
DYLIB_INSTALL_NAME_BASE = "@rpath";
ENABLE_STRICT_OBJC_MSGSEND = YES;
GCC_C_LANGUAGE_STANDARD = gnu99;
Expand Down
2 changes: 1 addition & 1 deletion XCDYouTubeKit/XCDYouTubeVideo.m
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ - (instancetype) initWithIdentifier:(NSString *)identifier info:(NSDictionary *)
return nil;
}
NSString *signature = [playerScript unscrambleSignature:scrambledSignature];
if (playerScript && !signature)
if (playerScript && scrambledSignature && !signature)
continue;

NSString *urlString = stream[@"url"];
Expand Down
2 changes: 1 addition & 1 deletion XCDYouTubeKit/XCDYouTubeVideoOperation.m
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ - (void) handleJavaScriptPlayerResponse
if (self.webpage.isAgeRestricted)
{
NSString *eurl = [@"https://youtube.googleapis.com/v/" stringByAppendingString:self.videoIdentifier];
NSString *sts = [self.embedWebpage.playerConfiguration[@"sts"] description] ?: @"";
NSString *sts = [self.embedWebpage.playerConfiguration[@"sts"] description] ?: [self.webpage.playerConfiguration[@"sts"] description] ?: @"";
NSDictionary *query = @{ @"video_id": self.videoIdentifier, @"hl": self.languageIdentifier, @"eurl": eurl, @"sts": sts};
NSString *queryString = XCDQueryStringWithDictionary(query, NSUTF8StringEncoding);
NSURL *videoInfoURL = [NSURL URLWithString:[@"https://www.youtube.com/get_video_info?" stringByAppendingString:queryString]];
Expand Down

0 comments on commit 2756be0

Please sign in to comment.