Skip to content

Commit

Permalink
Merge branch 'release/2.10.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
SoneeJohn committed Feb 17, 2020
2 parents f94baed + a3d1afd commit 1bd1061
Show file tree
Hide file tree
Showing 56 changed files with 2,462 additions and 552 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.9.0
module_version: 2.10.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.9.0/XCDYouTubeKit
github_file_prefix: https://github.com/0xced/XCDYouTubeKit/tree/2.10.0/XCDYouTubeKit
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
#### Version 2.10.0

* Fixed issue that caused certain videos to return error (#468)
* Add the ability to query `XCDYouTubeVideo` for reachable streams via `-[XCDYouTubeClient queryVideo:video:cookies:completionHandler:]` & `XCDYouTubeVideoQueryOperation` class
* Add new `videoIdentifiers` property in `XCDYouTubeVideo` (#290)

#### Version 2.9.0

* Add the ability to use custom regular expression patterns via `-[XCDYouTubeClient getVideoWithIdentifier:cookies:customPatterns:completionHandler:]` & `initWithVideoIdentifier:cookies:languageIdentifier:customPatterns` (#463, #199)
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,13 @@ XCDYouTubeKit is available through [CocoaPods](https://cocoapods.org/), [Carthag
CocoaPods:

```ruby
pod "XCDYouTubeKit", "~> 2.9"
pod "XCDYouTubeKit", "~> 2.10"
```

Carthage:

```objc
github "0xced/XCDYouTubeKit" ~> 2.9
github "0xced/XCDYouTubeKit" ~> 2.10
```

Swift Package Manager:
Expand All @@ -48,7 +48,7 @@ Add `XCDYouTubeKit` to the dependencies value of your `Package.swift`

```swift
dependencies: [
.package(url: "https://github.com/0xced/XCDYouTubeKit.git", from: "2.9.0")
.package(url: "https://github.com/0xced/XCDYouTubeKit.git", from: "2.10.0")
]
```

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.9.0;
CURRENT_PROJECT_VERSION = 2.10.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.9.0;
CURRENT_PROJECT_VERSION = 2.10.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.

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.

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[]
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[]
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
[
{
"body" : "",
"headers" : {
"X-Content-Type-Options" : "nosniff",
"Content-Type" : "text\/html; charset=utf-8",
"Server" : "YouTube Frontend Proxy",
"Cache-Control" : "no-cache",
"Date" : "Mon, 17 Feb 2020 14:12:18 GMT",
"X-XSS-Protection" : "0",
"Alt-Svc" : "quic=\":443\"; ma=2592000; v=\"46,43\",h3-Q050=\":443\"; ma=2592000,h3-Q049=\":443\"; ma=2592000,h3-Q048=\":443\"; ma=2592000,h3-Q046=\":443\"; ma=2592000,h3-Q043=\":443\"; ma=2592000",
"Content-Length" : "0",
"Expires" : "Tue, 27 Apr 1971 19:44:06 GMT"
},
"method" : "HEAD",
"status" : 404,
"uri" : "http:\/\/www.youtube.com\/video1.mp4?ratebypass=yes"
}
]
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[]
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[]
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[]
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[]
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[]
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[]
187 changes: 186 additions & 1 deletion XCDYouTubeKit Tests/XCDYouTubeClientTestCase.m
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#import "XCDYouTubeKitTestCase.h"

#import <XCDYouTubeKit/XCDYouTubeClient.h>
#import <XCDYouTubeKit/XCDYouTubeVideoOperation.h>

@interface XCDYouTubeClientTestCase : XCDYouTubeKitTestCase
@end
Expand Down Expand Up @@ -39,6 +40,41 @@ - (void) testThatVideoHasMetadata
[self waitForExpectationsWithTimeout:5 handler:nil];
}

- (void) testThatVideoHasOtherStreams
{
__weak XCTestExpectation *expectation = [self expectationWithDescription:@""];

[[XCDYouTubeClient defaultClient] getVideoWithIdentifier:@"sBHFOh5qe20" completionHandler:^(XCDYouTubeVideo *mainVideo, NSError *error)
{
XCTAssertNil(error);
XCTAssertNotNil(mainVideo.videoIdentifiers);

NSMutableArray *operations = [NSMutableArray new];
NSOperationQueue *queue = [NSOperationQueue new];
queue.maxConcurrentOperationCount = 6;

for (NSString *videoIdentifier in mainVideo.videoIdentifiers)
{
[operations addObject:[[XCDYouTubeVideoOperation alloc]initWithVideoIdentifier:videoIdentifier languageIdentifier:nil]];
}

XCTAssertTrue(operations.count != 0);
[queue addOperations:operations waitUntilFinished:YES];

for (XCDYouTubeVideoOperation *operation in operations)
{
XCTAssertNil(operation.error);
XCTAssertNotNil(operation.video);
XCTAssertTrue(operation.video.streamURLs.count > 0);
XCTAssertTrue(operation.video.duration > 0);
XCTAssertNotEqualObjects(operation.video, mainVideo, @"None of the `videoIdentifiers` returned from the `mainVideo` should be the same `videoIdentifier` was the `mainVideo`");
}

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

- (void) testVideoThatHasCaptions
{
__weak XCTestExpectation *expectation = [self expectationWithDescription:@""];
Expand Down Expand Up @@ -178,6 +214,135 @@ - (void) testVideo1IsPlayable
[self waitForExpectationsWithTimeout:5 handler:nil];
}

- (void) testVideo1ReturnsSomePlayableStreams
{
__weak XCTestExpectation *expectation = [self expectationWithDescription:@""];

//These are the playble itag stream for `cdqP6wI8TCc` as of Feb 12, 2020 in the US
NSArray<NSNumber *>*playableStreamKeys = @[@140, @136, @251, @134];

[[XCDYouTubeClient defaultClient] getVideoWithIdentifier:@"cdqP6wI8TCc" completionHandler:^(XCDYouTubeVideo *video, NSError *error)
{

XCTAssertNotNil(video);
XCTAssertNil(error);

[[XCDYouTubeClient defaultClient]queryVideo:video cookies:nil completionHandler:^(NSDictionary * _Nonnull streamURLs, NSError * _Nullable queryError, NSDictionary<id, NSError *> *streamErrors) {

XCTAssertNil(queryError);
XCTAssertNotNil(streamURLs);

for (NSNumber *itag in playableStreamKeys)
{
XCTAssertTrue([streamURLs.allKeys containsObject:itag]);
}

for (id key in streamURLs.allKeys)
{
XCTAssertNotNil(streamURLs[key]);
}

XCTAssertEqual(playableStreamKeys.count, streamURLs.count, @"`streamURLs` count should be equal to `playableStreamKeys` count");
XCTAssertNotEqual(video.streamURLs.count, streamURLs.count, @"`streamURLs` count should not be equal since this video contains some streams are unplayable");

[expectation fulfill];
}];
}];

[self waitForExpectationsWithTimeout:5 handler:nil];
}

// Disable internet connection before running to allow some queries to fail
- (void) testVideo1ReturnsSomePlayableStreamsEvenIfSomeFailDueToConnectionError_offline
{
__weak XCTestExpectation *expectation = [self expectationWithDescription:@""];
[[XCDYouTubeClient defaultClient] getVideoWithIdentifier:@"cdqP6wI8TCc" completionHandler:^(XCDYouTubeVideo *video, NSError *error)
{
XCTAssertNotNil(video);
XCTAssertNil(error);

[[XCDYouTubeClient defaultClient]queryVideo:video cookies:nil completionHandler:^(NSDictionary * _Nonnull streamURLs, NSError * _Nullable queryError, NSDictionary<id, NSError *> *streamErrors) {

XCTAssertNil(queryError);
XCTAssertNotNil(streamURLs);

for (id key in streamURLs.allKeys)
{
XCTAssertNotNil(streamURLs[key]);
}

XCTAssertTrue(streamErrors.count != 0);
for (NSError *streamError in streamErrors.allValues)
{
XCTAssertEqualObjects(streamError.localizedDescription, @"The Internet connection appears to be offline.");
}

XCTAssertNotEqual(video.streamURLs.count, streamURLs.count, @"`streamURLs` count should not be equal since this video contains some streams are unplayable");

[expectation fulfill];
}];
}];

[self waitForExpectationsWithTimeout:5 handler:nil];
}

// Disable internet connection before running to allow all queries to fail
- (void) testVideo1ReturnsNoPlayableStreamsBecauseConnectionError_offline
{
__weak XCTestExpectation *expectation = [self expectationWithDescription:@""];
[[XCDYouTubeClient defaultClient] getVideoWithIdentifier:@"cdqP6wI8TCc" completionHandler:^(XCDYouTubeVideo *video, NSError *error)
{
XCTAssertNotNil(video);
XCTAssertNil(error);

[[XCDYouTubeClient defaultClient]queryVideo:video cookies:nil completionHandler:^(NSDictionary * _Nonnull streamURLs, NSError * _Nullable queryError, NSDictionary<id, NSError *> *streamErrors) {

XCTAssertNotNil(queryError);
XCTAssertNil(streamURLs);
XCTAssertTrue(streamErrors.count != 0);

for (NSError *streamError in streamErrors.allValues)
{
XCTAssertEqualObjects(streamError.localizedDescription, @"The Internet connection appears to be offline.");
}

XCTAssertNotEqual(video.streamURLs.count, streamURLs.count, @"`streamURLs` count should not be equal since this video contains some streams are unplayable");

[expectation fulfill];
}];
}];

[self waitForExpectationsWithTimeout:5 handler:nil];
}

- (void) testVideo2ReturnsAllPlayableStreams
{
__weak XCTestExpectation *expectation = [self expectationWithDescription:@""];
[[XCDYouTubeClient defaultClient] getVideoWithIdentifier:@"QcIy9NiNbmo" completionHandler:^(XCDYouTubeVideo *video, NSError *error)
{
XCTAssertNotNil(video);
XCTAssertNil(error);

[[XCDYouTubeClient defaultClient]queryVideo:video cookies:nil completionHandler:^(NSDictionary * _Nonnull streamURLs, NSError * _Nullable queryError, NSDictionary<id, NSError *> *streamErrors) {

XCTAssertNil(queryError);
XCTAssertNil(streamErrors);
XCTAssertNotNil(streamURLs);

for (id key in streamURLs.allKeys)
{
XCTAssertNotNil(streamURLs[key]);
}

XCTAssertEqual(video.streamURLs.count, streamURLs.count, @"`streamURLs` count should be equal since all the streams are playable.");

[expectation fulfill];
}];
}];

[self waitForExpectationsWithTimeout:90 handler:nil];
}

- (void) testExpiredLiveVideo
{
__weak XCTestExpectation *expectation = [self expectationWithDescription:@""];
Expand Down Expand Up @@ -218,7 +383,7 @@ - (void) testRemovedVideo
XCTAssertNil(video);
XCTAssertEqualObjects(error.domain, XCDYouTubeVideoErrorDomain);
XCTAssertEqual(error.code, XCDYouTubeErrorNoStreamAvailable);
XCTAssertEqualObjects(error.localizedDescription, @"This video has been removed for violating YouTube's Terms of Service.");
XCTAssertEqualObjects(error.localizedDescription, @"This video is no longer available due to a copyright claim by Digital Rights Group Ltd.");
[expectation fulfill];
}];
[self waitForExpectationsWithTimeout:5 handler:nil];
Expand Down Expand Up @@ -352,6 +517,26 @@ - (void) testCancelingOperation
[self waitForExpectationsWithTimeout:1 handler:nil];
}

- (void) testCancelingOperationQueryOperation
{
__weak XCTestExpectation *expectation = [self expectationWithDescription:@""];
__block XCDYouTubeVideoQueryOperation *operation = nil;
[[XCDYouTubeClient defaultClient] getVideoWithIdentifier:@"6kLq3WMV1nU" completionHandler:^(XCDYouTubeVideo *video, NSError *error)
{
XCTAssertNotNil(video);

operation = [[XCDYouTubeClient defaultClient] queryVideo:video cookies:nil completionHandler:^(NSDictionary * _Nonnull streamURLs, NSError * _Nullable queryError, NSDictionary<id,NSError *> * _Nonnull streamErrors)
{
XCTFail();
}];

[operation cancel];
[expectation fulfill];
}];

[self waitForExpectationsWithTimeout:5 handler:nil];
}

- (void) testNilCompletionHandler
{
#pragma clang diagnostic push
Expand Down
6 changes: 3 additions & 3 deletions XCDYouTubeKit Tests/XCDYouTubeProtectedVideosTestCase.m
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ - (void) testProtectedVEVOVideoWithNilCustomPatternIsPlayable
}];
[dataTask resume];
}];
[self waitForExpectationsWithTimeout:100 handler:nil];
[self waitForExpectationsWithTimeout:5 handler:nil];
}

- (void) testProtectedVEVOVideoWithEmptyCustomPatternIsPlayable
Expand All @@ -208,7 +208,7 @@ - (void) testProtectedVEVOVideoWithEmptyCustomPatternIsPlayable
}];
[dataTask resume];
}];
[self waitForExpectationsWithTimeout:100 handler:nil];
[self waitForExpectationsWithTimeout:5 handler:nil];
}

- (void) testProtectedVEVOVideoWithInvalidCustomPatternIsPlayable
Expand Down Expand Up @@ -260,7 +260,7 @@ - (void) testProtectedVEVOVideoWithValidCustomPatternIsPlayable
}];
[dataTask resume];
}];
[self waitForExpectationsWithTimeout:100 handler:nil];
[self waitForExpectationsWithTimeout:5 handler:nil];
}

- (void) testProtectedVEVOVideo1
Expand Down
Loading

0 comments on commit 1bd1061

Please sign in to comment.