diff --git a/CHANGELOG.md b/CHANGELOG.md index b632a6b5..7d9a1c47 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +#### Version 2.5.1 + +* Adaptation to YouTube API change. (#231) +* Fixed compilation issue with Xcode 7.3 beta. (#228) +* Properly annotated the `preferredVideoQualities` property as `null_resettable`. + #### Version 2.5.0 * Logging is fully configurable with the new `XCDYouTubeLogger` class. diff --git a/XCDYouTubeKit Demo/XCDYouTubeKit Demo.xcodeproj/project.pbxproj b/XCDYouTubeKit Demo/XCDYouTubeKit Demo.xcodeproj/project.pbxproj index c273c242..ba0b807c 100644 --- a/XCDYouTubeKit Demo/XCDYouTubeKit Demo.xcodeproj/project.pbxproj +++ b/XCDYouTubeKit Demo/XCDYouTubeKit Demo.xcodeproj/project.pbxproj @@ -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.0; + CURRENT_PROJECT_VERSION = 2.5.1; ENABLE_STRICT_OBJC_MSGSEND = YES; ENABLE_TESTABILITY = YES; GCC_C_LANGUAGE_STANDARD = gnu99; @@ -805,7 +805,7 @@ CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; COPY_PHASE_STRIP = YES; - CURRENT_PROJECT_VERSION = 2.5.0; + CURRENT_PROJECT_VERSION = 2.5.1; ENABLE_STRICT_OBJC_MSGSEND = YES; GCC_C_LANGUAGE_STANDARD = gnu99; GCC_NO_COMMON_BLOCKS = YES; diff --git a/XCDYouTubeKit Demo/XCDYouTubeKit Demo.xcodeproj/xcshareddata/xcschemes/XCDYouTubeKit OS X Demo.xcscheme b/XCDYouTubeKit Demo/XCDYouTubeKit Demo.xcodeproj/xcshareddata/xcschemes/XCDYouTubeKit OS X Demo.xcscheme index abb11286..f5742813 100644 --- a/XCDYouTubeKit Demo/XCDYouTubeKit Demo.xcodeproj/xcshareddata/xcschemes/XCDYouTubeKit OS X Demo.xcscheme +++ b/XCDYouTubeKit Demo/XCDYouTubeKit Demo.xcodeproj/xcshareddata/xcschemes/XCDYouTubeKit OS X Demo.xcscheme @@ -11,7 +11,8 @@ buildForRunning = "YES" buildForProfiling = "YES" buildForArchiving = "YES" - buildForAnalyzing = "YES"> + buildForAnalyzing = "YES" + hideIssues = "NO"> - - - - + buildForAnalyzing = "YES" + hideIssues = "NO"> - - - - + buildForAnalyzing = "YES" + hideIssues = "NO"> diff --git a/XCDYouTubeKit.podspec b/XCDYouTubeKit.podspec index 023ba945..a54038df 100644 --- a/XCDYouTubeKit.podspec +++ b/XCDYouTubeKit.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = "XCDYouTubeKit" - s.version = "2.5.0" + s.version = "2.5.1" 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" diff --git a/XCDYouTubeKit.xcodeproj/project.pbxproj b/XCDYouTubeKit.xcodeproj/project.pbxproj index 419e847f..1bc859f7 100644 --- a/XCDYouTubeKit.xcodeproj/project.pbxproj +++ b/XCDYouTubeKit.xcodeproj/project.pbxproj @@ -1157,10 +1157,10 @@ CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 22; + CURRENT_PROJECT_VERSION = 23; DEFINES_MODULE = YES; DYLIB_COMPATIBILITY_VERSION = 2.0.0; - DYLIB_CURRENT_VERSION = 2.5.0; + DYLIB_CURRENT_VERSION = 2.5.1; DYLIB_INSTALL_NAME_BASE = "@rpath"; ENABLE_STRICT_OBJC_MSGSEND = YES; ENABLE_TESTABILITY = YES; @@ -1223,10 +1223,10 @@ CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; COPY_PHASE_STRIP = YES; - CURRENT_PROJECT_VERSION = 22; + CURRENT_PROJECT_VERSION = 23; DEFINES_MODULE = YES; DYLIB_COMPATIBILITY_VERSION = 2.0.0; - DYLIB_CURRENT_VERSION = 2.5.0; + DYLIB_CURRENT_VERSION = 2.5.1; DYLIB_INSTALL_NAME_BASE = "@rpath"; ENABLE_NS_ASSERTIONS = NO; ENABLE_STRICT_OBJC_MSGSEND = YES; @@ -1296,10 +1296,10 @@ CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 22; + CURRENT_PROJECT_VERSION = 23; DEFINES_MODULE = YES; DYLIB_COMPATIBILITY_VERSION = 2.0.0; - DYLIB_CURRENT_VERSION = 2.5.0; + DYLIB_CURRENT_VERSION = 2.5.1; DYLIB_INSTALL_NAME_BASE = "@rpath"; ENABLE_STRICT_OBJC_MSGSEND = YES; ENABLE_TESTABILITY = YES; diff --git a/XCDYouTubeKit.xcodeproj/xcshareddata/xcschemes/XCDYouTubeKit OS X Tests.xcscheme b/XCDYouTubeKit.xcodeproj/xcshareddata/xcschemes/XCDYouTubeKit OS X Tests.xcscheme index ad542cca..eda4d869 100644 --- a/XCDYouTubeKit.xcodeproj/xcshareddata/xcschemes/XCDYouTubeKit OS X Tests.xcscheme +++ b/XCDYouTubeKit.xcodeproj/xcshareddata/xcschemes/XCDYouTubeKit OS X Tests.xcscheme @@ -5,6 +5,23 @@ + + + + + + + buildForAnalyzing = "YES" + hideIssues = "NO"> @@ -96,6 +97,15 @@ savedToolIdentifier = "" useCustomWorkingDirectory = "NO" debugDocumentVersioning = "YES"> + + + + diff --git a/XCDYouTubeKit.xcodeproj/xcshareddata/xcschemes/XCDYouTubeKit iOS Framework.xcscheme b/XCDYouTubeKit.xcodeproj/xcshareddata/xcschemes/XCDYouTubeKit iOS Framework.xcscheme index 3785a54e..a46b0697 100644 --- a/XCDYouTubeKit.xcodeproj/xcshareddata/xcschemes/XCDYouTubeKit iOS Framework.xcscheme +++ b/XCDYouTubeKit.xcodeproj/xcshareddata/xcschemes/XCDYouTubeKit iOS Framework.xcscheme @@ -11,7 +11,8 @@ buildForRunning = "YES" buildForProfiling = "YES" buildForArchiving = "YES" - buildForAnalyzing = "YES"> + buildForAnalyzing = "YES" + hideIssues = "NO"> + buildForAnalyzing = "YES" + hideIssues = "NO"> + + + + diff --git a/XCDYouTubeKit.xcodeproj/xcshareddata/xcschemes/XCDYouTubeKit iOS Tests.xcscheme b/XCDYouTubeKit.xcodeproj/xcshareddata/xcschemes/XCDYouTubeKit iOS Tests.xcscheme index 9a91100d..d5c975b4 100644 --- a/XCDYouTubeKit.xcodeproj/xcshareddata/xcschemes/XCDYouTubeKit iOS Tests.xcscheme +++ b/XCDYouTubeKit.xcodeproj/xcshareddata/xcschemes/XCDYouTubeKit iOS Tests.xcscheme @@ -5,6 +5,23 @@ + + + + + + + + + + + + + buildForAnalyzing = "YES" + hideIssues = "NO"> + buildForAnalyzing = "NO" + hideIssues = "NO"> 0) - _languageIdentifier = [NSLocale canonicalLanguageIdentifierFromString:preferredLocalizations[0]]; - } - return _languageIdentifier; -} - - (id) getVideoWithIdentifier:(NSString *)videoIdentifier completionHandler:(void (^)(XCDYouTubeVideo * __nullable video, NSError * __nullable error))completionHandler { if (!completionHandler) diff --git a/XCDYouTubeKit/XCDYouTubeLogger.m b/XCDYouTubeKit/XCDYouTubeLogger.m index f4d2dcec..cc838607 100644 --- a/XCDYouTubeKit/XCDYouTubeLogger.m +++ b/XCDYouTubeKit/XCDYouTubeLogger.m @@ -13,14 +13,6 @@ @protocol XCDYouTubeLogger_DDLog + (void) log:(BOOL)asynchronous message:(NSString *)message level:(NSUInteger)level flag:(NSUInteger)flag context:(NSInteger)context file:(const char *)file function:(const char *)function line:(NSUInteger)line tag:(id)tag; @end -static void (^const DefaultLogHandler)(NSString * (^)(void), XCDLogLevel, const char *, const char *, NSUInteger) = ^(NSString *(^message)(void), XCDLogLevel level, const char *file, const char *function, NSUInteger line) -{ - char *logLevelString = getenv("XCDYouTubeKitLogLevel"); - NSUInteger logLevelMask = logLevelString ? strtoul(logLevelString, NULL, 0) : (1 << XCDLogLevelError) | (1 << XCDLogLevelWarning); - if ((1 << level) & logLevelMask) - NSLog(@"[XCDYouTubeKit] %@", message()); -}; - static Class DDLogClass = Nil; static void (^const CocoaLumberjackLogHandler)(NSString * (^)(void), XCDLogLevel, const char *, const char *, NSUInteger) = ^(NSString *(^message)(void), XCDLogLevel level, const char *file, const char *function, NSUInteger line) @@ -29,7 +21,13 @@ static void (^const CocoaLumberjackLogHandler)(NSString * (^)(void), XCDLogLevel [DDLogClass log:YES message:message() level:NSUIntegerMax flag:(1 << level) context:XCDYouTubeKitLumberjackContext file:file function:function line:line tag:nil]; }; -static void (^LogHandler)(NSString * (^)(void), XCDLogLevel, const char *, const char *, NSUInteger); +static void (^LogHandler)(NSString * (^)(void), XCDLogLevel, const char *, const char *, NSUInteger) = ^(NSString *(^message)(void), XCDLogLevel level, const char *file, const char *function, NSUInteger line) +{ + char *logLevelString = getenv("XCDYouTubeKitLogLevel"); + NSUInteger logLevelMask = logLevelString ? strtoul(logLevelString, NULL, 0) : (1 << XCDLogLevelError) | (1 << XCDLogLevelWarning); + if ((1 << level) & logLevelMask) + NSLog(@"[XCDYouTubeKit] %@", message()); +}; @implementation XCDYouTubeLogger @@ -37,8 +35,6 @@ + (void) initialize { static dispatch_once_t once; dispatch_once(&once, ^{ - LogHandler = DefaultLogHandler; - DDLogClass = objc_lookUpClass("DDLog"); if (DDLogClass) { diff --git a/XCDYouTubeKit/XCDYouTubePlayerScript.m b/XCDYouTubeKit/XCDYouTubePlayerScript.m index fcd57b2f..c331b822 100644 --- a/XCDYouTubeKit/XCDYouTubePlayerScript.m +++ b/XCDYouTubeKit/XCDYouTubePlayerScript.m @@ -40,7 +40,9 @@ - (instancetype) initWithString:(NSString *)string @"location": @{ @"hash": @"" }, - @"navigator": @{}, + @"navigator": @{ + @"userAgent": @"" + }, }; _context[@"window"] = @{}; for (NSString *propertyName in environment) diff --git a/XCDYouTubeKit/XCDYouTubeVideoOperation.m b/XCDYouTubeKit/XCDYouTubeVideoOperation.m index cd4a112d..ec971ddf 100644 --- a/XCDYouTubeKit/XCDYouTubeVideoOperation.m +++ b/XCDYouTubeKit/XCDYouTubeVideoOperation.m @@ -213,7 +213,7 @@ - (void) handleVideoInfoResponseWithInfo:(NSDictionary *)info response:(NSURLRes { self.lastError = error; if (error.code > 0) - self.youTubeError = YouTubeError(error, self.webpage.regionsAllowed, self.languageIdentifier); + self.youTubeError = error; [self startNextRequest]; } @@ -293,7 +293,7 @@ - (void) finishWithVideo:(XCDYouTubeVideo *)video - (void) finishWithError { - self.error = self.youTubeError ?: self.lastError; + self.error = self.youTubeError ? YouTubeError(self.youTubeError, self.webpage.regionsAllowed, self.languageIdentifier) : self.lastError; XCDYouTubeLogError(@"Video operation finished with error: %@\nDomain: %@\nCode: %@\nUser Info: %@", self.error.localizedDescription, self.error.domain, @(self.error.code), self.error.userInfo); [self finish]; } diff --git a/XCDYouTubeKit/XCDYouTubeVideoPlayerViewController.h b/XCDYouTubeKit/XCDYouTubeVideoPlayerViewController.h index a3f4493b..09e11f66 100644 --- a/XCDYouTubeKit/XCDYouTubeVideoPlayerViewController.h +++ b/XCDYouTubeKit/XCDYouTubeVideoPlayerViewController.h @@ -6,6 +6,7 @@ #define NS_ASSUME_NONNULL_BEGIN #define NS_ASSUME_NONNULL_END #define nullable +#define null_resettable #endif #import @@ -61,7 +62,7 @@ MP_EXTERN NSString *const XCDYouTubeVideoUserInfoKey; * * @discussion You can pass a nil *videoIdentifier* (or use the standard `init` method instead) and set the `` property later. */ -- (instancetype) initWithVideoIdentifier:(nullable NSString *)videoIdentifier __attribute__((objc_designated_initializer)); +- (instancetype) initWithVideoIdentifier:(nullable NSString *)videoIdentifier NS_DESIGNATED_INITIALIZER; /** * ------------------------------------ @@ -89,7 +90,7 @@ MP_EXTERN NSString *const XCDYouTubeVideoUserInfoKey; * * @see XCDYouTubeVideoQuality */ -@property (nonatomic, copy) NSArray *preferredVideoQualities; +@property (nonatomic, copy, null_resettable) NSArray *preferredVideoQualities; /** * ------------------------ diff --git a/XCDYouTubeKit/XCDYouTubeVideoPlayerViewController.m b/XCDYouTubeKit/XCDYouTubeVideoPlayerViewController.m index b34c5000..338d6e01 100644 --- a/XCDYouTubeKit/XCDYouTubeVideoPlayerViewController.m +++ b/XCDYouTubeKit/XCDYouTubeVideoPlayerViewController.m @@ -140,7 +140,7 @@ - (void) presentInView:(UIView *)view self.embedded = YES; self.moviePlayer.controlStyle = MPMovieControlStyleEmbedded; - self.moviePlayer.view.frame = CGRectMake(0.f, 0.f, view.bounds.size.width, view.bounds.size.height); + self.moviePlayer.view.frame = CGRectMake(0, 0, view.bounds.size.width, view.bounds.size.height); self.moviePlayer.view.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight; if (![view.subviews containsObject:self.moviePlayer.view]) [view addSubview:self.moviePlayer.view];