Skip to content

Commit

Permalink
Merge branch 'release/2.6.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
SoneeJohn committed Sep 28, 2018
2 parents 9b472f3 + 4f06a8a commit 6cf17c2
Show file tree
Hide file tree
Showing 38 changed files with 1,312 additions and 806 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.5.6
module_version: 2.6.0

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.5.6/XCDYouTubeKit
github_file_prefix: https://github.com/0xced/XCDYouTubeKit/tree/2.6.0/XCDYouTubeKit
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
#### Version 2.6.0

* Adaptation to YouTube API change. (#383, #388, #385, #382)
* Include DASH formats URLs in `streamURLs`. (#354)
* Add new `autoGeneratedCaptionURLs` and `captionURLs` properties to `XCDYouTubeVideo`. (#281)
* Fix `Messaging unqualified id` warnings. (#393)
* Deprecated `smallThumbnailURL`, `mediumThumbnailURL`, `largeThumbnailURL`. Use `thumbnailURL` instead.

#### Version 2.5.6

* Xcode 9 compatibility (#345, #347, #349)
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
## About

[![Build Status](https://img.shields.io/circleci/project/0xced/XCDYouTubeKit/master.svg?style=flat)](https://circleci.com/gh/0xced/XCDYouTubeKit)
[![Coverage Status](https://img.shields.io/codecov/c/github/0xced/XCDYouTubeKit/master.svg?style=flat)](https://codecov.io/gh/0xced/XCDYouTubeKit/branch/master)
[![Build Status](https://img.shields.io/circleci/project/0xced/XCDYouTubeKit/develop.svg?style=flat)](https://circleci.com/gh/0xced/XCDYouTubeKit)
[![Coverage Status](https://img.shields.io/codecov/c/github/0xced/XCDYouTubeKit/develop.svg?style=flat)](https://codecov.io/gh/0xced/XCDYouTubeKit/branch/develop)
[![Platform](https://img.shields.io/cocoapods/p/XCDYouTubeKit.svg?style=flat)](http://cocoadocs.org/docsets/XCDYouTubeKit/)
[![Pod Version](https://img.shields.io/cocoapods/v/XCDYouTubeKit.svg?style=flat)](https://cocoapods.org/pods/XCDYouTubeKit)
[![Carthage Compatibility](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage/)
Expand Down Expand Up @@ -32,13 +32,13 @@ XCDYouTubeKit is available through CocoaPods and Carthage.
CocoaPods:

```ruby
pod "XCDYouTubeKit", "~> 2.5"
pod "XCDYouTubeKit", "~> 2.6"
```

Carthage:

```objc
github "0xced/XCDYouTubeKit" ~> 2.5
github "0xced/XCDYouTubeKit" ~> 2.6
```

Alternatively, you can manually use the provided static library or dynamic framework. In order to use the static library, you must:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -760,7 +760,7 @@
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
COPY_PHASE_STRIP = NO;
CURRENT_PROJECT_VERSION = 2.5.6;
CURRENT_PROJECT_VERSION = 2.6.0;
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_TESTABILITY = YES;
GCC_C_LANGUAGE_STANDARD = gnu99;
Expand Down Expand Up @@ -804,7 +804,7 @@
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
COPY_PHASE_STRIP = YES;
CURRENT_PROJECT_VERSION = 2.5.6;
CURRENT_PROJECT_VERSION = 2.6.0;
ENABLE_STRICT_OBJC_MSGSEND = YES;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_NO_COMMON_BLOCKS = YES;
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.

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.

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.

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.

78 changes: 63 additions & 15 deletions XCDYouTubeKit Tests/XCDYouTubeClientTestCase.m
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,71 @@ - (void) testThatVideoHasMetadata
XCTAssertNil(error);
XCTAssertEqualObjects(video.identifier, @"9TTioMbNT9I");
XCTAssertEqualObjects(video.title, @"Super Mario Bros Theme Song on Wine Glasses and a Frying Pan (슈퍼 마리오 브라더스 - スーパーマリオブラザーズ - 超級瑪莉)");
XCTAssertNotNil(video.smallThumbnailURL);
XCTAssertNotNil(video.mediumThumbnailURL);
XCTAssertNotNil(video.largeThumbnailURL);
XCTAssertNotNil(video.thumbnailURL);
XCTAssertTrue(video.streamURLs.count > 0);
XCTAssertTrue(video.duration > 0);
[expectation fulfill];
}];
[self waitForExpectationsWithTimeout:5 handler:nil];
}

- (void) testVideoThatHasCaptions
{
__weak XCTestExpectation *expectation = [self expectationWithDescription:@""];
[[XCDYouTubeClient defaultClient] getVideoWithIdentifier:@"_g8aLVGXyc0" completionHandler:^(XCDYouTubeVideo *video, NSError *error)
{
XCTAssertNotNil(video);
XCTAssertNotNil(video);
XCTAssertNotNil(video.captionURLs);
XCTAssertNotNil(video.autoGeneratedCaptionURLs);
XCTAssertNotEqual(video.autoGeneratedCaptionURLs[@"en"], video.captionURLs[@"en"]);
[expectation fulfill];
}];
[self waitForExpectationsWithTimeout:5 handler:nil];

}

- (void)testVideoWithDashManifest
{
__weak XCTestExpectation *expectation = [self expectationWithDescription:@""];
[[XCDYouTubeClient defaultClient] getVideoWithIdentifier:@"YLg-LCkYXbI" completionHandler:^(XCDYouTubeVideo *video, NSError *error)
{
XCTAssertNotNil(video);
XCTAssertNotNil(video.streamURLs[@299], @"Could not find Dash video 299 in `streamURLs`"); //itag=299: {'ext': 'mp4', 'height': 1080, 'format_note': 'DASH video', 'vcodec': 'h264', 'fps': 60}
[expectation fulfill];
}];
[self waitForExpectationsWithTimeout:5 handler:nil];
}

//See -[XCDYouTubeVideoOperation handleConnectionError:requestType]
- (void)testConnectionErrorWithDashManifest
{
__weak XCTestExpectation *expectation = [self expectationWithDescription:@""];
[[XCDYouTubeClient defaultClient] getVideoWithIdentifier:@"YLg-LCkYXbI" completionHandler:^(XCDYouTubeVideo *video, NSError *error)
{
XCTAssertNotNil(video);
XCTAssertNil(video.streamURLs[@299]);

[expectation fulfill];
}];
[self waitForExpectationsWithTimeout:5 handler:nil];
}

- (void) testVideoWithUndeterminedCaptionLanguageCode
{
__weak XCTestExpectation *expectation = [self expectationWithDescription:@""];
[[XCDYouTubeClient defaultClient] getVideoWithIdentifier:@"RgKAFK5djSk" completionHandler:^(XCDYouTubeVideo *video, NSError *error)
{
XCTAssertNil(error);
XCTAssertNotNil(video);
XCTAssertNil(video.captionURLs[@"und"]);
XCTAssertNotNil(video.captionURLs);
[expectation fulfill];
}];
[self waitForExpectationsWithTimeout:5 handler:nil];

}

- (void) testMobileRestrictedVideo
{
__weak XCTestExpectation *expectation = [self expectationWithDescription:@""];
Expand All @@ -49,9 +104,7 @@ - (void) testMobileRestrictedVideo
XCTAssertNil(error);
XCTAssertNotNil(video.title);
XCTAssertNotNil(video.expirationDate);
XCTAssertNotNil(video.smallThumbnailURL);
XCTAssertNotNil(video.mediumThumbnailURL);
XCTAssertNotNil(video.largeThumbnailURL);
XCTAssertNotNil(video.thumbnailURL);
XCTAssertTrue(video.streamURLs.count > 0);
XCTAssertTrue(video.duration > 0);
[video.streamURLs enumerateKeysAndObjectsUsingBlock:^(NSNumber *key, NSURL *streamURL, BOOL *stop) {
Expand All @@ -65,15 +118,11 @@ - (void) testMobileRestrictedVideo
- (void) testLiveVideo
{
__weak XCTestExpectation *expectation = [self expectationWithDescription:@""];
[[XCDYouTubeClient defaultClient] getVideoWithIdentifier:@"y60wDzZt8yg" completionHandler:^(XCDYouTubeVideo *video, NSError *error)
[[XCDYouTubeClient defaultClient] getVideoWithIdentifier:@"wv8NRHysoo0" completionHandler:^(XCDYouTubeVideo *video, NSError *error)
{
XCTAssertNil(error);
XCTAssertNil(video.expirationDate);
XCTAssertNotNil(video.title);
XCTAssertNotNil(video.smallThumbnailURL);
XCTAssertNotNil(video.mediumThumbnailURL);
XCTAssertNotNil(video.largeThumbnailURL);
XCTAssertEqual(video.streamURLs.count, 1U);
XCTAssertNotNil(video.thumbnailURL);
XCTAssertNotNil(video.streamURLs[XCDYouTubeVideoQualityHTTPLiveStreaming]);
[expectation fulfill];
}];
Expand Down Expand Up @@ -103,7 +152,7 @@ - (void) testRestrictedVideo
XCTAssertNil(video);
XCTAssertEqualObjects(error.domain, XCDYouTubeVideoErrorDomain);
XCTAssertEqual(error.code, XCDYouTubeErrorRestrictedPlayback);
XCTAssertEqualObjects(error.localizedDescription, @"This video contains content from Youtube test content owner, who has blocked it on copyright grounds.");
XCTAssertEqualObjects(error.localizedDescription, @"This video is no longer available because the YouTube account associated with this video has been terminated.");
[expectation fulfill];
}];
[self waitForExpectationsWithTimeout:5 handler:nil];
Expand All @@ -120,7 +169,7 @@ - (void) testRemovedVideo
XCTAssertNil(video);
XCTAssertEqualObjects(error.domain, XCDYouTubeVideoErrorDomain);
XCTAssertEqual(error.code, XCDYouTubeErrorRestrictedPlayback);
XCTAssertEqualObjects(error.localizedDescription, @"\"9/11 The F...\" This video is no longer available due to a copyright claim by Digital Rights Group Ltd.");
XCTAssertEqualObjects(error.localizedDescription, @"\"9/11 The F...\" is no longer available due to a copyright claim by Digital Rights Group Ltd.");
[expectation fulfill];
}];
[self waitForExpectationsWithTimeout:5 handler:nil];
Expand All @@ -135,7 +184,6 @@ - (void) testGeoblockedVideo
XCTAssertEqualObjects(error.domain, XCDYouTubeVideoErrorDomain);
XCTAssertEqual(error.code, XCDYouTubeErrorRestrictedPlayback);
XCTAssertEqualObjects(error.localizedDescription, @"The uploader has not made this video available in your country.");
XCTAssertEqualObjects(error.userInfo[XCDYouTubeAllowedCountriesUserInfoKey], [NSSet setWithArray:(@[ @"American Samoa", @"Canada", @"Guam", @"Northern Mariana Islands", @"Puerto Rico", @"U.S. Outlying Islands", @"United States", @"U.S. Virgin Islands" ])]);
[expectation fulfill];
}];
[self waitForExpectationsWithTimeout:5 handler:nil];
Expand Down
45 changes: 16 additions & 29 deletions XCDYouTubeKit Tests/XCDYouTubeProtectedVideosTestCase.m
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,7 @@ - (void) testAgeRestrictedVideo
XCTAssertNil(error);
XCTAssertNotNil(video.title);
XCTAssertNotNil(video.expirationDate);
XCTAssertNotNil(video.smallThumbnailURL);
XCTAssertNotNil(video.mediumThumbnailURL);
XCTAssertNotNil(video.largeThumbnailURL);
XCTAssertNotNil(video.thumbnailURL);
XCTAssertTrue(video.streamURLs.count > 0);
XCTAssertTrue(video.duration > 0);
[video.streamURLs enumerateKeysAndObjectsUsingBlock:^(NSNumber *key, NSURL *streamURL, BOOL *stop)
Expand All @@ -41,9 +39,7 @@ - (void) testAgeRestrictedUnratedVideo
XCTAssertNil(error);
XCTAssertNotNil(video.title);
XCTAssertNotNil(video.expirationDate);
XCTAssertNotNil(video.smallThumbnailURL);
XCTAssertNotNil(video.mediumThumbnailURL);
XCTAssertNotNil(video.largeThumbnailURL);
XCTAssertNotNil(video.thumbnailURL);
XCTAssertTrue(video.streamURLs.count > 0);
XCTAssertTrue(video.duration > 0);
[video.streamURLs enumerateKeysAndObjectsUsingBlock:^(NSNumber *key, NSURL *streamURL, BOOL *stop)
Expand All @@ -63,9 +59,7 @@ - (void) testProtectedVEVOVideo1
XCTAssertNil(error);
XCTAssertNotNil(video.title);
XCTAssertNotNil(video.expirationDate);
XCTAssertNotNil(video.smallThumbnailURL);
XCTAssertNotNil(video.mediumThumbnailURL);
XCTAssertNotNil(video.largeThumbnailURL);
XCTAssertNotNil(video.thumbnailURL);
XCTAssertTrue(video.streamURLs.count > 0);
XCTAssertTrue(video.duration > 0);
[video.streamURLs enumerateKeysAndObjectsUsingBlock:^(NSNumber *key, NSURL *streamURL, BOOL *stop)
Expand All @@ -85,8 +79,7 @@ - (void) testProtectedVEVOVideo2
XCTAssertNil(error);
XCTAssertNotNil(video.title);
XCTAssertNotNil(video.expirationDate);
XCTAssertNotNil(video.smallThumbnailURL);
XCTAssertNotNil(video.mediumThumbnailURL);
XCTAssertNotNil(video.thumbnailURL);
XCTAssertTrue(video.streamURLs.count > 0);
XCTAssertTrue(video.duration > 0);
[video.streamURLs enumerateKeysAndObjectsUsingBlock:^(NSNumber *key, NSURL *streamURL, BOOL *stop)
Expand All @@ -106,9 +99,7 @@ - (void) testProtectedVEVOVideo3
XCTAssertNil(error);
XCTAssertNotNil(video.title);
XCTAssertNotNil(video.expirationDate);
XCTAssertNotNil(video.smallThumbnailURL);
XCTAssertNotNil(video.mediumThumbnailURL);
XCTAssertNotNil(video.largeThumbnailURL);
XCTAssertNotNil(video.thumbnailURL);
XCTAssertTrue(video.streamURLs.count > 0);
XCTAssertTrue(video.duration > 0);
[video.streamURLs enumerateKeysAndObjectsUsingBlock:^(NSNumber *key, NSURL *streamURL, BOOL *stop)
Expand All @@ -128,12 +119,10 @@ - (void) testProtectedVEVOIsPlayable
XCTAssertNil(error);
XCTAssertNotNil(video.title);
XCTAssertNotNil(video.expirationDate);
XCTAssertNotNil(video.smallThumbnailURL);
XCTAssertNotNil(video.mediumThumbnailURL);
XCTAssertNotNil(video.largeThumbnailURL);
XCTAssertNotNil(video.thumbnailURL);
XCTAssertTrue(video.streamURLs.count > 0);
XCTAssertTrue(video.duration > 0);
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:video.streamURLs[@(XCDYouTubeVideoQualityHD720)]];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:video.streamURLs[@(XCDYouTubeVideoQualityMedium360)]];
request.HTTPMethod = @"HEAD";
NSURLSessionDataTask *dataTask = [[NSURLSession sharedSession] dataTaskWithRequest:request completionHandler:^(NSData *data, NSURLResponse *response, NSError *connectionError)
{
Expand Down Expand Up @@ -172,9 +161,7 @@ - (void) testAgeRestrictedVEVOVideo
XCTAssertNil(error);
XCTAssertNotNil(video.title);
XCTAssertNotNil(video.expirationDate);
XCTAssertNotNil(video.smallThumbnailURL);
XCTAssertNotNil(video.mediumThumbnailURL);
XCTAssertNotNil(video.largeThumbnailURL);
XCTAssertNotNil(video.thumbnailURL);
XCTAssertTrue(video.streamURLs.count > 0);
XCTAssertTrue(video.duration > 0);
[video.streamURLs enumerateKeysAndObjectsUsingBlock:^(NSNumber *key, NSURL *streamURL, BOOL *stop)
Expand All @@ -197,13 +184,13 @@ - (void) testProtectedVideoWithWebPageConnectionError_offline
XCTAssertNil(video);
XCTAssertEqualObjects(error.domain, XCDYouTubeVideoErrorDomain);
XCTAssertEqual(error.code, XCDYouTubeErrorRestrictedPlayback);
XCTAssertEqualObjects(error.localizedDescription, @"This video contains content from WMG. It is restricted from playback on certain sites. Watch on YouTube");
XCTAssertEqualObjects(error.localizedDescription, @"This video is unavailable.");
[expectation fulfill];
}];
[self waitForExpectationsWithTimeout:1 handler:nil];
}

// With Charles: Tools -> Black List... -> Add `s.ytimg.com` to simulate connection error on the player script
// With Charles: Tools -> Black List... -> Add host:www.youtube.com and path:yts/* to simulate connection error on the player script
- (void) testProtectedVideoWithPlayerScriptConnectionError_offline
{
__weak XCTestExpectation *expectation = [self expectationWithDescription:@""];
Expand All @@ -212,13 +199,13 @@ - (void) testProtectedVideoWithPlayerScriptConnectionError_offline
XCTAssertNil(video);
XCTAssertEqualObjects(error.domain, XCDYouTubeVideoErrorDomain);
XCTAssertEqual(error.code, XCDYouTubeErrorRestrictedPlayback);
XCTAssertEqualObjects(error.localizedDescription, @"This video contains content from WMG. It is restricted from playback on certain sites. Watch on YouTube");
XCTAssertEqualObjects(error.localizedDescription, @"This video is unavailable.");
[expectation fulfill];
}];
[self waitForExpectationsWithTimeout:1 handler:nil];
}

// Edit testProtectedVideoWithoutSignatureFunction.json by replacing `\"signature\",` with `\"signaturX\",`
// Edit testProtectedVideoWithoutSignatureFunction.json by replacing `"akamaized",` with `"Xakamaized",`
- (void) testProtectedVideoWithoutSignatureFunction_offline
{
__weak XCTestExpectation *expectation = [self expectationWithDescription:@""];
Expand All @@ -227,7 +214,7 @@ - (void) testProtectedVideoWithoutSignatureFunction_offline
XCTAssertNil(video);
XCTAssertEqualObjects(error.domain, XCDYouTubeVideoErrorDomain);
XCTAssertEqual(error.code, XCDYouTubeErrorRestrictedPlayback);
XCTAssertEqualObjects(error.localizedDescription, @"This video contains content from WMG. It is restricted from playback on certain sites. Watch on YouTube");
XCTAssertEqualObjects(error.localizedDescription, @"This video is unavailable.");
[expectation fulfill];
}];
[self waitForExpectationsWithTimeout:1 handler:nil];
Expand All @@ -242,7 +229,7 @@ - (void) testProtectedVideoWithBrokenSignatureFunction_offline
XCTAssertNil(video);
XCTAssertEqualObjects(error.domain, XCDYouTubeVideoErrorDomain);
XCTAssertEqual(error.code, XCDYouTubeErrorRestrictedPlayback);
XCTAssertEqualObjects(error.localizedDescription, @"This video contains content from WMG. It is restricted from playback on certain sites. Watch on YouTube");
XCTAssertEqualObjects(error.localizedDescription, @"This video is unavailable.");
[expectation fulfill];
}];
[self waitForExpectationsWithTimeout:1 handler:nil];
Expand All @@ -257,7 +244,7 @@ - (void) testProtectedVideoWithoutJavaScriptPlayerURL_offline
XCTAssertNil(video);
XCTAssertEqualObjects(error.domain, XCDYouTubeVideoErrorDomain);
XCTAssertEqual(error.code, XCDYouTubeErrorRestrictedPlayback);
XCTAssertEqualObjects(error.localizedDescription, @"This video contains content from WMG. It is restricted from playback on certain sites. Watch on YouTube");
XCTAssertEqualObjects(error.localizedDescription, @"This video is unavailable.");
[expectation fulfill];
}];
[self waitForExpectationsWithTimeout:1 handler:nil];
Expand All @@ -272,7 +259,7 @@ - (void) testProtectedVideoWithNonAnonymousJavaScriptPlayerFunction_offline
XCTAssertNil(video);
XCTAssertEqualObjects(error.domain, XCDYouTubeVideoErrorDomain);
XCTAssertEqual(error.code, XCDYouTubeErrorRestrictedPlayback);
XCTAssertEqualObjects(error.localizedDescription, @"This video contains content from WMG. It is restricted from playback on certain sites. Watch on YouTube");
XCTAssertEqualObjects(error.localizedDescription, @"This video is unavailable.");
[expectation fulfill];
}];
[self waitForExpectationsWithTimeout:1 handler:nil];
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.5.6"
s.version = "2.6.0"
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
Loading

0 comments on commit 6cf17c2

Please sign in to comment.