From 02f2702c17b918203baddcc3057b1c64a5711d31 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ce=CC=81dric=20Luthi?= Date: Mon, 21 Dec 2015 21:33:01 +0100 Subject: [PATCH 01/18] Point badges to the develop branch --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 0f28fb7f..5d6a285b 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ ## About -[![Build Status](https://img.shields.io/travis/0xced/XCDYouTubeKit/master.svg?style=flat)](https://travis-ci.org/0xced/XCDYouTubeKit) -[![Coverage Status](https://img.shields.io/coveralls/0xced/XCDYouTubeKit/master.svg?style=flat)](https://coveralls.io/r/0xced/XCDYouTubeKit?branch=master) +[![Build Status](https://img.shields.io/travis/0xced/XCDYouTubeKit/develop.svg?style=flat)](https://travis-ci.org/0xced/XCDYouTubeKit) +[![Coverage Status](https://img.shields.io/coveralls/0xced/XCDYouTubeKit/develop.svg?style=flat)](https://coveralls.io/r/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/) From f9164a924e90278fdaf9875c6a604c50178ad03d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ce=CC=81dric=20Luthi?= Date: Sun, 27 Dec 2015 20:56:23 +0100 Subject: [PATCH 02/18] Remove Foundation assertions (NSAssert) in Release configuration --- XCDYouTubeKit.xcodeproj/project.pbxproj | 1 + 1 file changed, 1 insertion(+) diff --git a/XCDYouTubeKit.xcodeproj/project.pbxproj b/XCDYouTubeKit.xcodeproj/project.pbxproj index 8afd2297..823953d0 100644 --- a/XCDYouTubeKit.xcodeproj/project.pbxproj +++ b/XCDYouTubeKit.xcodeproj/project.pbxproj @@ -1212,6 +1212,7 @@ DYLIB_COMPATIBILITY_VERSION = 2.0.0; DYLIB_CURRENT_VERSION = 2.4.3; DYLIB_INSTALL_NAME_BASE = "@rpath"; + ENABLE_NS_ASSERTIONS = NO; ENABLE_STRICT_OBJC_MSGSEND = YES; GCC_C_LANGUAGE_STANDARD = gnu99; GCC_NO_COMMON_BLOCKS = YES; From f2f474118bfc85c59891dbc99c1a6e1de82bf246 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ce=CC=81dric=20Luthi?= Date: Thu, 31 Dec 2015 10:51:32 +0100 Subject: [PATCH 03/18] Use xcpretty-travis-formatter only when running on Travis --- Scripts/run-tests.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Scripts/run-tests.sh b/Scripts/run-tests.sh index c2c5f112..9a57d845 100755 --- a/Scripts/run-tests.sh +++ b/Scripts/run-tests.sh @@ -18,7 +18,7 @@ done COMMAND+=" | tee xcodebuild.log" -xcpretty --version > /dev/null 2>&1 && COMMAND+=" | xcpretty -c" && xcpretty-travis-formatter > /dev/null 2>&1 && COMMAND+=" -f `xcpretty-travis-formatter`" +xcpretty --version > /dev/null 2>&1 && COMMAND+=" | xcpretty -c" && [ "${TRAVIS}" == "true" ] && xcpretty-travis-formatter > /dev/null 2>&1 && COMMAND+=" -f `xcpretty-travis-formatter`" set -x eval "${COMMAND}" && rm xcodebuild.log From cc0709035aaa20b27a2ab103769a1b3073ced9ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ce=CC=81dric=20Luthi?= Date: Thu, 31 Dec 2015 10:54:59 +0100 Subject: [PATCH 04/18] Remove the `-c` xcpretty option It's automatic since version 0.2.0 --- Scripts/run-tests.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Scripts/run-tests.sh b/Scripts/run-tests.sh index 9a57d845..e8760d1a 100755 --- a/Scripts/run-tests.sh +++ b/Scripts/run-tests.sh @@ -18,7 +18,7 @@ done COMMAND+=" | tee xcodebuild.log" -xcpretty --version > /dev/null 2>&1 && COMMAND+=" | xcpretty -c" && [ "${TRAVIS}" == "true" ] && xcpretty-travis-formatter > /dev/null 2>&1 && COMMAND+=" -f `xcpretty-travis-formatter`" +xcpretty --version > /dev/null 2>&1 && COMMAND+=" | xcpretty" && [ "${TRAVIS}" == "true" ] && xcpretty-travis-formatter > /dev/null 2>&1 && COMMAND+=" -f `xcpretty-travis-formatter`" set -x eval "${COMMAND}" && rm xcodebuild.log From cfb79d9bd376bbfe0d90eea73b493ce8cc48621d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ce=CC=81dric=20Luthi?= Date: Tue, 15 Dec 2015 15:52:25 +0100 Subject: [PATCH 05/18] Make log handler customisable Also make sure that CocoaLumberjack is compatible by checking `log:message:level:flag:context:file:function:line:tag:` type encoding. --- XCDYouTubeKit/XCDYouTubeLogger.h | 2 ++ XCDYouTubeKit/XCDYouTubeLogger.m | 61 +++++++++++++++++++++++++------- 2 files changed, 50 insertions(+), 13 deletions(-) diff --git a/XCDYouTubeKit/XCDYouTubeLogger.h b/XCDYouTubeKit/XCDYouTubeLogger.h index ab3a9045..65a40a5b 100644 --- a/XCDYouTubeKit/XCDYouTubeLogger.h +++ b/XCDYouTubeKit/XCDYouTubeLogger.h @@ -19,6 +19,8 @@ __attribute__((visibility("hidden"))) + (void) logMessage:(NSString * (^)(void))message flag:(DDLogFlag)flag file:(const char *)file function:(const char *)function line:(NSUInteger)line; @end +extern void XCDYouTubeSetLogHandler(void (^handler)(NSString * (^message)(void), DDLogFlag flag, const char *file, const char *function, NSUInteger line)); + #define XCDYouTubeLog(_flag, _message) [XCDYouTubeLogger logMessage:(_message) flag:(_flag) file:__FILE__ function:__PRETTY_FUNCTION__ line:__LINE__] #define XCDYouTubeLogError(format, ...) XCDYouTubeLog(DDLogFlagError, (^{ return [NSString stringWithFormat:(format), ##__VA_ARGS__]; })) diff --git a/XCDYouTubeKit/XCDYouTubeLogger.m b/XCDYouTubeKit/XCDYouTubeLogger.m index ce22ede6..6626cdc5 100644 --- a/XCDYouTubeKit/XCDYouTubeLogger.m +++ b/XCDYouTubeKit/XCDYouTubeLogger.m @@ -4,29 +4,64 @@ #import "XCDYouTubeLogger.h" +#import + @protocol XCDYouTubeLogger_DDLog // Copied from CocoaLumberjack's DDLog interface + (void) log:(BOOL)asynchronous message:(NSString *)message level:(NSUInteger)level flag:(DDLogFlag)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), DDLogFlag, const char *, const char *, NSUInteger) = ^(NSString *(^message)(void), DDLogFlag flag, const char *file, const char *function, NSUInteger line) +{ + char *logLevelString = getenv("XCDYouTubeKitLogLevel"); + NSUInteger logLevel = logLevelString ? strtoul(logLevelString, NULL, 0) : DDLogFlagError | DDLogFlagWarning; + if ((flag & logLevel)) + NSLog(@"[XCDYouTubeKit] %@", message()); +}; + +static Class DDLogClass = Nil; + +static void (^const CocoaLumberjackLogHandler)(NSString *(^)(void), DDLogFlag, const char *, const char *, NSUInteger) = ^(NSString *(^message)(void), DDLogFlag flag, const char *file, const char *function, NSUInteger line) +{ + [DDLogClass log:YES message:message() level:NSUIntegerMax flag:flag context:(NSInteger)0xced70676 file:file function:function line:line tag:nil]; +}; + +static void (^LogHandler)(NSString *(^)(void), DDLogFlag, const char *, const char *, NSUInteger); + +void XCDYouTubeSetLogHandler(void (^handler)(NSString * (^message)(void), DDLogFlag flag, const char *file, const char *function, NSUInteger line)) +{ + LogHandler = handler; +} + @implementation XCDYouTubeLogger -+ (void) logMessage:(NSString * (^)(void))message flag:(DDLogFlag)flag file:(const char *)file function:(const char *)function line:(NSUInteger)line ++ (void) initialize { - Class DDLogClass = NSClassFromString(@"DDLog"); - if ([DDLogClass respondsToSelector:@selector(log:message:level:flag:context:file:function:line:tag:)]) - { - [DDLogClass log:YES message:message() level:NSUIntegerMax flag:flag context:(NSInteger)0xced70676 file:file function:function line:line tag:nil]; - } - else - { - char *logLevelString = getenv("XCDYouTubeKitLogLevel"); - NSUInteger logLevel = logLevelString ? strtoul(logLevelString, NULL, 0) : DDLogFlagError | DDLogFlagWarning; - if (!(flag & logLevel)) + static dispatch_once_t once; + dispatch_once(&once, ^{ + if (LogHandler) return; - NSLog(@"[XCDYouTubeKit] %@", message()); - } + LogHandler = DefaultLogHandler; + + DDLogClass = objc_lookUpClass("DDLog"); + if (DDLogClass) + { + const SEL logSeletor = @selector(log:message:level:flag:context:file:function:line:tag:); + const char *typeEncoding = method_getTypeEncoding(class_getClassMethod(DDLogClass, logSeletor)); + const char *expectedTypeEncoding = protocol_getMethodDescription(@protocol(XCDYouTubeLogger_DDLog), logSeletor, /* isRequiredMethod: */ YES, /* isInstanceMethod: */ NO).types; + if (typeEncoding && expectedTypeEncoding && strcmp(typeEncoding, expectedTypeEncoding) == 0) + LogHandler = CocoaLumberjackLogHandler; + else + NSLog(@"[XCDYouTubeKit] Incompatible CocoaLumberjack version. Expected \"%@\", got \"%@\".", expectedTypeEncoding ? @(expectedTypeEncoding) : @"", typeEncoding ? @(typeEncoding) : @""); + } + }); +} + ++ (void) logMessage:(NSString * (^)(void))message flag:(DDLogFlag)flag file:(const char *)file function:(const char *)function line:(NSUInteger)line +{ + if (LogHandler) + LogHandler(message, flag, file, function, line); } @end From 89dd8082e5bc75c9f745711183bd7efdd82a8545 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ce=CC=81dric=20Luthi?= Date: Tue, 15 Dec 2015 16:07:19 +0100 Subject: [PATCH 06/18] Do not usurp DDLogFlag namespace --- XCDYouTubeKit/XCDYouTubeLogger.h | 32 ++++++++++++++++---------------- XCDYouTubeKit/XCDYouTubeLogger.m | 14 +++++++------- 2 files changed, 23 insertions(+), 23 deletions(-) diff --git a/XCDYouTubeKit/XCDYouTubeLogger.h b/XCDYouTubeKit/XCDYouTubeLogger.h index 65a40a5b..c2af97a0 100644 --- a/XCDYouTubeKit/XCDYouTubeLogger.h +++ b/XCDYouTubeKit/XCDYouTubeLogger.h @@ -4,28 +4,28 @@ #import -// From CocoaLumberjack's DDLog.h -typedef NS_OPTIONS(NSUInteger, DDLogFlag) { - DDLogFlagError = (1 << 0), // 0...00001 - DDLogFlagWarning = (1 << 1), // 0...00010 - DDLogFlagInfo = (1 << 2), // 0...00100 - DDLogFlagDebug = (1 << 3), // 0...01000 - DDLogFlagVerbose = (1 << 4), // 0...10000 - DDLogFlagTrace = (1 << 5) // 0..100000 (custom level not present in DDLog.h) +// Matching DDLogFlag from CocoaLumberjack's DDLog.h +typedef NS_OPTIONS(NSUInteger, XCDLogFlag) { + XCDLogFlagError = (1 << 0), // 0...00001 + XCDLogFlagWarning = (1 << 1), // 0...00010 + XCDLogFlagInfo = (1 << 2), // 0...00100 + XCDLogFlagDebug = (1 << 3), // 0...01000 + XCDLogFlagVerbose = (1 << 4), // 0...10000 + XCDLogFlagTrace = (1 << 5) // 0..100000 (custom level not present in DDLog.h) }; __attribute__((visibility("hidden"))) @interface XCDYouTubeLogger : NSObject -+ (void) logMessage:(NSString * (^)(void))message flag:(DDLogFlag)flag file:(const char *)file function:(const char *)function line:(NSUInteger)line; ++ (void) logMessage:(NSString * (^)(void))message flag:(XCDLogFlag)flag file:(const char *)file function:(const char *)function line:(NSUInteger)line; @end -extern void XCDYouTubeSetLogHandler(void (^handler)(NSString * (^message)(void), DDLogFlag flag, const char *file, const char *function, NSUInteger line)); +extern void XCDYouTubeSetLogHandler(void (^handler)(NSString * (^message)(void), XCDLogFlag flag, const char *file, const char *function, NSUInteger line)); #define XCDYouTubeLog(_flag, _message) [XCDYouTubeLogger logMessage:(_message) flag:(_flag) file:__FILE__ function:__PRETTY_FUNCTION__ line:__LINE__] -#define XCDYouTubeLogError(format, ...) XCDYouTubeLog(DDLogFlagError, (^{ return [NSString stringWithFormat:(format), ##__VA_ARGS__]; })) -#define XCDYouTubeLogWarning(format, ...) XCDYouTubeLog(DDLogFlagWarning, (^{ return [NSString stringWithFormat:(format), ##__VA_ARGS__]; })) -#define XCDYouTubeLogInfo(format, ...) XCDYouTubeLog(DDLogFlagInfo, (^{ return [NSString stringWithFormat:(format), ##__VA_ARGS__]; })) -#define XCDYouTubeLogDebug(format, ...) XCDYouTubeLog(DDLogFlagDebug, (^{ return [NSString stringWithFormat:(format), ##__VA_ARGS__]; })) -#define XCDYouTubeLogVerbose(format, ...) XCDYouTubeLog(DDLogFlagVerbose, (^{ return [NSString stringWithFormat:(format), ##__VA_ARGS__]; })) -#define XCDYouTubeLogTrace(format, ...) XCDYouTubeLog(DDLogFlagTrace, (^{ return [NSString stringWithFormat:(format), ##__VA_ARGS__]; })) +#define XCDYouTubeLogError(format, ...) XCDYouTubeLog(XCDLogFlagError, (^{ return [NSString stringWithFormat:(format), ##__VA_ARGS__]; })) +#define XCDYouTubeLogWarning(format, ...) XCDYouTubeLog(XCDLogFlagWarning, (^{ return [NSString stringWithFormat:(format), ##__VA_ARGS__]; })) +#define XCDYouTubeLogInfo(format, ...) XCDYouTubeLog(XCDLogFlagInfo, (^{ return [NSString stringWithFormat:(format), ##__VA_ARGS__]; })) +#define XCDYouTubeLogDebug(format, ...) XCDYouTubeLog(XCDLogFlagDebug, (^{ return [NSString stringWithFormat:(format), ##__VA_ARGS__]; })) +#define XCDYouTubeLogVerbose(format, ...) XCDYouTubeLog(XCDLogFlagVerbose, (^{ return [NSString stringWithFormat:(format), ##__VA_ARGS__]; })) +#define XCDYouTubeLogTrace(format, ...) XCDYouTubeLog(XCDLogFlagTrace, (^{ return [NSString stringWithFormat:(format), ##__VA_ARGS__]; })) diff --git a/XCDYouTubeKit/XCDYouTubeLogger.m b/XCDYouTubeKit/XCDYouTubeLogger.m index 6626cdc5..a45bf0f3 100644 --- a/XCDYouTubeKit/XCDYouTubeLogger.m +++ b/XCDYouTubeKit/XCDYouTubeLogger.m @@ -8,27 +8,27 @@ @protocol XCDYouTubeLogger_DDLog // Copied from CocoaLumberjack's DDLog interface -+ (void) log:(BOOL)asynchronous message:(NSString *)message level:(NSUInteger)level flag:(DDLogFlag)flag context:(NSInteger)context file:(const char *)file function:(const char *)function line:(NSUInteger)line tag:(id)tag; ++ (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), DDLogFlag, const char *, const char *, NSUInteger) = ^(NSString *(^message)(void), DDLogFlag flag, const char *file, const char *function, NSUInteger line) +static void (^const DefaultLogHandler)(NSString *(^)(void), XCDLogFlag, const char *, const char *, NSUInteger) = ^(NSString *(^message)(void), XCDLogFlag flag, const char *file, const char *function, NSUInteger line) { char *logLevelString = getenv("XCDYouTubeKitLogLevel"); - NSUInteger logLevel = logLevelString ? strtoul(logLevelString, NULL, 0) : DDLogFlagError | DDLogFlagWarning; + NSUInteger logLevel = logLevelString ? strtoul(logLevelString, NULL, 0) : XCDLogFlagError | XCDLogFlagWarning; if ((flag & logLevel)) NSLog(@"[XCDYouTubeKit] %@", message()); }; static Class DDLogClass = Nil; -static void (^const CocoaLumberjackLogHandler)(NSString *(^)(void), DDLogFlag, const char *, const char *, NSUInteger) = ^(NSString *(^message)(void), DDLogFlag flag, const char *file, const char *function, NSUInteger line) +static void (^const CocoaLumberjackLogHandler)(NSString *(^)(void), XCDLogFlag, const char *, const char *, NSUInteger) = ^(NSString *(^message)(void), XCDLogFlag flag, const char *file, const char *function, NSUInteger line) { [DDLogClass log:YES message:message() level:NSUIntegerMax flag:flag context:(NSInteger)0xced70676 file:file function:function line:line tag:nil]; }; -static void (^LogHandler)(NSString *(^)(void), DDLogFlag, const char *, const char *, NSUInteger); +static void (^LogHandler)(NSString *(^)(void), XCDLogFlag, const char *, const char *, NSUInteger); -void XCDYouTubeSetLogHandler(void (^handler)(NSString * (^message)(void), DDLogFlag flag, const char *file, const char *function, NSUInteger line)) +void XCDYouTubeSetLogHandler(void (^handler)(NSString * (^message)(void), XCDLogFlag flag, const char *file, const char *function, NSUInteger line)) { LogHandler = handler; } @@ -58,7 +58,7 @@ + (void) initialize }); } -+ (void) logMessage:(NSString * (^)(void))message flag:(DDLogFlag)flag file:(const char *)file function:(const char *)function line:(NSUInteger)line ++ (void) logMessage:(NSString * (^)(void))message flag:(XCDLogFlag)flag file:(const char *)file function:(const char *)function line:(NSUInteger)line { if (LogHandler) LogHandler(message, flag, file, function, line); From b574756e291bca8839a716447d809c95a0871a28 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ce=CC=81dric=20Luthi?= Date: Wed, 16 Dec 2015 10:19:25 +0100 Subject: [PATCH 07/18] Make XCDYouTubeLogger public and configurable --- XCDYouTubeKit Demo/iOS Demo/AppDelegate.m | 5 +++-- XCDYouTubeKit.podspec | 2 +- XCDYouTubeKit.xcodeproj/project.pbxproj | 16 ++++++++++++++++ XCDYouTubeKit/XCDYouTubeKit.h | 1 + XCDYouTubeKit/XCDYouTubeLogger+Private.h | 22 ++++++++++++++++++++++ XCDYouTubeKit/XCDYouTubeLogger.h | 16 ++++------------ XCDYouTubeKit/XCDYouTubeLogger.m | 23 +++++++++++------------ XCDYouTubeKit/XCDYouTubePlayerScript.m | 2 +- XCDYouTubeKit/XCDYouTubeVideoOperation.m | 2 +- XCDYouTubeKit/XCDYouTubeVideoWebpage.m | 2 +- 10 files changed, 61 insertions(+), 30 deletions(-) create mode 100644 XCDYouTubeKit/XCDYouTubeLogger+Private.h diff --git a/XCDYouTubeKit Demo/iOS Demo/AppDelegate.m b/XCDYouTubeKit Demo/iOS Demo/AppDelegate.m index f35390d9..341a5bd7 100644 --- a/XCDYouTubeKit Demo/iOS Demo/AppDelegate.m +++ b/XCDYouTubeKit Demo/iOS Demo/AppDelegate.m @@ -6,6 +6,7 @@ @import AVFoundation; #import +#import #import "ContextLogFormatter.h" @@ -35,13 +36,13 @@ static void InitializeLoggers(void) DDTTYLogger *ttyLogger = [DDTTYLogger sharedInstance]; DDLogLevel defaultLogLevel = LogLevelForEnvironmentVariable(@"DefaultLogLevel", DDLogLevelInfo); DDLogLevel youTubeLogLevel = LogLevelForEnvironmentVariable(@"XCDYouTubeLogLevel", DDLogLevelWarning); - ttyLogger.logFormatter = [[ContextLogFormatter alloc] initWithLevels:@{ @((NSInteger)0xced70676) : @(youTubeLogLevel) } defaultLevel:defaultLogLevel]; + ttyLogger.logFormatter = [[ContextLogFormatter alloc] initWithLevels:@{ @(XCDYouTubeKitLumberjackContext) : @(youTubeLogLevel) } defaultLevel:defaultLogLevel]; ttyLogger.colorsEnabled = YES; [DDLog addLogger:ttyLogger]; NSString *bonjourServiceName = [[NSUserDefaults standardUserDefaults] objectForKey:@"NSLoggerBonjourServiceName"]; XCDLumberjackNSLogger *logger = [[XCDLumberjackNSLogger alloc] initWithBonjourServiceName:bonjourServiceName]; - logger.tags = @{ @0: @"Movie Player", @((NSInteger)0xced70676) : @"XCDYouTubeKit" }; + logger.tags = @{ @0: @"Movie Player", @(XCDYouTubeKitLumberjackContext) : @"XCDYouTubeKit" }; [DDLog addLogger:logger]; } diff --git a/XCDYouTubeKit.podspec b/XCDYouTubeKit.podspec index 34cd15a7..4ec7eb49 100644 --- a/XCDYouTubeKit.podspec +++ b/XCDYouTubeKit.podspec @@ -12,7 +12,7 @@ Pod::Spec.new do |s| s.osx.deployment_target = "10.9" s.tvos.deployment_target = "9.0" s.source_files = "XCDYouTubeKit" - s.public_header_files = "XCDYouTubeKit/XCDYouTube{Client,Error,Kit,Operation,Video,VideoOperation,VideoPlayerViewController}.h" + s.public_header_files = "XCDYouTubeKit/XCDYouTube{Client,Error,Kit,Logger,Operation,Video,VideoOperation,VideoPlayerViewController}.h" s.osx.exclude_files = "XCDYouTubeKit/XCDYouTubeVideoPlayerViewController.{h,m}" s.tvos.exclude_files = "XCDYouTubeKit/XCDYouTubeVideoPlayerViewController.{h,m}" s.ios.frameworks = "JavaScriptCore", "MediaPlayer" diff --git a/XCDYouTubeKit.xcodeproj/project.pbxproj b/XCDYouTubeKit.xcodeproj/project.pbxproj index 823953d0..e49fdf23 100644 --- a/XCDYouTubeKit.xcodeproj/project.pbxproj +++ b/XCDYouTubeKit.xcodeproj/project.pbxproj @@ -59,6 +59,13 @@ C24C162E18E9A139005E92E9 /* XCDYouTubeVideoOperation.m in Sources */ = {isa = PBXBuildFile; fileRef = C24C162D18E9A139005E92E9 /* XCDYouTubeVideoOperation.m */; }; C25308C518D7392500132734 /* XCDYouTubeClient.m in Sources */ = {isa = PBXBuildFile; fileRef = C25308C418D7392500132734 /* XCDYouTubeClient.m */; }; C25308C818D739EB00132734 /* XCDYouTubeVideo.m in Sources */ = {isa = PBXBuildFile; fileRef = C25308C718D739EB00132734 /* XCDYouTubeVideo.m */; }; + C257F7911C206B8F006146D3 /* XCDYouTubeLogger+Private.h in Headers */ = {isa = PBXBuildFile; fileRef = C257F7901C206B86006146D3 /* XCDYouTubeLogger+Private.h */; }; + C257F7921C206B8F006146D3 /* XCDYouTubeLogger+Private.h in Headers */ = {isa = PBXBuildFile; fileRef = C257F7901C206B86006146D3 /* XCDYouTubeLogger+Private.h */; }; + C257F7931C206B90006146D3 /* XCDYouTubeLogger+Private.h in Headers */ = {isa = PBXBuildFile; fileRef = C257F7901C206B86006146D3 /* XCDYouTubeLogger+Private.h */; }; + C257F7941C206D26006146D3 /* XCDYouTubeLogger.h in Headers */ = {isa = PBXBuildFile; fileRef = C2597EA41B0CD2120030E9F2 /* XCDYouTubeLogger.h */; settings = {ATTRIBUTES = (Public, ); }; }; + C257F7951C206D26006146D3 /* XCDYouTubeLogger.h in Headers */ = {isa = PBXBuildFile; fileRef = C2597EA41B0CD2120030E9F2 /* XCDYouTubeLogger.h */; settings = {ATTRIBUTES = (Public, ); }; }; + C257F7961C206D26006146D3 /* XCDYouTubeLogger.h in Headers */ = {isa = PBXBuildFile; fileRef = C2597EA41B0CD2120030E9F2 /* XCDYouTubeLogger.h */; settings = {ATTRIBUTES = (Public, ); }; }; + C257F7971C21617B006146D3 /* XCDYouTubeLogger.h in Copy Files */ = {isa = PBXBuildFile; fileRef = C2597EA41B0CD2120030E9F2 /* XCDYouTubeLogger.h */; }; C2597EA31B0CB9920030E9F2 /* JavaScriptCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C224EB641919241B0038186E /* JavaScriptCore.framework */; }; C2597EA61B0CE6D80030E9F2 /* XCDYouTubeLogger.m in Sources */ = {isa = PBXBuildFile; fileRef = C2597EA51B0CE6D70030E9F2 /* XCDYouTubeLogger.m */; }; C2597EA71B0CE6D80030E9F2 /* XCDYouTubeLogger.m in Sources */ = {isa = PBXBuildFile; fileRef = C2597EA51B0CE6D70030E9F2 /* XCDYouTubeLogger.m */; }; @@ -174,6 +181,7 @@ C2D0CBAD19122B3B00DA8CD4 /* XCDYouTubeKit.h in Copy Files */, C2A7E8B518EE1EFC005B8B5F /* XCDYouTubeClient.h in Copy Files */, C2A7E8B618EE1F00005B8B5F /* XCDYouTubeError.h in Copy Files */, + C257F7971C21617B006146D3 /* XCDYouTubeLogger.h in Copy Files */, C2A7E8B718EE1F09005B8B5F /* XCDYouTubeOperation.h in Copy Files */, C2A7E8B818EE205D005B8B5F /* XCDYouTubeVideo.h in Copy Files */, C2D0CBAE19122B4800DA8CD4 /* XCDYouTubeVideoOperation.h in Copy Files */, @@ -206,6 +214,7 @@ C25308C418D7392500132734 /* XCDYouTubeClient.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = XCDYouTubeClient.m; sourceTree = ""; }; C25308C618D739EB00132734 /* XCDYouTubeVideo.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = XCDYouTubeVideo.h; sourceTree = ""; }; C25308C718D739EB00132734 /* XCDYouTubeVideo.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = XCDYouTubeVideo.m; sourceTree = ""; }; + C257F7901C206B86006146D3 /* XCDYouTubeLogger+Private.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "XCDYouTubeLogger+Private.h"; sourceTree = ""; }; C2597EA41B0CD2120030E9F2 /* XCDYouTubeLogger.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = XCDYouTubeLogger.h; sourceTree = ""; }; C2597EA51B0CE6D70030E9F2 /* XCDYouTubeLogger.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = XCDYouTubeLogger.m; sourceTree = ""; }; C262317A191D741700D23900 /* XCDYouTubeKit.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = XCDYouTubeKit.framework; sourceTree = BUILT_PRODUCTS_DIR; }; @@ -387,6 +396,7 @@ C25308C418D7392500132734 /* XCDYouTubeClient.m */, C24C162918E4DA6E005E92E9 /* XCDYouTubeError.h */, C2D0CBAC19122A8F00DA8CD4 /* XCDYouTubeKit.h */, + C257F7901C206B86006146D3 /* XCDYouTubeLogger+Private.h */, C2597EA41B0CD2120030E9F2 /* XCDYouTubeLogger.h */, C2597EA51B0CE6D70030E9F2 /* XCDYouTubeLogger.m */, C24C163318E9FECE005E92E9 /* XCDYouTubeOperation.h */, @@ -444,6 +454,8 @@ C215BEB01BE2E57600F9783B /* XCDYouTubeClient.h in Headers */, C215BEB11BE2E57C00F9783B /* XCDYouTubeError.h in Headers */, C215BEB21BE2E58100F9783B /* XCDYouTubeKit.h in Headers */, + C257F7961C206D26006146D3 /* XCDYouTubeLogger.h in Headers */, + C257F7931C206B90006146D3 /* XCDYouTubeLogger+Private.h in Headers */, C215BEB31BE2E58900F9783B /* XCDYouTubeOperation.h in Headers */, C215BEB81BE2E5B000F9783B /* XCDYouTubeVideoWebpage.h in Headers */, C215BEB61BE2E59400F9783B /* XCDYouTubeVideo.h in Headers */, @@ -461,6 +473,8 @@ C2386B1E1974036300646123 /* XCDYouTubeVideoWebpage.h in Headers */, C26231AC191D752200D23900 /* XCDYouTubeError.h in Headers */, C26231AD191D752500D23900 /* XCDYouTubeKit.h in Headers */, + C257F7951C206D26006146D3 /* XCDYouTubeLogger.h in Headers */, + C257F7921C206B8F006146D3 /* XCDYouTubeLogger+Private.h in Headers */, C26231AE191D752800D23900 /* XCDYouTubeOperation.h in Headers */, C26231AF191D752D00D23900 /* XCDYouTubeVideo.h in Headers */, C26231B0191D753500D23900 /* XCDYouTubeVideoOperation.h in Headers */, @@ -476,6 +490,8 @@ C2F0E58E1944F82600D8EBA8 /* XCDYouTubeClient.h in Headers */, C2F0E58F1944F82600D8EBA8 /* XCDYouTubeError.h in Headers */, C2142F2A19644779000FA9C0 /* XCDYouTubeKit.h in Headers */, + C257F7941C206D26006146D3 /* XCDYouTubeLogger.h in Headers */, + C257F7911C206B8F006146D3 /* XCDYouTubeLogger+Private.h in Headers */, C2F0E5901944F83E00D8EBA8 /* XCDYouTubeOperation.h in Headers */, C2F0E5931944F84700D8EBA8 /* XCDYouTubeVideo.h in Headers */, C2F0E5941944F84A00D8EBA8 /* XCDYouTubeVideoOperation.h in Headers */, diff --git a/XCDYouTubeKit/XCDYouTubeKit.h b/XCDYouTubeKit/XCDYouTubeKit.h index dea9034d..bba37f2a 100644 --- a/XCDYouTubeKit/XCDYouTubeKit.h +++ b/XCDYouTubeKit/XCDYouTubeKit.h @@ -6,6 +6,7 @@ #import #import +#import #import #import #import diff --git a/XCDYouTubeKit/XCDYouTubeLogger+Private.h b/XCDYouTubeKit/XCDYouTubeLogger+Private.h new file mode 100644 index 00000000..eac53015 --- /dev/null +++ b/XCDYouTubeKit/XCDYouTubeLogger+Private.h @@ -0,0 +1,22 @@ +// +// Copyright (c) 2013-2015 Cédric Luthi. All rights reserved. +// + +#import + +#import "XCDYouTubeLogger.h" + +@interface XCDYouTubeLogger () + ++ (void) logMessage:(NSString * (^)(void))message flag:(XCDLogFlag)flag file:(const char *)file function:(const char *)function line:(NSUInteger)line; + +@end + +#define XCDYouTubeLog(_flag, _message) [XCDYouTubeLogger logMessage:(_message) flag:(_flag) file:__FILE__ function:__PRETTY_FUNCTION__ line:__LINE__] + +#define XCDYouTubeLogError(format, ...) XCDYouTubeLog(XCDLogFlagError, (^{ return [NSString stringWithFormat:(format), ##__VA_ARGS__]; })) +#define XCDYouTubeLogWarning(format, ...) XCDYouTubeLog(XCDLogFlagWarning, (^{ return [NSString stringWithFormat:(format), ##__VA_ARGS__]; })) +#define XCDYouTubeLogInfo(format, ...) XCDYouTubeLog(XCDLogFlagInfo, (^{ return [NSString stringWithFormat:(format), ##__VA_ARGS__]; })) +#define XCDYouTubeLogDebug(format, ...) XCDYouTubeLog(XCDLogFlagDebug, (^{ return [NSString stringWithFormat:(format), ##__VA_ARGS__]; })) +#define XCDYouTubeLogVerbose(format, ...) XCDYouTubeLog(XCDLogFlagVerbose, (^{ return [NSString stringWithFormat:(format), ##__VA_ARGS__]; })) +#define XCDYouTubeLogTrace(format, ...) XCDYouTubeLog(XCDLogFlagTrace, (^{ return [NSString stringWithFormat:(format), ##__VA_ARGS__]; })) diff --git a/XCDYouTubeKit/XCDYouTubeLogger.h b/XCDYouTubeKit/XCDYouTubeLogger.h index c2af97a0..261aebf5 100644 --- a/XCDYouTubeKit/XCDYouTubeLogger.h +++ b/XCDYouTubeKit/XCDYouTubeLogger.h @@ -4,6 +4,8 @@ #import +extern const NSInteger XCDYouTubeKitLumberjackContext; + // Matching DDLogFlag from CocoaLumberjack's DDLog.h typedef NS_OPTIONS(NSUInteger, XCDLogFlag) { XCDLogFlagError = (1 << 0), // 0...00001 @@ -14,18 +16,8 @@ typedef NS_OPTIONS(NSUInteger, XCDLogFlag) { XCDLogFlagTrace = (1 << 5) // 0..100000 (custom level not present in DDLog.h) }; -__attribute__((visibility("hidden"))) @interface XCDYouTubeLogger : NSObject -+ (void) logMessage:(NSString * (^)(void))message flag:(XCDLogFlag)flag file:(const char *)file function:(const char *)function line:(NSUInteger)line; -@end -extern void XCDYouTubeSetLogHandler(void (^handler)(NSString * (^message)(void), XCDLogFlag flag, const char *file, const char *function, NSUInteger line)); ++ (void) setLogHandler:(void (^)(NSString * (^message)(void), XCDLogFlag flag, const char *file, const char *function, NSUInteger line))logHandler; -#define XCDYouTubeLog(_flag, _message) [XCDYouTubeLogger logMessage:(_message) flag:(_flag) file:__FILE__ function:__PRETTY_FUNCTION__ line:__LINE__] - -#define XCDYouTubeLogError(format, ...) XCDYouTubeLog(XCDLogFlagError, (^{ return [NSString stringWithFormat:(format), ##__VA_ARGS__]; })) -#define XCDYouTubeLogWarning(format, ...) XCDYouTubeLog(XCDLogFlagWarning, (^{ return [NSString stringWithFormat:(format), ##__VA_ARGS__]; })) -#define XCDYouTubeLogInfo(format, ...) XCDYouTubeLog(XCDLogFlagInfo, (^{ return [NSString stringWithFormat:(format), ##__VA_ARGS__]; })) -#define XCDYouTubeLogDebug(format, ...) XCDYouTubeLog(XCDLogFlagDebug, (^{ return [NSString stringWithFormat:(format), ##__VA_ARGS__]; })) -#define XCDYouTubeLogVerbose(format, ...) XCDYouTubeLog(XCDLogFlagVerbose, (^{ return [NSString stringWithFormat:(format), ##__VA_ARGS__]; })) -#define XCDYouTubeLogTrace(format, ...) XCDYouTubeLog(XCDLogFlagTrace, (^{ return [NSString stringWithFormat:(format), ##__VA_ARGS__]; })) +@end diff --git a/XCDYouTubeKit/XCDYouTubeLogger.m b/XCDYouTubeKit/XCDYouTubeLogger.m index a45bf0f3..ec726375 100644 --- a/XCDYouTubeKit/XCDYouTubeLogger.m +++ b/XCDYouTubeKit/XCDYouTubeLogger.m @@ -6,12 +6,14 @@ #import +const NSInteger XCDYouTubeKitLumberjackContext = (NSInteger)0xced70676; + @protocol XCDYouTubeLogger_DDLog // Copied from CocoaLumberjack's DDLog interface + (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), XCDLogFlag, const char *, const char *, NSUInteger) = ^(NSString *(^message)(void), XCDLogFlag flag, const char *file, const char *function, NSUInteger line) +static void (^const DefaultLogHandler)(NSString * (^)(void), XCDLogFlag, const char *, const char *, NSUInteger) = ^(NSString *(^message)(void), XCDLogFlag flag, const char *file, const char *function, NSUInteger line) { char *logLevelString = getenv("XCDYouTubeKitLogLevel"); NSUInteger logLevel = logLevelString ? strtoul(logLevelString, NULL, 0) : XCDLogFlagError | XCDLogFlagWarning; @@ -21,17 +23,12 @@ static void (^const DefaultLogHandler)(NSString *(^)(void), XCDLogFlag, const ch static Class DDLogClass = Nil; -static void (^const CocoaLumberjackLogHandler)(NSString *(^)(void), XCDLogFlag, const char *, const char *, NSUInteger) = ^(NSString *(^message)(void), XCDLogFlag flag, const char *file, const char *function, NSUInteger line) +static void (^const CocoaLumberjackLogHandler)(NSString * (^)(void), XCDLogFlag, const char *, const char *, NSUInteger) = ^(NSString *(^message)(void), XCDLogFlag flag, const char *file, const char *function, NSUInteger line) { - [DDLogClass log:YES message:message() level:NSUIntegerMax flag:flag context:(NSInteger)0xced70676 file:file function:function line:line tag:nil]; + [DDLogClass log:YES message:message() level:NSUIntegerMax flag:flag context:XCDYouTubeKitLumberjackContext file:file function:function line:line tag:nil]; }; -static void (^LogHandler)(NSString *(^)(void), XCDLogFlag, const char *, const char *, NSUInteger); - -void XCDYouTubeSetLogHandler(void (^handler)(NSString * (^message)(void), XCDLogFlag flag, const char *file, const char *function, NSUInteger line)) -{ - LogHandler = handler; -} +static void (^LogHandler)(NSString * (^)(void), XCDLogFlag, const char *, const char *, NSUInteger); @implementation XCDYouTubeLogger @@ -39,9 +36,6 @@ + (void) initialize { static dispatch_once_t once; dispatch_once(&once, ^{ - if (LogHandler) - return; - LogHandler = DefaultLogHandler; DDLogClass = objc_lookUpClass("DDLog"); @@ -58,6 +52,11 @@ + (void) initialize }); } ++ (void) setLogHandler:(void (^)(NSString * (^message)(void), XCDLogFlag flag, const char *file, const char *function, NSUInteger line))logHandler +{ + LogHandler = logHandler; +} + + (void) logMessage:(NSString * (^)(void))message flag:(XCDLogFlag)flag file:(const char *)file function:(const char *)function line:(NSUInteger)line { if (LogHandler) diff --git a/XCDYouTubeKit/XCDYouTubePlayerScript.m b/XCDYouTubeKit/XCDYouTubePlayerScript.m index 1ac21c46..057deb0a 100644 --- a/XCDYouTubeKit/XCDYouTubePlayerScript.m +++ b/XCDYouTubeKit/XCDYouTubePlayerScript.m @@ -6,7 +6,7 @@ #import -#import "XCDYouTubeLogger.h" +#import "XCDYouTubeLogger+Private.h" @interface XCDYouTubePlayerScript () @property (nonatomic, strong) JSContext *context; diff --git a/XCDYouTubeKit/XCDYouTubeVideoOperation.m b/XCDYouTubeKit/XCDYouTubeVideoOperation.m index b789b2be..f9a961a8 100644 --- a/XCDYouTubeKit/XCDYouTubeVideoOperation.m +++ b/XCDYouTubeKit/XCDYouTubeVideoOperation.m @@ -10,7 +10,7 @@ #import "XCDYouTubeError.h" #import "XCDYouTubeVideoWebpage.h" #import "XCDYouTubePlayerScript.h" -#import "XCDYouTubeLogger.h" +#import "XCDYouTubeLogger+Private.h" typedef NS_ENUM(NSUInteger, XCDYouTubeRequestType) { XCDYouTubeRequestTypeGetVideoInfo = 1, diff --git a/XCDYouTubeKit/XCDYouTubeVideoWebpage.m b/XCDYouTubeKit/XCDYouTubeVideoWebpage.m index 1fe7bf68..1364d2e8 100644 --- a/XCDYouTubeKit/XCDYouTubeVideoWebpage.m +++ b/XCDYouTubeKit/XCDYouTubeVideoWebpage.m @@ -4,7 +4,7 @@ #import "XCDYouTubeVideoWebpage.h" -#import "XCDYouTubeLogger.h" +#import "XCDYouTubeLogger+Private.h" @interface XCDYouTubeVideoWebpage () @property (nonatomic, strong) NSData *data; From bd78d75e832f7b381f3c8226071318cff767de5a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ce=CC=81dric=20Luthi?= Date: Fri, 18 Dec 2015 17:03:08 +0100 Subject: [PATCH 08/18] Rename `XCDLogFlag` into `XCDLogLevel` --- XCDYouTubeKit/XCDYouTubeLogger+Private.h | 16 ++++++++-------- XCDYouTubeKit/XCDYouTubeLogger.h | 17 ++++++++--------- XCDYouTubeKit/XCDYouTubeLogger.m | 19 ++++++++++--------- 3 files changed, 26 insertions(+), 26 deletions(-) diff --git a/XCDYouTubeKit/XCDYouTubeLogger+Private.h b/XCDYouTubeKit/XCDYouTubeLogger+Private.h index eac53015..b6d53c43 100644 --- a/XCDYouTubeKit/XCDYouTubeLogger+Private.h +++ b/XCDYouTubeKit/XCDYouTubeLogger+Private.h @@ -8,15 +8,15 @@ @interface XCDYouTubeLogger () -+ (void) logMessage:(NSString * (^)(void))message flag:(XCDLogFlag)flag file:(const char *)file function:(const char *)function line:(NSUInteger)line; ++ (void) logMessage:(NSString * (^)(void))message level:(XCDLogLevel)level file:(const char *)file function:(const char *)function line:(NSUInteger)line; @end -#define XCDYouTubeLog(_flag, _message) [XCDYouTubeLogger logMessage:(_message) flag:(_flag) file:__FILE__ function:__PRETTY_FUNCTION__ line:__LINE__] +#define XCDYouTubeLog(_level, _message) [XCDYouTubeLogger logMessage:(_message) level:(_level) file:__FILE__ function:__PRETTY_FUNCTION__ line:__LINE__] -#define XCDYouTubeLogError(format, ...) XCDYouTubeLog(XCDLogFlagError, (^{ return [NSString stringWithFormat:(format), ##__VA_ARGS__]; })) -#define XCDYouTubeLogWarning(format, ...) XCDYouTubeLog(XCDLogFlagWarning, (^{ return [NSString stringWithFormat:(format), ##__VA_ARGS__]; })) -#define XCDYouTubeLogInfo(format, ...) XCDYouTubeLog(XCDLogFlagInfo, (^{ return [NSString stringWithFormat:(format), ##__VA_ARGS__]; })) -#define XCDYouTubeLogDebug(format, ...) XCDYouTubeLog(XCDLogFlagDebug, (^{ return [NSString stringWithFormat:(format), ##__VA_ARGS__]; })) -#define XCDYouTubeLogVerbose(format, ...) XCDYouTubeLog(XCDLogFlagVerbose, (^{ return [NSString stringWithFormat:(format), ##__VA_ARGS__]; })) -#define XCDYouTubeLogTrace(format, ...) XCDYouTubeLog(XCDLogFlagTrace, (^{ return [NSString stringWithFormat:(format), ##__VA_ARGS__]; })) +#define XCDYouTubeLogError(format, ...) XCDYouTubeLog(XCDLogLevelError, (^{ return [NSString stringWithFormat:(format), ##__VA_ARGS__]; })) +#define XCDYouTubeLogWarning(format, ...) XCDYouTubeLog(XCDLogLevelWarning, (^{ return [NSString stringWithFormat:(format), ##__VA_ARGS__]; })) +#define XCDYouTubeLogInfo(format, ...) XCDYouTubeLog(XCDLogLevelInfo, (^{ return [NSString stringWithFormat:(format), ##__VA_ARGS__]; })) +#define XCDYouTubeLogDebug(format, ...) XCDYouTubeLog(XCDLogLevelDebug, (^{ return [NSString stringWithFormat:(format), ##__VA_ARGS__]; })) +#define XCDYouTubeLogVerbose(format, ...) XCDYouTubeLog(XCDLogLevelVerbose, (^{ return [NSString stringWithFormat:(format), ##__VA_ARGS__]; })) +#define XCDYouTubeLogTrace(format, ...) XCDYouTubeLog(XCDLogLevelTrace, (^{ return [NSString stringWithFormat:(format), ##__VA_ARGS__]; })) diff --git a/XCDYouTubeKit/XCDYouTubeLogger.h b/XCDYouTubeKit/XCDYouTubeLogger.h index 261aebf5..c043b97f 100644 --- a/XCDYouTubeKit/XCDYouTubeLogger.h +++ b/XCDYouTubeKit/XCDYouTubeLogger.h @@ -6,18 +6,17 @@ extern const NSInteger XCDYouTubeKitLumberjackContext; -// Matching DDLogFlag from CocoaLumberjack's DDLog.h -typedef NS_OPTIONS(NSUInteger, XCDLogFlag) { - XCDLogFlagError = (1 << 0), // 0...00001 - XCDLogFlagWarning = (1 << 1), // 0...00010 - XCDLogFlagInfo = (1 << 2), // 0...00100 - XCDLogFlagDebug = (1 << 3), // 0...01000 - XCDLogFlagVerbose = (1 << 4), // 0...10000 - XCDLogFlagTrace = (1 << 5) // 0..100000 (custom level not present in DDLog.h) +typedef NS_ENUM(NSUInteger, XCDLogLevel) { + XCDLogLevelError = 0, + XCDLogLevelWarning = 1, + XCDLogLevelInfo = 2, + XCDLogLevelDebug = 3, + XCDLogLevelVerbose = 4, + XCDLogLevelTrace = 5 }; @interface XCDYouTubeLogger : NSObject -+ (void) setLogHandler:(void (^)(NSString * (^message)(void), XCDLogFlag flag, const char *file, const char *function, NSUInteger line))logHandler; ++ (void) setLogHandler:(void (^)(NSString * (^message)(void), XCDLogLevel level, const char *file, const char *function, NSUInteger line))logHandler; @end diff --git a/XCDYouTubeKit/XCDYouTubeLogger.m b/XCDYouTubeKit/XCDYouTubeLogger.m index ec726375..60068aae 100644 --- a/XCDYouTubeKit/XCDYouTubeLogger.m +++ b/XCDYouTubeKit/XCDYouTubeLogger.m @@ -13,22 +13,23 @@ @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), XCDLogFlag, const char *, const char *, NSUInteger) = ^(NSString *(^message)(void), XCDLogFlag flag, const char *file, const char *function, NSUInteger line) +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 logLevel = logLevelString ? strtoul(logLevelString, NULL, 0) : XCDLogFlagError | XCDLogFlagWarning; - if ((flag & logLevel)) + 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), XCDLogFlag, const char *, const char *, NSUInteger) = ^(NSString *(^message)(void), XCDLogFlag flag, const char *file, const char *function, NSUInteger line) +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) { - [DDLogClass log:YES message:message() level:NSUIntegerMax flag:flag context:XCDYouTubeKitLumberjackContext file:file function:function line:line tag:nil]; + // The `XCDLogLevel` enum was carefully crafted to match the `DDLogFlag` options from DDLog.h + [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), XCDLogFlag, const char *, const char *, NSUInteger); +static void (^LogHandler)(NSString * (^)(void), XCDLogLevel, const char *, const char *, NSUInteger); @implementation XCDYouTubeLogger @@ -52,15 +53,15 @@ + (void) initialize }); } -+ (void) setLogHandler:(void (^)(NSString * (^message)(void), XCDLogFlag flag, const char *file, const char *function, NSUInteger line))logHandler ++ (void) setLogHandler:(void (^)(NSString * (^message)(void), XCDLogLevel level, const char *file, const char *function, NSUInteger line))logHandler { LogHandler = logHandler; } -+ (void) logMessage:(NSString * (^)(void))message flag:(XCDLogFlag)flag file:(const char *)file function:(const char *)function line:(NSUInteger)line ++ (void) logMessage:(NSString * (^)(void))message level:(XCDLogLevel)level file:(const char *)file function:(const char *)function line:(NSUInteger)line { if (LogHandler) - LogHandler(message, flag, file, function, line); + LogHandler(message, level, file, function, line); } @end From d63931c3b07b81a46b7ecae8d8e8bb26c1d1e478 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ce=CC=81dric=20Luthi?= Date: Sun, 27 Dec 2015 20:52:59 +0100 Subject: [PATCH 09/18] Refactor response data to string decoding --- XCDYouTubeKit/XCDYouTubeLogger+Private.h | 1 - XCDYouTubeKit/XCDYouTubeLogger.h | 3 +-- XCDYouTubeKit/XCDYouTubePlayerScript.m | 1 - XCDYouTubeKit/XCDYouTubeVideoOperation.m | 33 ++++++++++++------------ XCDYouTubeKit/XCDYouTubeVideoWebpage.h | 2 +- XCDYouTubeKit/XCDYouTubeVideoWebpage.m | 29 ++++----------------- 6 files changed, 24 insertions(+), 45 deletions(-) diff --git a/XCDYouTubeKit/XCDYouTubeLogger+Private.h b/XCDYouTubeKit/XCDYouTubeLogger+Private.h index b6d53c43..871d1846 100644 --- a/XCDYouTubeKit/XCDYouTubeLogger+Private.h +++ b/XCDYouTubeKit/XCDYouTubeLogger+Private.h @@ -19,4 +19,3 @@ #define XCDYouTubeLogInfo(format, ...) XCDYouTubeLog(XCDLogLevelInfo, (^{ return [NSString stringWithFormat:(format), ##__VA_ARGS__]; })) #define XCDYouTubeLogDebug(format, ...) XCDYouTubeLog(XCDLogLevelDebug, (^{ return [NSString stringWithFormat:(format), ##__VA_ARGS__]; })) #define XCDYouTubeLogVerbose(format, ...) XCDYouTubeLog(XCDLogLevelVerbose, (^{ return [NSString stringWithFormat:(format), ##__VA_ARGS__]; })) -#define XCDYouTubeLogTrace(format, ...) XCDYouTubeLog(XCDLogLevelTrace, (^{ return [NSString stringWithFormat:(format), ##__VA_ARGS__]; })) diff --git a/XCDYouTubeKit/XCDYouTubeLogger.h b/XCDYouTubeKit/XCDYouTubeLogger.h index c043b97f..0f9f6031 100644 --- a/XCDYouTubeKit/XCDYouTubeLogger.h +++ b/XCDYouTubeKit/XCDYouTubeLogger.h @@ -11,8 +11,7 @@ typedef NS_ENUM(NSUInteger, XCDLogLevel) { XCDLogLevelWarning = 1, XCDLogLevelInfo = 2, XCDLogLevelDebug = 3, - XCDLogLevelVerbose = 4, - XCDLogLevelTrace = 5 + XCDLogLevelVerbose = 4 }; @interface XCDYouTubeLogger : NSObject diff --git a/XCDYouTubeKit/XCDYouTubePlayerScript.m b/XCDYouTubeKit/XCDYouTubePlayerScript.m index 057deb0a..87ddf914 100644 --- a/XCDYouTubeKit/XCDYouTubePlayerScript.m +++ b/XCDYouTubeKit/XCDYouTubePlayerScript.m @@ -21,7 +21,6 @@ - (instancetype) initWithString:(NSString *)string return nil; // LCOV_EXCL_LINE NSString *script = [string stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]]; - XCDYouTubeLogTrace(@"%@", script); NSRegularExpression *anonymousFunctionRegularExpression = [NSRegularExpression regularExpressionWithPattern:@"\\(function\\([^)]*\\)\\{(.*)\\}\\)\\([^)]*\\)" options:NSRegularExpressionDotMatchesLineSeparators error:NULL]; NSTextCheckingResult *anonymousFunctionResult = [anonymousFunctionRegularExpression firstMatchInString:script options:(NSMatchingOptions)0 range:NSMakeRange(0, script.length)]; if (anonymousFunctionResult.numberOfRanges > 1) diff --git a/XCDYouTubeKit/XCDYouTubeVideoOperation.m b/XCDYouTubeKit/XCDYouTubeVideoOperation.m index f9a961a8..e8c648ff 100644 --- a/XCDYouTubeKit/XCDYouTubeVideoOperation.m +++ b/XCDYouTubeKit/XCDYouTubeVideoOperation.m @@ -134,23 +134,26 @@ - (void) startRequestWithURL:(NSURL *)url type:(XCDYouTubeRequestType)requestTyp - (void) handleConnectionSuccessWithData:(NSData *)data response:(NSURLResponse *)response requestType:(XCDYouTubeRequestType)requestType { + CFStringEncoding encoding = CFStringConvertIANACharSetNameToEncoding((__bridge CFStringRef)response.textEncodingName ?: CFSTR("")); + // Use kCFStringEncodingMacRoman as fallback because it defines characters for every byte value and is ASCII compatible. See https://mikeash.com/pyblog/friday-qa-2010-02-19-character-encodings.html + NSString *responseString = CFBridgingRelease(CFStringCreateWithBytes(kCFAllocatorDefault, data.bytes, (CFIndex)data.length, encoding != kCFStringEncodingInvalidId ? encoding : kCFStringEncodingMacRoman, false)) ?: @""; + NSAssert(responseString.length > 0, @"Failed to decode response from %@ (response.textEncodingName = %@, data.length = %@)", response.URL, response.textEncodingName, @(data.length)); + + XCDYouTubeLogVerbose(@"Response: %@\n%@", response, responseString); + switch (requestType) { case XCDYouTubeRequestTypeGetVideoInfo: - { - NSString *videoQuery = [[NSString alloc] initWithData:data encoding:NSASCIIStringEncoding]; - NSDictionary *info = XCDDictionaryWithQueryString(videoQuery); - [self handleVideoInfoResponseWithInfo:info response:response]; - } + [self handleVideoInfoResponseWithInfo:XCDDictionaryWithQueryString(responseString) response:response]; break; case XCDYouTubeRequestTypeWatchPage: - [self handleWebPageWithData:data response:response]; + [self handleWebPageWithHTMLString:responseString]; break; case XCDYouTubeRequestTypeEmbedPage: - [self handleEmbedWebPageWithData:data response:response]; + [self handleEmbedWebPageWithHTMLString:responseString]; break; case XCDYouTubeRequestTypeJavaScriptPlayer: - [self handleJavaScriptPlayerWithData:data response:response]; + [self handleJavaScriptPlayerWithScript:responseString]; break; } } @@ -169,7 +172,6 @@ - (void) handleConnectionError:(NSError *)connectionError - (void) handleVideoInfoResponseWithInfo:(NSDictionary *)info response:(NSURLResponse *)response { XCDYouTubeLogDebug(@"Handling video info response"); - XCDYouTubeLogVerbose(@"Video info: %@", info); NSError *error = nil; XCDYouTubeVideo *video = [[XCDYouTubeVideo alloc] initWithIdentifier:self.videoIdentifier info:info playerScript:self.playerScript response:response error:&error]; @@ -197,11 +199,11 @@ - (void) handleVideoInfoResponseWithInfo:(NSDictionary *)info response:(NSURLRes } } -- (void) handleWebPageWithData:(NSData *)data response:(NSURLResponse *)response +- (void) handleWebPageWithHTMLString:(NSString *)html { XCDYouTubeLogDebug(@"Handling web page response"); - self.webpage = [[XCDYouTubeVideoWebpage alloc] initWithData:data response:response]; + self.webpage = [[XCDYouTubeVideoWebpage alloc] initWithHTMLString:html]; if (self.webpage.javaScriptPlayerURL) { @@ -221,11 +223,11 @@ - (void) handleWebPageWithData:(NSData *)data response:(NSURLResponse *)response } } -- (void) handleEmbedWebPageWithData:(NSData *)data response:(NSURLResponse *)response +- (void) handleEmbedWebPageWithHTMLString:(NSString *)html { XCDYouTubeLogDebug(@"Handling embed web page response"); - self.embedWebpage = [[XCDYouTubeVideoWebpage alloc] initWithData:data response:response]; + self.embedWebpage = [[XCDYouTubeVideoWebpage alloc] initWithHTMLString:html]; if (self.embedWebpage.javaScriptPlayerURL) { @@ -237,11 +239,10 @@ - (void) handleEmbedWebPageWithData:(NSData *)data response:(NSURLResponse *)res } } -- (void) handleJavaScriptPlayerWithData:(NSData *)data response:(NSURLResponse *)response +- (void) handleJavaScriptPlayerWithScript:(NSString *)script { XCDYouTubeLogDebug(@"Handling JavaScript player response"); - NSString *script = [[NSString alloc] initWithData:data encoding:NSISOLatin1StringEncoding]; self.playerScript = [[XCDYouTubePlayerScript alloc] initWithString:script]; if (self.webpage.isAgeRestricted) @@ -255,7 +256,7 @@ - (void) handleJavaScriptPlayerWithData:(NSData *)data response:(NSURLResponse * } else { - [self handleVideoInfoResponseWithInfo:self.webpage.videoInfo response:response]; + [self handleVideoInfoResponseWithInfo:self.webpage.videoInfo response:nil]; } } diff --git a/XCDYouTubeKit/XCDYouTubeVideoWebpage.h b/XCDYouTubeKit/XCDYouTubeVideoWebpage.h index 18408419..091c5861 100644 --- a/XCDYouTubeKit/XCDYouTubeVideoWebpage.h +++ b/XCDYouTubeKit/XCDYouTubeVideoWebpage.h @@ -7,7 +7,7 @@ __attribute__((visibility("hidden"))) @interface XCDYouTubeVideoWebpage : NSObject -- (instancetype) initWithData:(NSData *)data response:(NSURLResponse *)response; +- (instancetype) initWithHTMLString:(NSString *)html; @property (nonatomic, readonly) NSDictionary *playerConfiguration; @property (nonatomic, readonly) NSDictionary *videoInfo; diff --git a/XCDYouTubeKit/XCDYouTubeVideoWebpage.m b/XCDYouTubeKit/XCDYouTubeVideoWebpage.m index 1364d2e8..c6fc9f8d 100644 --- a/XCDYouTubeKit/XCDYouTubeVideoWebpage.m +++ b/XCDYouTubeKit/XCDYouTubeVideoWebpage.m @@ -4,45 +4,27 @@ #import "XCDYouTubeVideoWebpage.h" -#import "XCDYouTubeLogger+Private.h" - @interface XCDYouTubeVideoWebpage () -@property (nonatomic, strong) NSData *data; -@property (nonatomic, strong) NSURLResponse *response; - @property (nonatomic, readonly) NSString *html; @end @implementation XCDYouTubeVideoWebpage -@synthesize html = _html; @synthesize playerConfiguration = _playerConfiguration; @synthesize videoInfo = _videoInfo; @synthesize javaScriptPlayerURL = _javaScriptPlayerURL; @synthesize isAgeRestricted = _isAgeRestricted; -- (instancetype) initWithData:(NSData *)data response:(NSURLResponse *)response +- (instancetype) initWithHTMLString:(NSString *)html { if (!(self = [super init])) return nil; // LCOV_EXCL_LINE - _data = data; - _response = response; + _html = html; return self; } -- (NSString *) html -{ - if (!_html) - { - CFStringEncoding encoding = CFStringConvertIANACharSetNameToEncoding((__bridge CFStringRef)self.response.textEncodingName ?: CFSTR("")); - _html = CFBridgingRelease(CFStringCreateWithBytes(kCFAllocatorDefault, self.data.bytes, (CFIndex)self.data.length, encoding != kCFStringEncodingInvalidId ? encoding : kCFStringEncodingISOLatin1, false)); - XCDYouTubeLogTrace(@"%@", self->_html); - } - return _html; -} - - (NSDictionary *) playerConfiguration { if (!_playerConfiguration) @@ -112,10 +94,9 @@ - (BOOL) isAgeRestricted { if (!_isAgeRestricted) { - NSData *openGraphAgeRestriction = [@"og:restrictions:age" dataUsingEncoding:NSUTF8StringEncoding]; - NSDataSearchOptions options = (NSDataSearchOptions)0; - NSRange range = NSMakeRange(0, self.data.length); - _isAgeRestricted = [self.data rangeOfData:openGraphAgeRestriction options:options range:range].location != NSNotFound; + NSStringCompareOptions options = (NSStringCompareOptions)0; + NSRange range = NSMakeRange(0, self.html.length); + _isAgeRestricted = [self.html rangeOfString:@"og:restrictions:age" options:options range:range].location != NSNotFound; } return _isAgeRestricted; } From e758c71872e8a601134a6f7fbeed62d1ee9fe89a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ce=CC=81dric=20Luthi?= Date: Mon, 4 Jan 2016 14:43:02 +0100 Subject: [PATCH 10/18] Document the XCDYouTubeLogger class --- README.md | 23 +------- XCDYouTubeKit/XCDYouTubeLogger.h | 92 ++++++++++++++++++++++++++++++-- 2 files changed, 89 insertions(+), 26 deletions(-) diff --git a/README.md b/README.md index 5d6a285b..02809d0d 100644 --- a/README.md +++ b/README.md @@ -108,28 +108,9 @@ See the demo project for more sample code. ## Logging -Since version 2.2.0, XCDYouTubeKit produces logs. XCDYouTubeKit supports [CocoaLumberjack](https://github.com/CocoaLumberjack/CocoaLumberjack) but does not require it. If your project includes CocoaLumberjack, all logs will be routed through CocoaLumberjack, else logs will be emitted with `NSLog`. +Since version 2.2.0, XCDYouTubeKit produces logs. XCDYouTubeKit supports [CocoaLumberjack](https://github.com/CocoaLumberjack/CocoaLumberjack) but does not require it. -The context for identifying all XCDYouTubeKit logs in CocoaLumberjack is the number `(NSInteger)0xced70676`. Beware, CocoaLumberjack contexts are NSIntegers, don’t forget the cast. - -### Controlling log levels - -If you are using CocoaLumberjack, you are responsible for controlling the log levels with the CocoaLumberjack APIs. - -If you are not using CocoaLumberjack, you can control the log levels with the `XCDYouTubeKitLogLevel` environment variable. The log levels are the same as CocoaLumberjack, with the addition of the *trace* level. - -Level | Value ---------|------ -Error | 0x01 -Warning | 0x02 -Info | 0x04 -Debug | 0x08 -Verbose | 0x10 -Trace | 0x20 - -The levels are bitmasks, so you can combine them. For example, if you want to log *error*, *warning* and *info* levels, set the `XCDYouTubeKitLogLevel` environment variable to `0x7`. - -If you do not set the `XCDYouTubeKitLogLevel` environment variable, only warning and error levels are logged. +See the `XCDYouTubeLogger` class [documentation](http://cocoadocs.org/docsets/XCDYouTubeKit/) for more information. ## Credits diff --git a/XCDYouTubeKit/XCDYouTubeLogger.h b/XCDYouTubeKit/XCDYouTubeLogger.h index 0f9f6031..0e68008b 100644 --- a/XCDYouTubeKit/XCDYouTubeLogger.h +++ b/XCDYouTubeKit/XCDYouTubeLogger.h @@ -4,18 +4,100 @@ #import +/** + * The [context][1] used when logging with CocoaLumberjack. + * + * [1]: https://github.com/CocoaLumberjack/CocoaLumberjack/blob/master/Documentation/CustomContext.md + */ extern const NSInteger XCDYouTubeKitLumberjackContext; +/** + * The log levels, closely mirroring the log levels of CocoaLumberjack. + */ typedef NS_ENUM(NSUInteger, XCDLogLevel) { - XCDLogLevelError = 0, - XCDLogLevelWarning = 1, - XCDLogLevelInfo = 2, - XCDLogLevelDebug = 3, - XCDLogLevelVerbose = 4 + /** + * Used when an error is produced, e.g. when a `` finishes with an error. + */ + XCDLogLevelError = 0, + + /** + * Used on unusual conditions that may eventually lead to an error. + */ + XCDLogLevelWarning = 1, + + /** + * Used when logging normal operational information, e.g. when a `` starts, is cancelled or finishes. + */ + XCDLogLevelInfo = 2, + + /** + * Used throughout a `` for debugging purpose, e.g. for HTTP requests. + */ + XCDLogLevelDebug = 3, + + /** + * Used to report large amount of information, e.g. full HTTP responses. + */ + XCDLogLevelVerbose = 4, }; +/** + * You can use the `XCDYouTubeLogger` class to configure how the XCDYouTubeKit framework emits logs. + * + * By default, logs are emitted through CocoaLumberjack if it is available, i.e. if the `DDLog` class is found at runtime. + * The [context][1] used for CocoaLumberjack is the `XCDYouTubeKitLumberjackContext` constant whose value is `(NSInteger)0xced70676`. + * + * If CocoaLumberjack is not available, logs are emitted with `NSLog`, prefixed with the `[XCDYouTubeKit]` string. + * + * ## Controlling log levels + * + * If you are using CocoaLumberjack, you are responsible for controlling the log levels with the CocoaLumberjack APIs. + * + * If you are not using CocoaLumberjack, you can control the log levels with the `XCDYouTubeKitLogLevel` environment variable. See also the `` enum. + * + * Level | Value | Mask + * --------|-------|------ + * Error | 0 | 0x01 + * Warning | 1 | 0x02 + * Info | 2 | 0x04 + * Debug | 3 | 0x08 + * Verbose | 4 | 0x10 + * + * Use the corresponding bitmask to combine levels. For example, if you want to log *error*, *warning* and *info* levels, set the `XCDYouTubeKitLogLevel` environment variable to `0x7` (0x01 | 0x02 | 0x04). + * + * If you do not set the `XCDYouTubeKitLogLevel` environment variable, only warning and error levels are logged. + * + * [1]: https://github.com/CocoaLumberjack/CocoaLumberjack/blob/master/Documentation/CustomContext.md + */ @interface XCDYouTubeLogger : NSObject +/** + * ------------------- + * @name Custom Logger + * ------------------- + */ + +/** + * If you prefer not to use CocoaLumberjack and want something more advanced than the default `NSLog` implementation, you can use this method to write your own logger. + * + * @param logHandler The block called when a log is emitted by the XCDYouTubeKit framework. If you set the log handler to nil, logging will be completely disabled. + * + * @discussion Here is a description of the log handler parameters. + * + * - The `message` parameter is a block returning a string that you must call to evaluate the log message. + * - The `level` parameter is the log level of the message, see ``. + * - The `file` parameter is the full path of the file, captured with the `__FILE__` macro where the log is emitted. + * - The `function` parameter is the function name, captured with the `__PRETTY_FUNCTION__` macro where the log is emitted. + * - The `line` parameter is the line number, captured with the `__LINE__` macro where the log is emitted. + * + * Here is how you could implement a custom log handler with [NSLogger](https://github.com/fpillet/NSLogger): + * + * ``` + * [XCDYouTubeLogger setLogHandler:^(NSString * (^message)(void), XCDLogLevel level, const char *file, const char *function, NSUInteger line) { + * LogMessageRawF(file, (int)line, function, @"XCDYouTubeKit", (int)level, message()); + * }]; + * ``` + */ + (void) setLogHandler:(void (^)(NSString * (^message)(void), XCDLogLevel level, const char *file, const char *function, NSUInteger line))logHandler; @end From 6475510e3325b0e480e47206f96642ae98f71909 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ce=CC=81dric=20Luthi?= Date: Mon, 4 Jan 2016 14:47:08 +0100 Subject: [PATCH 11/18] Fix appledoc settings file --- XCDYouTubeKit/AppledocSettings.plist | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/XCDYouTubeKit/AppledocSettings.plist b/XCDYouTubeKit/AppledocSettings.plist index 61556bb9..52df4e30 100644 --- a/XCDYouTubeKit/AppledocSettings.plist +++ b/XCDYouTubeKit/AppledocSettings.plist @@ -8,8 +8,7 @@ --ignore - XCDYouTubeLogger.h - XCDYouTubeVideoOperation.m + *.m --index-desc README.md From da17d55306265ef9d2cd79c9e74dc536312f2d63 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ce=CC=81dric=20Luthi?= Date: Mon, 4 Jan 2016 21:31:34 +0100 Subject: [PATCH 12/18] Update copyrights --- LICENSE | 2 +- XCDYouTubeKit Demo/OS X Demo/AppDelegate.h | 2 +- XCDYouTubeKit Demo/OS X Demo/AppDelegate.m | 2 +- .../Supporting Files/XCDYouTubeKit OS X Demo-Info.plist | 2 +- XCDYouTubeKit Demo/OS X Demo/Supporting Files/main.m | 2 +- XCDYouTubeKit Demo/iOS Demo/AppDelegate.h | 2 +- XCDYouTubeKit Demo/iOS Demo/AppDelegate.m | 2 +- XCDYouTubeKit Demo/iOS Demo/ContextLogFormatter.h | 2 +- XCDYouTubeKit Demo/iOS Demo/ContextLogFormatter.m | 2 +- .../iOS Demo/DemoAsynchronousViewController.h | 2 +- .../iOS Demo/DemoAsynchronousViewController.m | 2 +- XCDYouTubeKit Demo/iOS Demo/DemoFullScreenViewController.h | 2 +- XCDYouTubeKit Demo/iOS Demo/DemoFullScreenViewController.m | 2 +- XCDYouTubeKit Demo/iOS Demo/DemoInlineViewController.h | 2 +- XCDYouTubeKit Demo/iOS Demo/DemoInlineViewController.m | 2 +- XCDYouTubeKit Demo/iOS Demo/DemoThumbnailViewController.h | 2 +- XCDYouTubeKit Demo/iOS Demo/DemoThumbnailViewController.m | 2 +- .../iOS Demo/MPMoviePlayerController+BackgroundPlayback.h | 2 +- .../iOS Demo/MPMoviePlayerController+BackgroundPlayback.m | 2 +- XCDYouTubeKit Demo/iOS Demo/NowPlayingInfoCenterProvider.h | 2 +- XCDYouTubeKit Demo/iOS Demo/NowPlayingInfoCenterProvider.m | 2 +- XCDYouTubeKit Demo/iOS Demo/PlayerEventLogger.h | 2 +- XCDYouTubeKit Demo/iOS Demo/PlayerEventLogger.m | 2 +- XCDYouTubeKit Demo/iOS Demo/SettingsViewController.h | 2 +- XCDYouTubeKit Demo/iOS Demo/SettingsViewController.m | 2 +- XCDYouTubeKit Demo/iOS Demo/Supporting Files/main.m | 2 +- XCDYouTubeKit Demo/iOS Demo/VideoPickerController.h | 6 +----- XCDYouTubeKit Demo/iOS Demo/VideoPickerController.m | 6 +----- XCDYouTubeKit Demo/tvOS Demo/AppDelegate.h | 2 +- XCDYouTubeKit Demo/tvOS Demo/AppDelegate.m | 2 +- XCDYouTubeKit Demo/tvOS Demo/GradientMaskView.h | 2 +- XCDYouTubeKit Demo/tvOS Demo/GradientMaskView.m | 2 +- .../tvOS Demo/PlaylistCollectionViewController.h | 2 +- .../tvOS Demo/PlaylistCollectionViewController.m | 2 +- XCDYouTubeKit Demo/tvOS Demo/Supporting Files/main.m | 2 +- XCDYouTubeKit Demo/tvOS Demo/VideoCell.h | 2 +- XCDYouTubeKit Demo/tvOS Demo/VideoCell.m | 2 +- XCDYouTubeKit Tests/XCDYouTubeClientTestCase.m | 2 +- XCDYouTubeKit Tests/XCDYouTubeKitTestCase.h | 2 +- XCDYouTubeKit Tests/XCDYouTubeKitTestCase.m | 2 +- XCDYouTubeKit Tests/XCDYouTubeProtectedVideosTestCase.m | 2 +- XCDYouTubeKit Tests/XCDYouTubeVideoOperationTestCase.m | 2 +- .../XCDYouTubeVideoPlayerViewControllerTestCase.m | 2 +- XCDYouTubeKit Tests/XCDYouTubeVideoTestCase.m | 2 +- XCDYouTubeKit Tests/XCTestWorkarounds.m | 2 +- XCDYouTubeKit/Info.plist | 2 +- XCDYouTubeKit/XCDYouTubeClient.h | 2 +- XCDYouTubeKit/XCDYouTubeClient.m | 2 +- XCDYouTubeKit/XCDYouTubeError.h | 2 +- XCDYouTubeKit/XCDYouTubeKit.h | 2 +- XCDYouTubeKit/XCDYouTubeLogger+Private.h | 2 +- XCDYouTubeKit/XCDYouTubeLogger.h | 2 +- XCDYouTubeKit/XCDYouTubeLogger.m | 2 +- XCDYouTubeKit/XCDYouTubeOperation.h | 2 +- XCDYouTubeKit/XCDYouTubePlayerScript.h | 2 +- XCDYouTubeKit/XCDYouTubePlayerScript.m | 2 +- XCDYouTubeKit/XCDYouTubeVideo+Private.h | 2 +- XCDYouTubeKit/XCDYouTubeVideo.h | 2 +- XCDYouTubeKit/XCDYouTubeVideo.m | 2 +- XCDYouTubeKit/XCDYouTubeVideoOperation.h | 2 +- XCDYouTubeKit/XCDYouTubeVideoOperation.m | 2 +- XCDYouTubeKit/XCDYouTubeVideoPlayerViewController.h | 2 +- XCDYouTubeKit/XCDYouTubeVideoPlayerViewController.m | 2 +- XCDYouTubeKit/XCDYouTubeVideoWebpage.h | 2 +- XCDYouTubeKit/XCDYouTubeVideoWebpage.m | 2 +- 65 files changed, 65 insertions(+), 73 deletions(-) diff --git a/LICENSE b/LICENSE index 37026f30..e21050fe 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ The MIT License (MIT) -Copyright (c) 2013-2015 Cédric Luthi +Copyright (c) 2013-2016 Cédric Luthi Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/XCDYouTubeKit Demo/OS X Demo/AppDelegate.h b/XCDYouTubeKit Demo/OS X Demo/AppDelegate.h index 5e2b7bad..7343b926 100644 --- a/XCDYouTubeKit Demo/OS X Demo/AppDelegate.h +++ b/XCDYouTubeKit Demo/OS X Demo/AppDelegate.h @@ -1,5 +1,5 @@ // -// Copyright (c) 2013-2015 Cédric Luthi. All rights reserved. +// Copyright (c) 2013-2016 Cédric Luthi. All rights reserved. // @import AppKit; diff --git a/XCDYouTubeKit Demo/OS X Demo/AppDelegate.m b/XCDYouTubeKit Demo/OS X Demo/AppDelegate.m index ea290d36..b6c257b5 100644 --- a/XCDYouTubeKit Demo/OS X Demo/AppDelegate.m +++ b/XCDYouTubeKit Demo/OS X Demo/AppDelegate.m @@ -1,5 +1,5 @@ // -// Copyright (c) 2013-2015 Cédric Luthi. All rights reserved. +// Copyright (c) 2013-2016 Cédric Luthi. All rights reserved. // #import "AppDelegate.h" diff --git a/XCDYouTubeKit Demo/OS X Demo/Supporting Files/XCDYouTubeKit OS X Demo-Info.plist b/XCDYouTubeKit Demo/OS X Demo/Supporting Files/XCDYouTubeKit OS X Demo-Info.plist index 65d76dcf..77f6b78b 100644 --- a/XCDYouTubeKit Demo/OS X Demo/Supporting Files/XCDYouTubeKit OS X Demo-Info.plist +++ b/XCDYouTubeKit Demo/OS X Demo/Supporting Files/XCDYouTubeKit OS X Demo-Info.plist @@ -25,7 +25,7 @@ LSMinimumSystemVersion $(MACOSX_DEPLOYMENT_TARGET) NSHumanReadableCopyright - Copyright © 2013-2015 Cédric Luthi. All rights reserved. + Copyright © 2013-2016 Cédric Luthi. All rights reserved. NSMainNibFile MainMenu NSPrincipalClass diff --git a/XCDYouTubeKit Demo/OS X Demo/Supporting Files/main.m b/XCDYouTubeKit Demo/OS X Demo/Supporting Files/main.m index 2f9a905b..ca1faf1c 100644 --- a/XCDYouTubeKit Demo/OS X Demo/Supporting Files/main.m +++ b/XCDYouTubeKit Demo/OS X Demo/Supporting Files/main.m @@ -1,5 +1,5 @@ // -// Copyright (c) 2013-2015 Cédric Luthi. All rights reserved. +// Copyright (c) 2013-2016 Cédric Luthi. All rights reserved. // @import AppKit; diff --git a/XCDYouTubeKit Demo/iOS Demo/AppDelegate.h b/XCDYouTubeKit Demo/iOS Demo/AppDelegate.h index d502e63a..bd6c2923 100644 --- a/XCDYouTubeKit Demo/iOS Demo/AppDelegate.h +++ b/XCDYouTubeKit Demo/iOS Demo/AppDelegate.h @@ -1,5 +1,5 @@ // -// Copyright (c) 2013-2015 Cédric Luthi. All rights reserved. +// Copyright (c) 2013-2016 Cédric Luthi. All rights reserved. // @import UIKit; diff --git a/XCDYouTubeKit Demo/iOS Demo/AppDelegate.m b/XCDYouTubeKit Demo/iOS Demo/AppDelegate.m index 341a5bd7..4451e322 100644 --- a/XCDYouTubeKit Demo/iOS Demo/AppDelegate.m +++ b/XCDYouTubeKit Demo/iOS Demo/AppDelegate.m @@ -1,5 +1,5 @@ // -// Copyright (c) 2013-2015 Cédric Luthi. All rights reserved. +// Copyright (c) 2013-2016 Cédric Luthi. All rights reserved. // #import "AppDelegate.h" diff --git a/XCDYouTubeKit Demo/iOS Demo/ContextLogFormatter.h b/XCDYouTubeKit Demo/iOS Demo/ContextLogFormatter.h index 8d97edbd..e4afe04d 100644 --- a/XCDYouTubeKit Demo/iOS Demo/ContextLogFormatter.h +++ b/XCDYouTubeKit Demo/iOS Demo/ContextLogFormatter.h @@ -1,5 +1,5 @@ // -// Copyright (c) 2013-2015 Cédric Luthi. All rights reserved. +// Copyright (c) 2013-2016 Cédric Luthi. All rights reserved. // @import Foundation; diff --git a/XCDYouTubeKit Demo/iOS Demo/ContextLogFormatter.m b/XCDYouTubeKit Demo/iOS Demo/ContextLogFormatter.m index eb800aa9..9204003c 100644 --- a/XCDYouTubeKit Demo/iOS Demo/ContextLogFormatter.m +++ b/XCDYouTubeKit Demo/iOS Demo/ContextLogFormatter.m @@ -1,5 +1,5 @@ // -// Copyright (c) 2013-2015 Cédric Luthi. All rights reserved. +// Copyright (c) 2013-2016 Cédric Luthi. All rights reserved. // #import "ContextLogFormatter.h" diff --git a/XCDYouTubeKit Demo/iOS Demo/DemoAsynchronousViewController.h b/XCDYouTubeKit Demo/iOS Demo/DemoAsynchronousViewController.h index ce0e504b..8f336b68 100644 --- a/XCDYouTubeKit Demo/iOS Demo/DemoAsynchronousViewController.h +++ b/XCDYouTubeKit Demo/iOS Demo/DemoAsynchronousViewController.h @@ -1,5 +1,5 @@ // -// Copyright (c) 2013-2015 Cédric Luthi. All rights reserved. +// Copyright (c) 2013-2016 Cédric Luthi. All rights reserved. // @import UIKit; diff --git a/XCDYouTubeKit Demo/iOS Demo/DemoAsynchronousViewController.m b/XCDYouTubeKit Demo/iOS Demo/DemoAsynchronousViewController.m index 4ee8b299..33f2989f 100644 --- a/XCDYouTubeKit Demo/iOS Demo/DemoAsynchronousViewController.m +++ b/XCDYouTubeKit Demo/iOS Demo/DemoAsynchronousViewController.m @@ -1,5 +1,5 @@ // -// Copyright (c) 2013-2015 Cédric Luthi. All rights reserved. +// Copyright (c) 2013-2016 Cédric Luthi. All rights reserved. // #import "DemoAsynchronousViewController.h" diff --git a/XCDYouTubeKit Demo/iOS Demo/DemoFullScreenViewController.h b/XCDYouTubeKit Demo/iOS Demo/DemoFullScreenViewController.h index 474f7b18..2085880d 100644 --- a/XCDYouTubeKit Demo/iOS Demo/DemoFullScreenViewController.h +++ b/XCDYouTubeKit Demo/iOS Demo/DemoFullScreenViewController.h @@ -1,5 +1,5 @@ // -// Copyright (c) 2013-2015 Cédric Luthi. All rights reserved. +// Copyright (c) 2013-2016 Cédric Luthi. All rights reserved. // @import UIKit; diff --git a/XCDYouTubeKit Demo/iOS Demo/DemoFullScreenViewController.m b/XCDYouTubeKit Demo/iOS Demo/DemoFullScreenViewController.m index 7662dfe7..92438df4 100644 --- a/XCDYouTubeKit Demo/iOS Demo/DemoFullScreenViewController.m +++ b/XCDYouTubeKit Demo/iOS Demo/DemoFullScreenViewController.m @@ -1,5 +1,5 @@ // -// Copyright (c) 2013-2015 Cédric Luthi. All rights reserved. +// Copyright (c) 2013-2016 Cédric Luthi. All rights reserved. // #import "DemoFullScreenViewController.h" diff --git a/XCDYouTubeKit Demo/iOS Demo/DemoInlineViewController.h b/XCDYouTubeKit Demo/iOS Demo/DemoInlineViewController.h index 0c3ff11e..cc4596bc 100644 --- a/XCDYouTubeKit Demo/iOS Demo/DemoInlineViewController.h +++ b/XCDYouTubeKit Demo/iOS Demo/DemoInlineViewController.h @@ -1,5 +1,5 @@ // -// Copyright (c) 2013-2015 Cédric Luthi. All rights reserved. +// Copyright (c) 2013-2016 Cédric Luthi. All rights reserved. // @import UIKit; diff --git a/XCDYouTubeKit Demo/iOS Demo/DemoInlineViewController.m b/XCDYouTubeKit Demo/iOS Demo/DemoInlineViewController.m index b62993bb..6c2d7e03 100644 --- a/XCDYouTubeKit Demo/iOS Demo/DemoInlineViewController.m +++ b/XCDYouTubeKit Demo/iOS Demo/DemoInlineViewController.m @@ -1,5 +1,5 @@ // -// Copyright (c) 2013-2015 Cédric Luthi. All rights reserved. +// Copyright (c) 2013-2016 Cédric Luthi. All rights reserved. // #import "DemoInlineViewController.h" diff --git a/XCDYouTubeKit Demo/iOS Demo/DemoThumbnailViewController.h b/XCDYouTubeKit Demo/iOS Demo/DemoThumbnailViewController.h index 3d9415f8..55255d05 100644 --- a/XCDYouTubeKit Demo/iOS Demo/DemoThumbnailViewController.h +++ b/XCDYouTubeKit Demo/iOS Demo/DemoThumbnailViewController.h @@ -1,5 +1,5 @@ // -// Copyright (c) 2013-2015 Cédric Luthi. All rights reserved. +// Copyright (c) 2013-2016 Cédric Luthi. All rights reserved. // @import UIKit; diff --git a/XCDYouTubeKit Demo/iOS Demo/DemoThumbnailViewController.m b/XCDYouTubeKit Demo/iOS Demo/DemoThumbnailViewController.m index ff0e154f..588d19d9 100644 --- a/XCDYouTubeKit Demo/iOS Demo/DemoThumbnailViewController.m +++ b/XCDYouTubeKit Demo/iOS Demo/DemoThumbnailViewController.m @@ -1,5 +1,5 @@ // -// Copyright (c) 2013-2015 Cédric Luthi. All rights reserved. +// Copyright (c) 2013-2016 Cédric Luthi. All rights reserved. // #import "DemoThumbnailViewController.h" diff --git a/XCDYouTubeKit Demo/iOS Demo/MPMoviePlayerController+BackgroundPlayback.h b/XCDYouTubeKit Demo/iOS Demo/MPMoviePlayerController+BackgroundPlayback.h index d99bc1c8..30c6b242 100644 --- a/XCDYouTubeKit Demo/iOS Demo/MPMoviePlayerController+BackgroundPlayback.h +++ b/XCDYouTubeKit Demo/iOS Demo/MPMoviePlayerController+BackgroundPlayback.h @@ -1,5 +1,5 @@ // -// Copyright (c) 2013-2015 Cédric Luthi. All rights reserved. +// Copyright (c) 2013-2016 Cédric Luthi. All rights reserved. // @import MediaPlayer; diff --git a/XCDYouTubeKit Demo/iOS Demo/MPMoviePlayerController+BackgroundPlayback.m b/XCDYouTubeKit Demo/iOS Demo/MPMoviePlayerController+BackgroundPlayback.m index bc241759..510d0fa3 100644 --- a/XCDYouTubeKit Demo/iOS Demo/MPMoviePlayerController+BackgroundPlayback.m +++ b/XCDYouTubeKit Demo/iOS Demo/MPMoviePlayerController+BackgroundPlayback.m @@ -1,5 +1,5 @@ // -// Copyright (c) 2013-2015 Cédric Luthi. All rights reserved. +// Copyright (c) 2013-2016 Cédric Luthi. All rights reserved. // #import "MPMoviePlayerController+BackgroundPlayback.h" diff --git a/XCDYouTubeKit Demo/iOS Demo/NowPlayingInfoCenterProvider.h b/XCDYouTubeKit Demo/iOS Demo/NowPlayingInfoCenterProvider.h index 1e034a00..9eefd65b 100644 --- a/XCDYouTubeKit Demo/iOS Demo/NowPlayingInfoCenterProvider.h +++ b/XCDYouTubeKit Demo/iOS Demo/NowPlayingInfoCenterProvider.h @@ -1,5 +1,5 @@ // -// Copyright (c) 2013-2015 Cédric Luthi. All rights reserved. +// Copyright (c) 2013-2016 Cédric Luthi. All rights reserved. // @import Foundation; diff --git a/XCDYouTubeKit Demo/iOS Demo/NowPlayingInfoCenterProvider.m b/XCDYouTubeKit Demo/iOS Demo/NowPlayingInfoCenterProvider.m index c2bab258..e4571697 100644 --- a/XCDYouTubeKit Demo/iOS Demo/NowPlayingInfoCenterProvider.m +++ b/XCDYouTubeKit Demo/iOS Demo/NowPlayingInfoCenterProvider.m @@ -1,5 +1,5 @@ // -// Copyright (c) 2013-2015 Cédric Luthi. All rights reserved. +// Copyright (c) 2013-2016 Cédric Luthi. All rights reserved. // #import "NowPlayingInfoCenterProvider.h" diff --git a/XCDYouTubeKit Demo/iOS Demo/PlayerEventLogger.h b/XCDYouTubeKit Demo/iOS Demo/PlayerEventLogger.h index ad1c5658..54805c27 100644 --- a/XCDYouTubeKit Demo/iOS Demo/PlayerEventLogger.h +++ b/XCDYouTubeKit Demo/iOS Demo/PlayerEventLogger.h @@ -1,5 +1,5 @@ // -// Copyright (c) 2013-2015 Cédric Luthi. All rights reserved. +// Copyright (c) 2013-2016 Cédric Luthi. All rights reserved. // @import Foundation; diff --git a/XCDYouTubeKit Demo/iOS Demo/PlayerEventLogger.m b/XCDYouTubeKit Demo/iOS Demo/PlayerEventLogger.m index 19e3170c..79e2f01f 100644 --- a/XCDYouTubeKit Demo/iOS Demo/PlayerEventLogger.m +++ b/XCDYouTubeKit Demo/iOS Demo/PlayerEventLogger.m @@ -1,5 +1,5 @@ // -// Copyright (c) 2013-2015 Cédric Luthi. All rights reserved. +// Copyright (c) 2013-2016 Cédric Luthi. All rights reserved. // #import "PlayerEventLogger.h" diff --git a/XCDYouTubeKit Demo/iOS Demo/SettingsViewController.h b/XCDYouTubeKit Demo/iOS Demo/SettingsViewController.h index 79943566..d9c5a1cc 100644 --- a/XCDYouTubeKit Demo/iOS Demo/SettingsViewController.h +++ b/XCDYouTubeKit Demo/iOS Demo/SettingsViewController.h @@ -1,5 +1,5 @@ // -// Copyright (c) 2013-2015 Cédric Luthi. All rights reserved. +// Copyright (c) 2013-2016 Cédric Luthi. All rights reserved. // @import UIKit; diff --git a/XCDYouTubeKit Demo/iOS Demo/SettingsViewController.m b/XCDYouTubeKit Demo/iOS Demo/SettingsViewController.m index 3948d8a1..a0234fe2 100644 --- a/XCDYouTubeKit Demo/iOS Demo/SettingsViewController.m +++ b/XCDYouTubeKit Demo/iOS Demo/SettingsViewController.m @@ -1,5 +1,5 @@ // -// Copyright (c) 2013-2015 Cédric Luthi. All rights reserved. +// Copyright (c) 2013-2016 Cédric Luthi. All rights reserved. // #import "SettingsViewController.h" diff --git a/XCDYouTubeKit Demo/iOS Demo/Supporting Files/main.m b/XCDYouTubeKit Demo/iOS Demo/Supporting Files/main.m index 56daa1ec..a22df77b 100644 --- a/XCDYouTubeKit Demo/iOS Demo/Supporting Files/main.m +++ b/XCDYouTubeKit Demo/iOS Demo/Supporting Files/main.m @@ -1,5 +1,5 @@ // -// Copyright (c) 2013-2015 Cédric Luthi. All rights reserved. +// Copyright (c) 2013-2016 Cédric Luthi. All rights reserved. // #import "AppDelegate.h" diff --git a/XCDYouTubeKit Demo/iOS Demo/VideoPickerController.h b/XCDYouTubeKit Demo/iOS Demo/VideoPickerController.h index 20bd9ea5..d6eb651e 100644 --- a/XCDYouTubeKit Demo/iOS Demo/VideoPickerController.h +++ b/XCDYouTubeKit Demo/iOS Demo/VideoPickerController.h @@ -1,9 +1,5 @@ // -// VideoPickerController.h -// XCDYouTubeKit Demo -// -// Created by Cédric Luthi on 20.01.15. -// Copyright (c) 2015 Cédric Luthi. All rights reserved. +// Copyright (c) 2013-2016 Cédric Luthi. All rights reserved. // @import UIKit; diff --git a/XCDYouTubeKit Demo/iOS Demo/VideoPickerController.m b/XCDYouTubeKit Demo/iOS Demo/VideoPickerController.m index 4af03b95..985c3186 100644 --- a/XCDYouTubeKit Demo/iOS Demo/VideoPickerController.m +++ b/XCDYouTubeKit Demo/iOS Demo/VideoPickerController.m @@ -1,9 +1,5 @@ // -// VideoPickerController.m -// XCDYouTubeKit Demo -// -// Created by Cédric Luthi on 20.01.15. -// Copyright (c) 2015 Cédric Luthi. All rights reserved. +// Copyright (c) 2013-2016 Cédric Luthi. All rights reserved. // #import "VideoPickerController.h" diff --git a/XCDYouTubeKit Demo/tvOS Demo/AppDelegate.h b/XCDYouTubeKit Demo/tvOS Demo/AppDelegate.h index bf2ea34e..91a58f24 100644 --- a/XCDYouTubeKit Demo/tvOS Demo/AppDelegate.h +++ b/XCDYouTubeKit Demo/tvOS Demo/AppDelegate.h @@ -1,5 +1,5 @@ // -// Copyright © 2015 Cédric Luthi. All rights reserved. +// Copyright © 2013-2016 Cédric Luthi. All rights reserved. // #import diff --git a/XCDYouTubeKit Demo/tvOS Demo/AppDelegate.m b/XCDYouTubeKit Demo/tvOS Demo/AppDelegate.m index 84b7a667..0741a34a 100644 --- a/XCDYouTubeKit Demo/tvOS Demo/AppDelegate.m +++ b/XCDYouTubeKit Demo/tvOS Demo/AppDelegate.m @@ -1,5 +1,5 @@ // -// Copyright © 2015 Cédric Luthi. All rights reserved. +// Copyright © 2013-2016 Cédric Luthi. All rights reserved. // #import "AppDelegate.h" diff --git a/XCDYouTubeKit Demo/tvOS Demo/GradientMaskView.h b/XCDYouTubeKit Demo/tvOS Demo/GradientMaskView.h index a0853eeb..60e65690 100644 --- a/XCDYouTubeKit Demo/tvOS Demo/GradientMaskView.h +++ b/XCDYouTubeKit Demo/tvOS Demo/GradientMaskView.h @@ -1,5 +1,5 @@ // -// Copyright © 2015 Cédric Luthi. All rights reserved. +// Copyright © 2013-2016 Cédric Luthi. All rights reserved. // #import diff --git a/XCDYouTubeKit Demo/tvOS Demo/GradientMaskView.m b/XCDYouTubeKit Demo/tvOS Demo/GradientMaskView.m index d540d630..a53696b8 100644 --- a/XCDYouTubeKit Demo/tvOS Demo/GradientMaskView.m +++ b/XCDYouTubeKit Demo/tvOS Demo/GradientMaskView.m @@ -1,5 +1,5 @@ // -// Copyright © 2015 Cédric Luthi. All rights reserved. +// Copyright © 2013-2016 Cédric Luthi. All rights reserved. // #import "GradientMaskView.h" diff --git a/XCDYouTubeKit Demo/tvOS Demo/PlaylistCollectionViewController.h b/XCDYouTubeKit Demo/tvOS Demo/PlaylistCollectionViewController.h index 8293a2b9..61816f87 100644 --- a/XCDYouTubeKit Demo/tvOS Demo/PlaylistCollectionViewController.h +++ b/XCDYouTubeKit Demo/tvOS Demo/PlaylistCollectionViewController.h @@ -1,5 +1,5 @@ // -// Copyright © 2015 Cédric Luthi. All rights reserved. +// Copyright © 2013-2016 Cédric Luthi. All rights reserved. // #import diff --git a/XCDYouTubeKit Demo/tvOS Demo/PlaylistCollectionViewController.m b/XCDYouTubeKit Demo/tvOS Demo/PlaylistCollectionViewController.m index 9af7bbe2..f59c939e 100644 --- a/XCDYouTubeKit Demo/tvOS Demo/PlaylistCollectionViewController.m +++ b/XCDYouTubeKit Demo/tvOS Demo/PlaylistCollectionViewController.m @@ -1,5 +1,5 @@ // -// Copyright © 2015 Cédric Luthi. All rights reserved. +// Copyright © 2013-2016 Cédric Luthi. All rights reserved. // #import "PlaylistCollectionViewController.h" diff --git a/XCDYouTubeKit Demo/tvOS Demo/Supporting Files/main.m b/XCDYouTubeKit Demo/tvOS Demo/Supporting Files/main.m index 9dea0cf3..7f023895 100644 --- a/XCDYouTubeKit Demo/tvOS Demo/Supporting Files/main.m +++ b/XCDYouTubeKit Demo/tvOS Demo/Supporting Files/main.m @@ -1,5 +1,5 @@ // -// Copyright © 2015 Cédric Luthi. All rights reserved. +// Copyright © 2013-2016 Cédric Luthi. All rights reserved. // #import diff --git a/XCDYouTubeKit Demo/tvOS Demo/VideoCell.h b/XCDYouTubeKit Demo/tvOS Demo/VideoCell.h index b97ecc16..6c48933e 100644 --- a/XCDYouTubeKit Demo/tvOS Demo/VideoCell.h +++ b/XCDYouTubeKit Demo/tvOS Demo/VideoCell.h @@ -1,5 +1,5 @@ // -// Copyright © 2015 Cédric Luthi. All rights reserved. +// Copyright © 2013-2016 Cédric Luthi. All rights reserved. // #import diff --git a/XCDYouTubeKit Demo/tvOS Demo/VideoCell.m b/XCDYouTubeKit Demo/tvOS Demo/VideoCell.m index bcdacc7c..080ef049 100644 --- a/XCDYouTubeKit Demo/tvOS Demo/VideoCell.m +++ b/XCDYouTubeKit Demo/tvOS Demo/VideoCell.m @@ -1,5 +1,5 @@ // -// Copyright © 2015 Cédric Luthi. All rights reserved. +// Copyright © 2013-2016 Cédric Luthi. All rights reserved. // #import "VideoCell.h" diff --git a/XCDYouTubeKit Tests/XCDYouTubeClientTestCase.m b/XCDYouTubeKit Tests/XCDYouTubeClientTestCase.m index 60281e41..973ea752 100644 --- a/XCDYouTubeKit Tests/XCDYouTubeClientTestCase.m +++ b/XCDYouTubeKit Tests/XCDYouTubeClientTestCase.m @@ -1,5 +1,5 @@ // -// Copyright (c) 2013-2015 Cédric Luthi. All rights reserved. +// Copyright (c) 2013-2016 Cédric Luthi. All rights reserved. // #import "XCDYouTubeKitTestCase.h" diff --git a/XCDYouTubeKit Tests/XCDYouTubeKitTestCase.h b/XCDYouTubeKit Tests/XCDYouTubeKitTestCase.h index 43f99069..e547ba21 100644 --- a/XCDYouTubeKit Tests/XCDYouTubeKitTestCase.h +++ b/XCDYouTubeKit Tests/XCDYouTubeKitTestCase.h @@ -1,5 +1,5 @@ // -// Copyright (c) 2013-2015 Cédric Luthi. All rights reserved. +// Copyright (c) 2013-2016 Cédric Luthi. All rights reserved. // #import diff --git a/XCDYouTubeKit Tests/XCDYouTubeKitTestCase.m b/XCDYouTubeKit Tests/XCDYouTubeKitTestCase.m index 56e20997..4dff2c3d 100644 --- a/XCDYouTubeKit Tests/XCDYouTubeKitTestCase.m +++ b/XCDYouTubeKit Tests/XCDYouTubeKitTestCase.m @@ -1,5 +1,5 @@ // -// Copyright (c) 2013-2015 Cédric Luthi. All rights reserved. +// Copyright (c) 2013-2016 Cédric Luthi. All rights reserved. // #import "XCDYouTubeKitTestCase.h" diff --git a/XCDYouTubeKit Tests/XCDYouTubeProtectedVideosTestCase.m b/XCDYouTubeKit Tests/XCDYouTubeProtectedVideosTestCase.m index 12ce4ed4..2904e0bc 100644 --- a/XCDYouTubeKit Tests/XCDYouTubeProtectedVideosTestCase.m +++ b/XCDYouTubeKit Tests/XCDYouTubeProtectedVideosTestCase.m @@ -1,5 +1,5 @@ // -// Copyright (c) 2013-2015 Cédric Luthi. All rights reserved. +// Copyright (c) 2013-2016 Cédric Luthi. All rights reserved. // #import "XCDYouTubeKitTestCase.h" diff --git a/XCDYouTubeKit Tests/XCDYouTubeVideoOperationTestCase.m b/XCDYouTubeKit Tests/XCDYouTubeVideoOperationTestCase.m index 034778d6..1290f5b3 100644 --- a/XCDYouTubeKit Tests/XCDYouTubeVideoOperationTestCase.m +++ b/XCDYouTubeKit Tests/XCDYouTubeVideoOperationTestCase.m @@ -1,5 +1,5 @@ // -// Copyright (c) 2013-2015 Cédric Luthi. All rights reserved. +// Copyright (c) 2013-2016 Cédric Luthi. All rights reserved. // #import "XCDYouTubeKitTestCase.h" diff --git a/XCDYouTubeKit Tests/XCDYouTubeVideoPlayerViewControllerTestCase.m b/XCDYouTubeKit Tests/XCDYouTubeVideoPlayerViewControllerTestCase.m index 00adde76..45fb2f7f 100644 --- a/XCDYouTubeKit Tests/XCDYouTubeVideoPlayerViewControllerTestCase.m +++ b/XCDYouTubeKit Tests/XCDYouTubeVideoPlayerViewControllerTestCase.m @@ -1,5 +1,5 @@ // -// Copyright (c) 2013-2015 Cédric Luthi. All rights reserved. +// Copyright (c) 2013-2016 Cédric Luthi. All rights reserved. // #import "XCDYouTubeKitTestCase.h" diff --git a/XCDYouTubeKit Tests/XCDYouTubeVideoTestCase.m b/XCDYouTubeKit Tests/XCDYouTubeVideoTestCase.m index 0f5092ff..307ee545 100644 --- a/XCDYouTubeKit Tests/XCDYouTubeVideoTestCase.m +++ b/XCDYouTubeKit Tests/XCDYouTubeVideoTestCase.m @@ -1,5 +1,5 @@ // -// Copyright (c) 2013-2015 Cédric Luthi. All rights reserved. +// Copyright (c) 2013-2016 Cédric Luthi. All rights reserved. // #import diff --git a/XCDYouTubeKit Tests/XCTestWorkarounds.m b/XCDYouTubeKit Tests/XCTestWorkarounds.m index 61394b88..3511aee1 100644 --- a/XCDYouTubeKit Tests/XCTestWorkarounds.m +++ b/XCDYouTubeKit Tests/XCTestWorkarounds.m @@ -1,5 +1,5 @@ // -// Copyright (c) 2013-2015 Cédric Luthi. All rights reserved. +// Copyright (c) 2013-2016 Cédric Luthi. All rights reserved. // // Explanation on http://stackoverflow.com/questions/30938525/xctest-exception-when-using-keyvalueobservingexpectationforobjectkeypathhandle diff --git a/XCDYouTubeKit/Info.plist b/XCDYouTubeKit/Info.plist index 5c3619e4..ddfdeab8 100644 --- a/XCDYouTubeKit/Info.plist +++ b/XCDYouTubeKit/Info.plist @@ -19,6 +19,6 @@ CFBundleVersion $(CURRENT_PROJECT_VERSION) NSHumanReadableCopyright - Copyright © 2013-2015 Cédric Luthi. All rights reserved. + Copyright © 2013-2016 Cédric Luthi. All rights reserved. diff --git a/XCDYouTubeKit/XCDYouTubeClient.h b/XCDYouTubeKit/XCDYouTubeClient.h index 00e67152..ee6b6247 100644 --- a/XCDYouTubeKit/XCDYouTubeClient.h +++ b/XCDYouTubeKit/XCDYouTubeClient.h @@ -1,5 +1,5 @@ // -// Copyright (c) 2013-2015 Cédric Luthi. All rights reserved. +// Copyright (c) 2013-2016 Cédric Luthi. All rights reserved. // #if !__has_feature(nullability) diff --git a/XCDYouTubeKit/XCDYouTubeClient.m b/XCDYouTubeKit/XCDYouTubeClient.m index 3a5a1bac..a9064b11 100644 --- a/XCDYouTubeKit/XCDYouTubeClient.m +++ b/XCDYouTubeKit/XCDYouTubeClient.m @@ -1,5 +1,5 @@ // -// Copyright (c) 2013-2015 Cédric Luthi. All rights reserved. +// Copyright (c) 2013-2016 Cédric Luthi. All rights reserved. // #import "XCDYouTubeClient.h" diff --git a/XCDYouTubeKit/XCDYouTubeError.h b/XCDYouTubeKit/XCDYouTubeError.h index a427513a..96c7ece2 100644 --- a/XCDYouTubeKit/XCDYouTubeError.h +++ b/XCDYouTubeKit/XCDYouTubeError.h @@ -1,5 +1,5 @@ // -// Copyright (c) 2013-2015 Cédric Luthi. All rights reserved. +// Copyright (c) 2013-2016 Cédric Luthi. All rights reserved. // #import diff --git a/XCDYouTubeKit/XCDYouTubeKit.h b/XCDYouTubeKit/XCDYouTubeKit.h index bba37f2a..250ef88f 100644 --- a/XCDYouTubeKit/XCDYouTubeKit.h +++ b/XCDYouTubeKit/XCDYouTubeKit.h @@ -1,5 +1,5 @@ // -// Copyright (c) 2013-2015 Cédric Luthi. All rights reserved. +// Copyright (c) 2013-2016 Cédric Luthi. All rights reserved. // #import diff --git a/XCDYouTubeKit/XCDYouTubeLogger+Private.h b/XCDYouTubeKit/XCDYouTubeLogger+Private.h index 871d1846..65612410 100644 --- a/XCDYouTubeKit/XCDYouTubeLogger+Private.h +++ b/XCDYouTubeKit/XCDYouTubeLogger+Private.h @@ -1,5 +1,5 @@ // -// Copyright (c) 2013-2015 Cédric Luthi. All rights reserved. +// Copyright (c) 2013-2016 Cédric Luthi. All rights reserved. // #import diff --git a/XCDYouTubeKit/XCDYouTubeLogger.h b/XCDYouTubeKit/XCDYouTubeLogger.h index 0e68008b..b5737ee6 100644 --- a/XCDYouTubeKit/XCDYouTubeLogger.h +++ b/XCDYouTubeKit/XCDYouTubeLogger.h @@ -1,5 +1,5 @@ // -// Copyright (c) 2013-2015 Cédric Luthi. All rights reserved. +// Copyright (c) 2013-2016 Cédric Luthi. All rights reserved. // #import diff --git a/XCDYouTubeKit/XCDYouTubeLogger.m b/XCDYouTubeKit/XCDYouTubeLogger.m index 60068aae..f4d2dcec 100644 --- a/XCDYouTubeKit/XCDYouTubeLogger.m +++ b/XCDYouTubeKit/XCDYouTubeLogger.m @@ -1,5 +1,5 @@ // -// Copyright (c) 2013-2015 Cédric Luthi. All rights reserved. +// Copyright (c) 2013-2016 Cédric Luthi. All rights reserved. // #import "XCDYouTubeLogger.h" diff --git a/XCDYouTubeKit/XCDYouTubeOperation.h b/XCDYouTubeKit/XCDYouTubeOperation.h index 46136fb9..0b425c4d 100644 --- a/XCDYouTubeKit/XCDYouTubeOperation.h +++ b/XCDYouTubeKit/XCDYouTubeOperation.h @@ -1,5 +1,5 @@ // -// Copyright (c) 2013-2015 Cédric Luthi. All rights reserved. +// Copyright (c) 2013-2016 Cédric Luthi. All rights reserved. // #import diff --git a/XCDYouTubeKit/XCDYouTubePlayerScript.h b/XCDYouTubeKit/XCDYouTubePlayerScript.h index ee247b12..5421a1cc 100644 --- a/XCDYouTubeKit/XCDYouTubePlayerScript.h +++ b/XCDYouTubeKit/XCDYouTubePlayerScript.h @@ -1,5 +1,5 @@ // -// Copyright (c) 2013-2015 Cédric Luthi. All rights reserved. +// Copyright (c) 2013-2016 Cédric Luthi. All rights reserved. // #import diff --git a/XCDYouTubeKit/XCDYouTubePlayerScript.m b/XCDYouTubeKit/XCDYouTubePlayerScript.m index 87ddf914..fcd57b2f 100644 --- a/XCDYouTubeKit/XCDYouTubePlayerScript.m +++ b/XCDYouTubeKit/XCDYouTubePlayerScript.m @@ -1,5 +1,5 @@ // -// Copyright (c) 2013-2015 Cédric Luthi. All rights reserved. +// Copyright (c) 2013-2016 Cédric Luthi. All rights reserved. // #import "XCDYouTubePlayerScript.h" diff --git a/XCDYouTubeKit/XCDYouTubeVideo+Private.h b/XCDYouTubeKit/XCDYouTubeVideo+Private.h index 6fb50285..3b50ea3c 100644 --- a/XCDYouTubeKit/XCDYouTubeVideo+Private.h +++ b/XCDYouTubeKit/XCDYouTubeVideo+Private.h @@ -1,5 +1,5 @@ // -// Copyright (c) 2013-2015 Cédric Luthi. All rights reserved. +// Copyright (c) 2013-2016 Cédric Luthi. All rights reserved. // #import diff --git a/XCDYouTubeKit/XCDYouTubeVideo.h b/XCDYouTubeKit/XCDYouTubeVideo.h index 8ab776e9..3a2b09fa 100644 --- a/XCDYouTubeKit/XCDYouTubeVideo.h +++ b/XCDYouTubeKit/XCDYouTubeVideo.h @@ -1,5 +1,5 @@ // -// Copyright (c) 2013-2015 Cédric Luthi. All rights reserved. +// Copyright (c) 2013-2016 Cédric Luthi. All rights reserved. // #if !__has_feature(nullability) diff --git a/XCDYouTubeKit/XCDYouTubeVideo.m b/XCDYouTubeKit/XCDYouTubeVideo.m index dd111955..b8200dc1 100644 --- a/XCDYouTubeKit/XCDYouTubeVideo.m +++ b/XCDYouTubeKit/XCDYouTubeVideo.m @@ -1,5 +1,5 @@ // -// Copyright (c) 2013-2015 Cédric Luthi. All rights reserved. +// Copyright (c) 2013-2016 Cédric Luthi. All rights reserved. // #import "XCDYouTubeVideo+Private.h" diff --git a/XCDYouTubeKit/XCDYouTubeVideoOperation.h b/XCDYouTubeKit/XCDYouTubeVideoOperation.h index b646202d..5f5f0366 100644 --- a/XCDYouTubeKit/XCDYouTubeVideoOperation.h +++ b/XCDYouTubeKit/XCDYouTubeVideoOperation.h @@ -1,5 +1,5 @@ // -// Copyright (c) 2013-2015 Cédric Luthi. All rights reserved. +// Copyright (c) 2013-2016 Cédric Luthi. All rights reserved. // #if !__has_feature(nullability) diff --git a/XCDYouTubeKit/XCDYouTubeVideoOperation.m b/XCDYouTubeKit/XCDYouTubeVideoOperation.m index e8c648ff..244336b9 100644 --- a/XCDYouTubeKit/XCDYouTubeVideoOperation.m +++ b/XCDYouTubeKit/XCDYouTubeVideoOperation.m @@ -1,5 +1,5 @@ // -// Copyright (c) 2013-2015 Cédric Luthi. All rights reserved. +// Copyright (c) 2013-2016 Cédric Luthi. All rights reserved. // #import "XCDYouTubeVideoOperation.h" diff --git a/XCDYouTubeKit/XCDYouTubeVideoPlayerViewController.h b/XCDYouTubeKit/XCDYouTubeVideoPlayerViewController.h index 62240973..a3f4493b 100644 --- a/XCDYouTubeKit/XCDYouTubeVideoPlayerViewController.h +++ b/XCDYouTubeKit/XCDYouTubeVideoPlayerViewController.h @@ -1,5 +1,5 @@ // -// Copyright (c) 2013-2015 Cédric Luthi. All rights reserved. +// Copyright (c) 2013-2016 Cédric Luthi. All rights reserved. // #if !__has_feature(nullability) diff --git a/XCDYouTubeKit/XCDYouTubeVideoPlayerViewController.m b/XCDYouTubeKit/XCDYouTubeVideoPlayerViewController.m index db7741bb..b34c5000 100644 --- a/XCDYouTubeKit/XCDYouTubeVideoPlayerViewController.m +++ b/XCDYouTubeKit/XCDYouTubeVideoPlayerViewController.m @@ -1,5 +1,5 @@ // -// Copyright (c) 2013-2015 Cédric Luthi. All rights reserved. +// Copyright (c) 2013-2016 Cédric Luthi. All rights reserved. // #import "XCDYouTubeVideoPlayerViewController.h" diff --git a/XCDYouTubeKit/XCDYouTubeVideoWebpage.h b/XCDYouTubeKit/XCDYouTubeVideoWebpage.h index 091c5861..53e6f4bc 100644 --- a/XCDYouTubeKit/XCDYouTubeVideoWebpage.h +++ b/XCDYouTubeKit/XCDYouTubeVideoWebpage.h @@ -1,5 +1,5 @@ // -// Copyright (c) 2013-2015 Cédric Luthi. All rights reserved. +// Copyright (c) 2013-2016 Cédric Luthi. All rights reserved. // #import diff --git a/XCDYouTubeKit/XCDYouTubeVideoWebpage.m b/XCDYouTubeKit/XCDYouTubeVideoWebpage.m index c6fc9f8d..89459679 100644 --- a/XCDYouTubeKit/XCDYouTubeVideoWebpage.m +++ b/XCDYouTubeKit/XCDYouTubeVideoWebpage.m @@ -1,5 +1,5 @@ // -// Copyright (c) 2013-2015 Cédric Luthi. All rights reserved. +// Copyright (c) 2013-2016 Cédric Luthi. All rights reserved. // #import "XCDYouTubeVideoWebpage.h" From 3c2f444cfed7af5664e6270d4dfb3b192d4c689b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ce=CC=81dric=20Luthi?= Date: Mon, 4 Jan 2016 22:09:35 +0100 Subject: [PATCH 13/18] Encourage to use ~> Major.Minor for semantic versioning XCDYouTubeKit adheres to semantic versioning so using ~> Major.Minor instead of ~> Major.Minor.Patch will ease adopting new non-breaking versions. --- Scripts/release.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Scripts/release.sh b/Scripts/release.sh index 908b1b2f..7541586e 100755 --- a/Scripts/release.sh +++ b/Scripts/release.sh @@ -17,6 +17,7 @@ if [[ $# -ne 1 ]]; then fi VERSION=$1 +VERSION_PARTS=(${VERSION//./ }) git flow release start ${VERSION} @@ -28,7 +29,7 @@ sed -i "" "s/DYLIB_CURRENT_VERSION = .*;/DYLIB_CURRENT_VERSION = ${VERSION};/g" sed -i "" "s/CURRENT_PROJECT_VERSION = .*;/CURRENT_PROJECT_VERSION = ${CURRENT_PROJECT_VERSION};/g" "XCDYouTubeKit.xcodeproj/project.pbxproj" sed -i "" "s/CURRENT_PROJECT_VERSION = .*;/CURRENT_PROJECT_VERSION = ${VERSION};/g" "XCDYouTubeKit Demo/XCDYouTubeKit Demo.xcodeproj/project.pbxproj" sed -i "" "s/^\(.*s.version.*=.*\)\".*\"/\1\"${VERSION}\"/" "XCDYouTubeKit.podspec" -sed -E -i "" "s/~> [0-9\.]+/~> ${VERSION}/g" "README.md" +sed -E -i "" "s/~> [0-9\.]+/~> ${VERSION_PARTS[0]}.${VERSION_PARTS[1]}/g" "README.md" set +v git add "XCDYouTubeKit.xcodeproj" git add "XCDYouTubeKit Demo/XCDYouTubeKit Demo.xcodeproj" From fad86afe5878c979639b2e42e5e4b95f405e98c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ce=CC=81dric=20Luthi?= Date: Tue, 5 Jan 2016 00:24:00 +0100 Subject: [PATCH 14/18] Add CHANGELOG entry for version 2.5.0 --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 841b5599..80ad9f09 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +#### Version 2.5.0 + +* Logging is fully configurable with the new `XCDYouTubeLogger` class. + #### Version 2.4.3 * Fixed *XCDYouTubeKit iOS Framework* deployment target. (#223) From e31f5f50a0626c274b5b4892e7f2c4b724b9a762 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ce=CC=81dric=20Luthi?= Date: Wed, 6 Jan 2016 00:06:30 +0100 Subject: [PATCH 15/18] Add new userInfo key for better diagnosis of some unplayable videos Fixes #216 --- CHANGELOG.md | 1 + .../XCDYouTubeClientTestCase.m | 1 + XCDYouTubeKit/XCDYouTubeError.h | 6 +++++ XCDYouTubeKit/XCDYouTubeVideo.m | 1 + XCDYouTubeKit/XCDYouTubeVideoOperation.m | 23 ++++++++++++++++++- XCDYouTubeKit/XCDYouTubeVideoWebpage.h | 1 + XCDYouTubeKit/XCDYouTubeVideoWebpage.m | 18 +++++++++++++++ 7 files changed, 50 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 80ad9f09..b632a6b5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ #### Version 2.5.0 * Logging is fully configurable with the new `XCDYouTubeLogger` class. +* Added `XCDYouTubeAllowedCountriesUserInfoKey` for better diagnosis of some unplayable (geoblocked) videos. (#216) #### Version 2.4.3 diff --git a/XCDYouTubeKit Tests/XCDYouTubeClientTestCase.m b/XCDYouTubeKit Tests/XCDYouTubeClientTestCase.m index 973ea752..00e78b83 100644 --- a/XCDYouTubeKit Tests/XCDYouTubeClientTestCase.m +++ b/XCDYouTubeKit Tests/XCDYouTubeClientTestCase.m @@ -136,6 +136,7 @@ - (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:@[ @"Mexico" ]]); [expectation fulfill]; }]; [self waitForExpectationsWithTimeout:5 handler:nil]; diff --git a/XCDYouTubeKit/XCDYouTubeError.h b/XCDYouTubeKit/XCDYouTubeError.h index 96c7ece2..92ffe38e 100644 --- a/XCDYouTubeKit/XCDYouTubeError.h +++ b/XCDYouTubeKit/XCDYouTubeError.h @@ -9,6 +9,12 @@ */ extern NSString *const XCDYouTubeVideoErrorDomain; +/** + * A key that may be present in the error's userInfo dictionary when the error code is XCDYouTubeErrorRestrictedPlayback. + * The object for that key is a NSSet instance containing localized country names. + */ +extern NSString *const XCDYouTubeAllowedCountriesUserInfoKey; + /** * These values are returned as the error code property of an NSError object with the domain `XCDYouTubeVideoErrorDomain`. */ diff --git a/XCDYouTubeKit/XCDYouTubeVideo.m b/XCDYouTubeKit/XCDYouTubeVideo.m index b8200dc1..2fca78a3 100644 --- a/XCDYouTubeKit/XCDYouTubeVideo.m +++ b/XCDYouTubeKit/XCDYouTubeVideo.m @@ -9,6 +9,7 @@ #import NSString *const XCDYouTubeVideoErrorDomain = @"XCDYouTubeVideoErrorDomain"; +NSString *const XCDYouTubeAllowedCountriesUserInfoKey = @"AllowedCountries"; NSString *const XCDYouTubeNoStreamVideoUserInfoKey = @"NoStreamVideo"; NSString *const XCDYouTubeVideoQualityHTTPLiveStreaming = @"HTTPLiveStreaming"; diff --git a/XCDYouTubeKit/XCDYouTubeVideoOperation.m b/XCDYouTubeKit/XCDYouTubeVideoOperation.m index 244336b9..cd4a112d 100644 --- a/XCDYouTubeKit/XCDYouTubeVideoOperation.m +++ b/XCDYouTubeKit/XCDYouTubeVideoOperation.m @@ -46,6 +46,27 @@ @interface XCDYouTubeVideoOperation () @implementation XCDYouTubeVideoOperation +static NSError *YouTubeError(NSError *error, NSSet *regionsAllowed, NSString *languageIdentifier) +{ + if (error.code == XCDYouTubeErrorRestrictedPlayback && regionsAllowed.count > 0) + { + NSLocale *locale = [NSLocale localeWithLocaleIdentifier:languageIdentifier]; + NSMutableSet *allowedCountries = [NSMutableSet new]; + for (NSString *countryCode in regionsAllowed) + { + NSString *country = [locale displayNameForKey:NSLocaleCountryCode value:countryCode]; + [allowedCountries addObject:country ?: countryCode]; + } + NSMutableDictionary *userInfo = [NSMutableDictionary dictionaryWithDictionary:error.userInfo]; + userInfo[XCDYouTubeAllowedCountriesUserInfoKey] = [allowedCountries copy]; + return [NSError errorWithDomain:error.domain code:error.code userInfo:[userInfo copy]]; + } + else + { + return error; + } +} + - (instancetype) init { @throw [NSException exceptionWithName:NSGenericException reason:@"Use the `initWithVideoIdentifier:languageIdentifier:` method instead." userInfo:nil]; @@ -192,7 +213,7 @@ - (void) handleVideoInfoResponseWithInfo:(NSDictionary *)info response:(NSURLRes { self.lastError = error; if (error.code > 0) - self.youTubeError = error; + self.youTubeError = YouTubeError(error, self.webpage.regionsAllowed, self.languageIdentifier); [self startNextRequest]; } diff --git a/XCDYouTubeKit/XCDYouTubeVideoWebpage.h b/XCDYouTubeKit/XCDYouTubeVideoWebpage.h index 53e6f4bc..750cfdc7 100644 --- a/XCDYouTubeKit/XCDYouTubeVideoWebpage.h +++ b/XCDYouTubeKit/XCDYouTubeVideoWebpage.h @@ -13,5 +13,6 @@ __attribute__((visibility("hidden"))) @property (nonatomic, readonly) NSDictionary *videoInfo; @property (nonatomic, readonly) NSURL *javaScriptPlayerURL; @property (nonatomic, readonly) BOOL isAgeRestricted; +@property (nonatomic, readonly) NSSet *regionsAllowed; @end diff --git a/XCDYouTubeKit/XCDYouTubeVideoWebpage.m b/XCDYouTubeKit/XCDYouTubeVideoWebpage.m index 89459679..1608b3de 100644 --- a/XCDYouTubeKit/XCDYouTubeVideoWebpage.m +++ b/XCDYouTubeKit/XCDYouTubeVideoWebpage.m @@ -14,6 +14,7 @@ @implementation XCDYouTubeVideoWebpage @synthesize videoInfo = _videoInfo; @synthesize javaScriptPlayerURL = _javaScriptPlayerURL; @synthesize isAgeRestricted = _isAgeRestricted; +@synthesize regionsAllowed = _regionsAllowed; - (instancetype) initWithHTMLString:(NSString *)html { @@ -101,4 +102,21 @@ - (BOOL) isAgeRestricted return _isAgeRestricted; } +- (NSSet *) regionsAllowed +{ + if (!_regionsAllowed) + { + _regionsAllowed = [NSSet set]; + NSRegularExpression *regionsAllowedRegularExpression = [NSRegularExpression regularExpressionWithPattern:@"meta\\s+itemprop=\"regionsAllowed\"\\s+content=\"(.*)\"" options:(NSRegularExpressionOptions)0 error:NULL]; + NSTextCheckingResult *regionsAllowedResult = [regionsAllowedRegularExpression firstMatchInString:self.html options:(NSMatchingOptions)0 range:NSMakeRange(0, self.html.length)]; + if (regionsAllowedResult.numberOfRanges > 1) + { + NSString *regionsAllowed = [self.html substringWithRange:[regionsAllowedResult rangeAtIndex:1]]; + if (regionsAllowed.length > 0) + _regionsAllowed = [NSSet setWithArray:[regionsAllowed componentsSeparatedByString:@","]]; + } + } + return _regionsAllowed; +} + @end From 859e3e7bb8c33ff39836137c469b35da5bed02af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ce=CC=81dric=20Luthi?= Date: Wed, 6 Jan 2016 00:29:35 +0100 Subject: [PATCH 16/18] Do not test on iOS 8.2, 8.3 and 9.1 on Travis --- .travis.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 3552e40a..6deb8c08 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,11 +4,8 @@ env: matrix: - 'DESTINATION="platform=iOS Simulator,name=iPhone 5s" CONFIGURATION="Code Coverage" SCHEME="XCDYouTubeKit iOS Static Library" OBJROOT="build"' - 'DESTINATION="platform=iOS Simulator,name=iPhone 5s,OS=8.1" CONFIGURATION="Release" SCHEME="XCDYouTubeKit iOS Static Library"' - - 'DESTINATION="platform=iOS Simulator,name=iPhone 5s,OS=8.2" CONFIGURATION="Release" SCHEME="XCDYouTubeKit iOS Static Library"' - - 'DESTINATION="platform=iOS Simulator,name=iPhone 5s,OS=8.3" CONFIGURATION="Release" SCHEME="XCDYouTubeKit iOS Static Library"' - 'DESTINATION="platform=iOS Simulator,name=iPhone 5s,OS=8.4" CONFIGURATION="Release" SCHEME="XCDYouTubeKit iOS Static Library"' - 'DESTINATION="platform=iOS Simulator,name=iPhone 5s,OS=9.0" CONFIGURATION="Release" SCHEME="XCDYouTubeKit iOS Static Library"' - - 'DESTINATION="platform=iOS Simulator,name=iPhone 5s,OS=9.1" CONFIGURATION="Release" SCHEME="XCDYouTubeKit iOS Static Library"' - 'DESTINATION="platform=iOS Simulator,name=iPhone 5s,OS=9.2" CONFIGURATION="Release" SCHEME="XCDYouTubeKit iOS Static Library"' - 'DESTINATION="platform=iOS Simulator,name=iPhone 5s,OS=9.2" CONFIGURATION="Release" SCHEME="XCDYouTubeKit iOS Static Library" IPHONEOS_DEPLOYMENT_TARGET="9.2"' - 'DESTINATION="platform=iOS Simulator,name=iPhone 4s" CONFIGURATION="Release" SCHEME="XCDYouTubeKit iOS Static Library" RUN_CLANG_STATIC_ANALYZER="YES"' From 70579a6983f385ff136bb47a97270c8dbe1bc7b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ce=CC=81dric=20Luthi?= Date: Wed, 6 Jan 2016 00:51:57 +0100 Subject: [PATCH 17/18] Update version to 2.5.0 --- README.md | 4 ++-- .../XCDYouTubeKit Demo.xcodeproj/project.pbxproj | 4 ++-- XCDYouTubeKit.podspec | 2 +- XCDYouTubeKit.xcodeproj/project.pbxproj | 12 ++++++------ 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 02809d0d..48c69a0b 100644 --- a/README.md +++ b/README.md @@ -31,13 +31,13 @@ XCDYouTubeKit is available through CocoaPods and Carthage. CocoaPods: ```ruby -pod "XCDYouTubeKit", "~> 2.4.3" +pod "XCDYouTubeKit", "~> 2.5" ``` Carthage: ```objc -github "0xced/XCDYouTubeKit" ~> 2.4.3 +github "0xced/XCDYouTubeKit" ~> 2.5 ``` 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: diff --git a/XCDYouTubeKit Demo/XCDYouTubeKit Demo.xcodeproj/project.pbxproj b/XCDYouTubeKit Demo/XCDYouTubeKit Demo.xcodeproj/project.pbxproj index 58b33e18..c273c242 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.4.3; + CURRENT_PROJECT_VERSION = 2.5.0; 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.4.3; + CURRENT_PROJECT_VERSION = 2.5.0; ENABLE_STRICT_OBJC_MSGSEND = YES; GCC_C_LANGUAGE_STANDARD = gnu99; GCC_NO_COMMON_BLOCKS = YES; diff --git a/XCDYouTubeKit.podspec b/XCDYouTubeKit.podspec index 4ec7eb49..023ba945 100644 --- a/XCDYouTubeKit.podspec +++ b/XCDYouTubeKit.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = "XCDYouTubeKit" - s.version = "2.4.3" + s.version = "2.5.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" diff --git a/XCDYouTubeKit.xcodeproj/project.pbxproj b/XCDYouTubeKit.xcodeproj/project.pbxproj index e49fdf23..419e847f 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 = 21; + CURRENT_PROJECT_VERSION = 22; DEFINES_MODULE = YES; DYLIB_COMPATIBILITY_VERSION = 2.0.0; - DYLIB_CURRENT_VERSION = 2.4.3; + DYLIB_CURRENT_VERSION = 2.5.0; 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 = 21; + CURRENT_PROJECT_VERSION = 22; DEFINES_MODULE = YES; DYLIB_COMPATIBILITY_VERSION = 2.0.0; - DYLIB_CURRENT_VERSION = 2.4.3; + DYLIB_CURRENT_VERSION = 2.5.0; 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 = 21; + CURRENT_PROJECT_VERSION = 22; DEFINES_MODULE = YES; DYLIB_COMPATIBILITY_VERSION = 2.0.0; - DYLIB_CURRENT_VERSION = 2.4.3; + DYLIB_CURRENT_VERSION = 2.5.0; DYLIB_INSTALL_NAME_BASE = "@rpath"; ENABLE_STRICT_OBJC_MSGSEND = YES; ENABLE_TESTABILITY = YES; From eee525bcc46f000d9f2d71a0763e21fdb076ffb1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ce=CC=81dric=20Luthi?= Date: Wed, 6 Jan 2016 00:51:57 +0100 Subject: [PATCH 18/18] Point badges to the master branch --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 48c69a0b..ea1fddfe 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ ## About -[![Build Status](https://img.shields.io/travis/0xced/XCDYouTubeKit/develop.svg?style=flat)](https://travis-ci.org/0xced/XCDYouTubeKit) -[![Coverage Status](https://img.shields.io/coveralls/0xced/XCDYouTubeKit/develop.svg?style=flat)](https://coveralls.io/r/0xced/XCDYouTubeKit?branch=develop) +[![Build Status](https://img.shields.io/travis/0xced/XCDYouTubeKit/master.svg?style=flat)](https://travis-ci.org/0xced/XCDYouTubeKit) +[![Coverage Status](https://img.shields.io/coveralls/0xced/XCDYouTubeKit/master.svg?style=flat)](https://coveralls.io/r/0xced/XCDYouTubeKit?branch=master) [![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/)