Skip to content

Commit

Permalink
Merge branch 'release/2.8.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
SoneeJohn committed Aug 7, 2019
2 parents 679ba67 + aed37cb commit 8367211
Show file tree
Hide file tree
Showing 23 changed files with 342 additions and 310 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.7.8
module_version: 2.8.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.7.8/XCDYouTubeKit
github_file_prefix: https://github.com/0xced/XCDYouTubeKit/tree/2.8.0/XCDYouTubeKit
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
#### Version 2.8.0

* Adaptation to YouTube API change.
* Deprecated `XCDYouTubeErrorRestrictedPlayback` & `XCDYouTubeErrorInvalidVideoIdentifier` use `XCDYouTubeErrorNoStreamAvailable` instead.

#### Version 2.7.8

* Adaptation to YouTube API change. (#443)
Expand Down
4 changes: 2 additions & 2 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.7"
pod "XCDYouTubeKit", "~> 2.8"
```

Carthage:

```objc
github "0xced/XCDYouTubeKit" ~> 2.7
github "0xced/XCDYouTubeKit" ~> 2.8
```

Accio:
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.7.8;
CURRENT_PROJECT_VERSION = 2.8.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.7.8;
CURRENT_PROJECT_VERSION = 2.8.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.

20 changes: 10 additions & 10 deletions XCDYouTubeKit Tests/XCDYouTubeClientTestCase.m
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ - (void) testExpiredLiveVideo
[[XCDYouTubeClient defaultClient] getVideoWithIdentifier:@"i2-MnWWoL6M" completionHandler:^(XCDYouTubeVideo *video, NSError *error) {
XCTAssertNil(video);
XCTAssertEqualObjects(error.domain, XCDYouTubeVideoErrorDomain);
XCTAssertEqual(error.code, XCDYouTubeErrorRestrictedPlayback);
XCTAssertEqual(error.code, XCDYouTubeErrorNoStreamAvailable);
XCTAssertEqualObjects(error.localizedDescription, @"This live stream recording is not available.");
[expectation fulfill];
}];
Expand All @@ -196,7 +196,7 @@ - (void) testRestrictedVideo
{
XCTAssertNil(video);
XCTAssertEqualObjects(error.domain, XCDYouTubeVideoErrorDomain);
XCTAssertEqual(error.code, XCDYouTubeErrorRestrictedPlayback);
XCTAssertEqual(error.code, XCDYouTubeErrorNoStreamAvailable);
XCTAssertEqualObjects(error.localizedDescription, @"This video is no longer available because the YouTube account associated with this video has been terminated.");
[expectation fulfill];
}];
Expand All @@ -213,8 +213,8 @@ - (void) testRemovedVideo
{
XCTAssertNil(video);
XCTAssertEqualObjects(error.domain, XCDYouTubeVideoErrorDomain);
XCTAssertEqual(error.code, XCDYouTubeErrorRestrictedPlayback);
XCTAssertEqualObjects(error.localizedDescription, @"\"9/11 The F...\" is no longer available due to a copyright claim by Digital Rights Group Ltd.");
XCTAssertEqual(error.code, XCDYouTubeErrorNoStreamAvailable);
XCTAssertEqualObjects(error.localizedDescription, @"This video has been removed for violating YouTube's Terms of Service.");
[expectation fulfill];
}];
[self waitForExpectationsWithTimeout:5 handler:nil];
Expand All @@ -227,7 +227,7 @@ - (void) testGeoblockedVideo
{
XCTAssertNil(video);
XCTAssertEqualObjects(error.domain, XCDYouTubeVideoErrorDomain);
XCTAssertEqual(error.code, XCDYouTubeErrorRestrictedPlayback);
XCTAssertEqual(error.code, XCDYouTubeErrorNoStreamAvailable);
XCTAssertEqualObjects(error.localizedDescription, @"The uploader has not made this video available in your country.");
[expectation fulfill];
}];
Expand All @@ -241,7 +241,7 @@ - (void) testInvalidVideoIdentifier
{
XCTAssertNil(video);
XCTAssertEqualObjects(error.domain, XCDYouTubeVideoErrorDomain);
XCTAssertEqual(error.code, XCDYouTubeErrorInvalidVideoIdentifier);
XCTAssertEqual(error.code, XCDYouTubeErrorNoStreamAvailable);
XCTAssertEqualObjects(error.localizedDescription, @"Invalid parameters.");
[expectation fulfill];
}];
Expand All @@ -255,7 +255,7 @@ - (void) testNonExistentVideoIdentifier
{
XCTAssertNil(video);
XCTAssertEqualObjects(error.domain, XCDYouTubeVideoErrorDomain);
XCTAssertEqual(error.code, XCDYouTubeErrorRestrictedPlayback);
XCTAssertEqual(error.code, XCDYouTubeErrorNoStreamAvailable);
XCTAssertEqualObjects(error.localizedDescription, @"This video is unavailable.");
[expectation fulfill];
}];
Expand All @@ -269,7 +269,7 @@ - (void) testFrenchClient
{
XCTAssertNil(video);
XCTAssertEqualObjects(error.domain, XCDYouTubeVideoErrorDomain);
XCTAssertEqual(error.code, XCDYouTubeErrorRestrictedPlayback);
XCTAssertEqual(error.code, XCDYouTubeErrorNoStreamAvailable);
XCTAssertEqualObjects(error.localizedDescription, @"Cette vidéo n'est pas disponible.");
[expectation fulfill];
}];
Expand All @@ -283,7 +283,7 @@ - (void) testNilVideoIdentifier
{
XCTAssertNil(video);
XCTAssertEqualObjects(error.domain, XCDYouTubeVideoErrorDomain);
XCTAssertEqual(error.code, XCDYouTubeErrorInvalidVideoIdentifier);
XCTAssertEqual(error.code, XCDYouTubeErrorNoStreamAvailable);
XCTAssertEqualObjects(error.localizedDescription, @"Invalid parameters.");
[expectation fulfill];
}];
Expand All @@ -297,7 +297,7 @@ - (void) testSpaceVideoIdentifier
{
XCTAssertNil(video);
XCTAssertEqualObjects(error.domain, XCDYouTubeVideoErrorDomain);
XCTAssertEqual(error.code, XCDYouTubeErrorInvalidVideoIdentifier);
XCTAssertEqual(error.code, XCDYouTubeErrorNoStreamAvailable);
XCTAssertEqualObjects(error.localizedDescription, @"Invalid parameters.");
[expectation fulfill];
}];
Expand Down
16 changes: 8 additions & 8 deletions XCDYouTubeKit Tests/XCDYouTubeProtectedVideosTestCase.m
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ - (void) testProtectedVideoWithWebPageConnectionError_offline
{
XCTAssertNil(video);
XCTAssertEqualObjects(error.domain, XCDYouTubeVideoErrorDomain);
XCTAssertEqual(error.code, XCDYouTubeErrorRestrictedPlayback);
XCTAssertEqual(error.code, XCDYouTubeErrorNoStreamAvailable);
XCTAssertEqualObjects(error.localizedDescription, @"This video is unavailable.");
[expectation fulfill];
}];
Expand All @@ -316,7 +316,7 @@ - (void) testProtectedVideoWithPlayerScriptConnectionError_offline
{
XCTAssertNil(video);
XCTAssertEqualObjects(error.domain, XCDYouTubeVideoErrorDomain);
XCTAssertEqual(error.code, XCDYouTubeErrorRestrictedPlayback);
XCTAssertEqual(error.code, XCDYouTubeErrorNoStreamAvailable);
XCTAssertEqualObjects(error.localizedDescription, @"This video is unavailable.");
[expectation fulfill];
}];
Expand All @@ -332,7 +332,7 @@ - (void) testProtectedVideoWithoutSignatureFunction_offline
{
XCTAssertNil(video);
XCTAssertEqualObjects(error.domain, XCDYouTubeVideoErrorDomain);
XCTAssertEqual(error.code, XCDYouTubeErrorRestrictedPlayback);
XCTAssertEqual(error.code, XCDYouTubeErrorNoStreamAvailable);
XCTAssertEqualObjects(error.localizedDescription, @"This video is unavailable.");
[expectation fulfill];
}];
Expand All @@ -349,7 +349,7 @@ - (void) testProtectedVideoWithBrokenSignatureFunction_offline
{
XCTAssertNil(video);
XCTAssertEqualObjects(error.domain, XCDYouTubeVideoErrorDomain);
XCTAssertEqual(error.code, XCDYouTubeErrorRestrictedPlayback);
XCTAssertEqual(error.code, XCDYouTubeErrorNoStreamAvailable);
XCTAssertEqualObjects(error.localizedDescription, @"This video is unavailable.");
[expectation fulfill];
}];
Expand All @@ -364,7 +364,7 @@ - (void) testProtectedVideoWithoutJavaScriptPlayerURL_offline
{
XCTAssertNil(video);
XCTAssertEqualObjects(error.domain, XCDYouTubeVideoErrorDomain);
XCTAssertEqual(error.code, XCDYouTubeErrorRestrictedPlayback);
XCTAssertEqual(error.code, XCDYouTubeErrorNoStreamAvailable);
XCTAssertEqualObjects(error.localizedDescription, @"This video is unavailable.");
[expectation fulfill];
}];
Expand All @@ -380,7 +380,7 @@ - (void) testProtectedVideoWithNonAnonymousJavaScriptPlayerFunction_offline
{
XCTAssertNil(video);
XCTAssertEqualObjects(error.domain, XCDYouTubeVideoErrorDomain);
XCTAssertEqual(error.code, XCDYouTubeErrorRestrictedPlayback);
XCTAssertEqual(error.code, XCDYouTubeErrorNoStreamAvailable);
XCTAssertEqualObjects(error.localizedDescription, @"This video is unavailable.");
[expectation fulfill];
}];
Expand All @@ -395,7 +395,7 @@ - (void) testAgeRestrictedVEVOVideoWithEmbedWebPageConnectionError_offline
{
XCTAssertNil(video);
XCTAssertEqualObjects(error.domain, XCDYouTubeVideoErrorDomain);
XCTAssertEqual(error.code, XCDYouTubeErrorRestrictedPlayback);
XCTAssertEqual(error.code, XCDYouTubeErrorNoStreamAvailable);
XCTAssertEqualObjects(error.localizedDescription, @"Sign in to confirm your age");
[expectation fulfill];
}];
Expand Down Expand Up @@ -432,7 +432,7 @@ - (void) testAgeRestrictedVideo1WithNoJavaScriptPlayerURL_offline
{
XCTAssertNil(video);
XCTAssertEqualObjects(error.domain, XCDYouTubeVideoErrorDomain);
XCTAssertEqual(error.code, XCDYouTubeErrorRestrictedPlayback);
XCTAssertEqual(error.code, XCDYouTubeErrorNoStreamAvailable);
XCTAssertEqualObjects(error.localizedDescription, @"Sign in to confirm your age");
[expectation fulfill];
}];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ - (void) testRestrictedPlaybackErrorNotification
MPMovieFinishReason finishReason = [notification.userInfo[MPMoviePlayerPlaybackDidFinishReasonUserInfoKey] integerValue];
XCTAssertEqual(finishReason, MPMovieFinishReasonPlaybackError);
XCTAssertEqualObjects(error.domain, XCDYouTubeVideoErrorDomain);
XCTAssertEqual(error.code, XCDYouTubeErrorRestrictedPlayback);
XCTAssertEqual(error.code, XCDYouTubeErrorNoStreamAvailable);
[expectation fulfill];
}];
[self waitForExpectationsWithTimeout:5 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.7.8"
s.version = "2.8.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
8 changes: 4 additions & 4 deletions XCDYouTubeKit.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -613,10 +613,10 @@
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
COMBINE_HIDPI_IMAGES = YES;
COPY_PHASE_STRIP = NO;
CURRENT_PROJECT_VERSION = 38;
CURRENT_PROJECT_VERSION = 39;
DEFINES_MODULE = YES;
DYLIB_COMPATIBILITY_VERSION = 2.0.0;
DYLIB_CURRENT_VERSION = 2.7.8;
DYLIB_CURRENT_VERSION = 2.8.0;
DYLIB_INSTALL_NAME_BASE = "@rpath";
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_TESTABILITY = YES;
Expand Down Expand Up @@ -691,10 +691,10 @@
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
COMBINE_HIDPI_IMAGES = YES;
COPY_PHASE_STRIP = YES;
CURRENT_PROJECT_VERSION = 38;
CURRENT_PROJECT_VERSION = 39;
DEFINES_MODULE = YES;
DYLIB_COMPATIBILITY_VERSION = 2.0.0;
DYLIB_CURRENT_VERSION = 2.7.8;
DYLIB_CURRENT_VERSION = 2.8.0;
DYLIB_INSTALL_NAME_BASE = "@rpath";
ENABLE_NS_ASSERTIONS = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
Expand Down
18 changes: 11 additions & 7 deletions XCDYouTubeKit/XCDYouTubeError.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
extern NSString *const XCDYouTubeVideoErrorDomain;

/**
* A key that may be present in the error's userInfo dictionary when the error code is XCDYouTubeErrorRestrictedPlayback.
* A key that may be present in the error's userInfo dictionary when the error code is XCDYouTubeErrorNoStreamAvailable.
* The object for that key is a NSSet instance containing localized country names.
*/
extern NSString *const XCDYouTubeAllowedCountriesUserInfoKey;
Expand All @@ -20,7 +20,10 @@ extern NSString *const XCDYouTubeAllowedCountriesUserInfoKey;
*/
typedef NS_ENUM(NSInteger, XCDYouTubeErrorCode) {
/**
* Returned when no suitable video stream is available.
* Returned when no suitable video stream is available. This can occur due to various reason such as:
* * The video is not playable because of legal reasons or when the video is private.
* * The given video identifier string is invalid.
* * The video was removed as a violation of YouTube's policy or when the video did not exist.
*/
XCDYouTubeErrorNoStreamAvailable = -2,

Expand All @@ -30,18 +33,19 @@ typedef NS_ENUM(NSInteger, XCDYouTubeErrorCode) {
XCDYouTubeErrorNetwork = -1,

/**
* Returned when the given video identifier string is invalid.
* Previously returned when the given video identifier string is invalid.
* Use `XCDYouTubeErrorNoStreamAvailable` instead.
*/
XCDYouTubeErrorInvalidVideoIdentifier = 2,
XCDYouTubeErrorInvalidVideoIdentifier DEPRECATED_MSG_ATTRIBUTE("YouTube has stopped using error code 2.") = 2,

/**
* Previously returned when the video was removed as a violation of YouTube's policy or when the video did not exist.
* Now replaced by code 150, i.e. `XCDYouTubeErrorRestrictedPlayback`.
*/
XCDYouTubeErrorRemovedVideo DEPRECATED_MSG_ATTRIBUTE("YouTube has stopped using error code 100.") = 100,

/**
* Returned when the video is not playable because of legal reasons or when the video is private.
* Previously returned when the video is not playable because of legal reasons or when the video is private.
* Use `XCDYouTubeErrorNoStreamAvailable` instead.
*/
XCDYouTubeErrorRestrictedPlayback = 150
XCDYouTubeErrorRestrictedPlayback DEPRECATED_MSG_ATTRIBUTE("YouTube has stopped using error code 150.") = 150
};
6 changes: 2 additions & 4 deletions XCDYouTubeKit/XCDYouTubeVideo.m
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ - (instancetype) initWithIdentifier:(NSString *)identifier info:(NSDictionary *)
{
if (error)
{
NSString *reason = info[@"reason"];
NSString *reason = info[@"reason"] == nil ? XCDDictionaryWithString(playerResponse)[@"playabilityStatus"][@"reason"] : info[@"reason"];
if (reason)
{
reason = [reason stringByReplacingOccurrencesOfString:@"<br\\s*/?>" withString:@" " options:NSRegularExpressionSearch range:NSMakeRange(0, reason.length)];
Expand All @@ -312,9 +312,7 @@ - (instancetype) initWithIdentifier:(NSString *)identifier info:(NSDictionary *)
userInfo[NSLocalizedDescriptionKey] = reason;
}

NSString *errorcode = info[@"errorcode"];
NSInteger code = errorcode ? errorcode.integerValue : XCDYouTubeErrorNoStreamAvailable;
*error = [NSError errorWithDomain:XCDYouTubeVideoErrorDomain code:code userInfo:userInfo];
*error = [NSError errorWithDomain:XCDYouTubeVideoErrorDomain code:XCDYouTubeErrorNoStreamAvailable userInfo:userInfo];
}
return nil;
}
Expand Down
4 changes: 2 additions & 2 deletions XCDYouTubeKit/XCDYouTubeVideoOperation.m
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ @implementation XCDYouTubeVideoOperation

static NSError *YouTubeError(NSError *error, NSSet *regionsAllowed, NSString *languageIdentifier)
{
if (error.code == XCDYouTubeErrorRestrictedPlayback && regionsAllowed.count > 0)
if (error.code == XCDYouTubeErrorNoStreamAvailable && regionsAllowed.count > 0)
{
NSLocale *locale = [NSLocale localeWithLocaleIdentifier:languageIdentifier];
NSMutableSet *allowedCountries = [NSMutableSet new];
Expand Down Expand Up @@ -247,7 +247,7 @@ - (void) handleVideoInfoResponseWithInfo:(NSDictionary *)info response:(NSURLRes
else
{
self.lastError = error;
if (error.code > 0)
if (error.userInfo[NSLocalizedDescriptionKey])
self.youTubeError = error;

[self startNextRequest];
Expand Down

0 comments on commit 8367211

Please sign in to comment.