diff --git a/.travis.yml b/.travis.yml
index 3552e40ab..6deb8c088 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"'
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 841b5599a..b632a6b5d 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,8 @@
+#### 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
* Fixed *XCDYouTubeKit iOS Framework* deployment target. (#223)
diff --git a/LICENSE b/LICENSE
index 37026f305..e21050fe2 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/README.md b/README.md
index 0f28fb7f5..ea1fddfec 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:
@@ -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/Scripts/release.sh b/Scripts/release.sh
index 908b1b2f3..7541586eb 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"
diff --git a/Scripts/run-tests.sh b/Scripts/run-tests.sh
index c2c5f1126..e8760d1ab 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" && [ "${TRAVIS}" == "true" ] && xcpretty-travis-formatter > /dev/null 2>&1 && COMMAND+=" -f `xcpretty-travis-formatter`"
set -x
eval "${COMMAND}" && rm xcodebuild.log
diff --git a/XCDYouTubeKit Demo/OS X Demo/AppDelegate.h b/XCDYouTubeKit Demo/OS X Demo/AppDelegate.h
index 5e2b7bad9..7343b9264 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 ea290d36b..b6c257b55 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 65d76dcfb..77f6b78b8 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 2f9a905b3..ca1faf1c2 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/XCDYouTubeKit Demo.xcodeproj/project.pbxproj b/XCDYouTubeKit Demo/XCDYouTubeKit Demo.xcodeproj/project.pbxproj
index 58b33e186..c273c2422 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 Demo/iOS Demo/AppDelegate.h b/XCDYouTubeKit Demo/iOS Demo/AppDelegate.h
index d502e63a9..bd6c2923b 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 f35390d97..4451e322e 100644
--- a/XCDYouTubeKit Demo/iOS Demo/AppDelegate.m
+++ b/XCDYouTubeKit Demo/iOS Demo/AppDelegate.m
@@ -1,11 +1,12 @@
//
-// Copyright (c) 2013-2015 Cédric Luthi. All rights reserved.
+// Copyright (c) 2013-2016 Cédric Luthi. All rights reserved.
//
#import "AppDelegate.h"
@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 Demo/iOS Demo/ContextLogFormatter.h b/XCDYouTubeKit Demo/iOS Demo/ContextLogFormatter.h
index 8d97edbd3..e4afe04d3 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 eb800aa90..9204003cb 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 ce0e504b7..8f336b686 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 4ee8b2996..33f2989f9 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 474f7b183..2085880d4 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 7662dfe77..92438df4d 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 0c3ff11ec..cc4596bc8 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 b62993bbb..6c2d7e03a 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 3d9415f81..55255d053 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 ff0e154f7..588d19d9b 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 d99bc1c8e..30c6b2424 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 bc2417594..510d0fa35 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 1e034a00b..9eefd65b5 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 c2bab258e..e45716976 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 ad1c56582..54805c278 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 19e3170ca..79e2f01fd 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 799435668..d9c5a1ccc 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 3948d8a1c..a0234fe2f 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 56daa1ece..a22df77b0 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 20bd9ea58..d6eb651e6 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 4af03b95a..985c3186f 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 bf2ea34ec..91a58f245 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 84b7a667e..0741a34a3 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 a0853eebb..60e656900 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 d540d6309..a53696b83 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 8293a2b91..61816f87b 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 9af7bbe22..f59c939ed 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 9dea0cf31..7f0238956 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 b97ecc168..6c48933ef 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 bcdacc7cb..080ef0491 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 60281e414..00e78b836 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"
@@ -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 Tests/XCDYouTubeKitTestCase.h b/XCDYouTubeKit Tests/XCDYouTubeKitTestCase.h
index 43f990698..e547ba21b 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 56e209978..4dff2c3df 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 12ce4ed42..2904e0bcb 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 034778d6f..1290f5b3f 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 00adde769..45fb2f7f2 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 0f5092ff3..307ee545a 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 61394b88f..3511aee11 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.podspec b/XCDYouTubeKit.podspec
index 34cd15a7a..023ba9454 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"
@@ -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 8afd22972..419e847f1 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 */,
@@ -1141,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;
@@ -1207,11 +1223,12 @@
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;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_NO_COMMON_BLOCKS = YES;
@@ -1279,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;
diff --git a/XCDYouTubeKit/AppledocSettings.plist b/XCDYouTubeKit/AppledocSettings.plist
index 61556bb93..52df4e309 100644
--- a/XCDYouTubeKit/AppledocSettings.plist
+++ b/XCDYouTubeKit/AppledocSettings.plist
@@ -8,8 +8,7 @@
--ignore
- XCDYouTubeLogger.h
- XCDYouTubeVideoOperation.m
+ *.m
--index-desc
README.md
diff --git a/XCDYouTubeKit/Info.plist b/XCDYouTubeKit/Info.plist
index 5c3619e41..ddfdeab83 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 00e671529..ee6b62476 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 3a5a1bac6..a9064b117 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 a427513ad..92ffe38e5 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
@@ -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/XCDYouTubeKit.h b/XCDYouTubeKit/XCDYouTubeKit.h
index dea9034dc..250ef88f2 100644
--- a/XCDYouTubeKit/XCDYouTubeKit.h
+++ b/XCDYouTubeKit/XCDYouTubeKit.h
@@ -1,11 +1,12 @@
//
-// Copyright (c) 2013-2015 Cédric Luthi. All rights reserved.
+// Copyright (c) 2013-2016 Cédric Luthi. All rights reserved.
//
#import
#import
#import
+#import
#import
#import
#import
diff --git a/XCDYouTubeKit/XCDYouTubeLogger+Private.h b/XCDYouTubeKit/XCDYouTubeLogger+Private.h
new file mode 100644
index 000000000..65612410a
--- /dev/null
+++ b/XCDYouTubeKit/XCDYouTubeLogger+Private.h
@@ -0,0 +1,21 @@
+//
+// Copyright (c) 2013-2016 Cédric Luthi. All rights reserved.
+//
+
+#import
+
+#import "XCDYouTubeLogger.h"
+
+@interface XCDYouTubeLogger ()
+
++ (void) logMessage:(NSString * (^)(void))message level:(XCDLogLevel)level file:(const char *)file function:(const char *)function line:(NSUInteger)line;
+
+@end
+
+#define XCDYouTubeLog(_level, _message) [XCDYouTubeLogger logMessage:(_message) level:(_level) file:__FILE__ function:__PRETTY_FUNCTION__ line:__LINE__]
+
+#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__]; }))
diff --git a/XCDYouTubeKit/XCDYouTubeLogger.h b/XCDYouTubeKit/XCDYouTubeLogger.h
index ab3a9045b..b5737ee6e 100644
--- a/XCDYouTubeKit/XCDYouTubeLogger.h
+++ b/XCDYouTubeKit/XCDYouTubeLogger.h
@@ -1,29 +1,103 @@
//
-// Copyright (c) 2013-2015 Cédric Luthi. All rights reserved.
+// Copyright (c) 2013-2016 Cédric Luthi. All rights reserved.
//
#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)
+/**
+ * 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) {
+ /**
+ * 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,
};
-__attribute__((visibility("hidden")))
+/**
+ * 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
-+ (void) logMessage:(NSString * (^)(void))message flag:(DDLogFlag)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__]
+/**
+ * -------------------
+ * @name Custom Logger
+ * -------------------
+ */
-#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__]; }))
+/**
+ * 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
diff --git a/XCDYouTubeKit/XCDYouTubeLogger.m b/XCDYouTubeKit/XCDYouTubeLogger.m
index ce22ede68..f4d2dcecf 100644
--- a/XCDYouTubeKit/XCDYouTubeLogger.m
+++ b/XCDYouTubeKit/XCDYouTubeLogger.m
@@ -1,32 +1,67 @@
//
-// Copyright (c) 2013-2015 Cédric Luthi. All rights reserved.
+// Copyright (c) 2013-2016 Cédric Luthi. All rights reserved.
//
#import "XCDYouTubeLogger.h"
+#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:(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), XCDLogLevel, const char *, const char *, NSUInteger) = ^(NSString *(^message)(void), XCDLogLevel level, const char *file, const char *function, NSUInteger line)
+{
+ char *logLevelString = getenv("XCDYouTubeKitLogLevel");
+ NSUInteger logLevelMask = logLevelString ? strtoul(logLevelString, NULL, 0) : (1 << XCDLogLevelError) | (1 << XCDLogLevelWarning);
+ if ((1 << level) & logLevelMask)
+ NSLog(@"[XCDYouTubeKit] %@", message());
+};
+
+static Class DDLogClass = Nil;
+
+static void (^const CocoaLumberjackLogHandler)(NSString * (^)(void), XCDLogLevel, const char *, const char *, NSUInteger) = ^(NSString *(^message)(void), XCDLogLevel level, const char *file, const char *function, NSUInteger line)
+{
+ // 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), XCDLogLevel, const char *, const char *, NSUInteger);
+
@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))
- return;
+ static dispatch_once_t once;
+ dispatch_once(&once, ^{
+ LogHandler = DefaultLogHandler;
- NSLog(@"[XCDYouTubeKit] %@", message());
- }
+ 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) setLogHandler:(void (^)(NSString * (^message)(void), XCDLogLevel level, const char *file, const char *function, NSUInteger line))logHandler
+{
+ LogHandler = logHandler;
+}
+
++ (void) logMessage:(NSString * (^)(void))message level:(XCDLogLevel)level file:(const char *)file function:(const char *)function line:(NSUInteger)line
+{
+ if (LogHandler)
+ LogHandler(message, level, file, function, line);
}
@end
diff --git a/XCDYouTubeKit/XCDYouTubeOperation.h b/XCDYouTubeKit/XCDYouTubeOperation.h
index 46136fb96..0b425c4df 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 ee247b123..5421a1cc6 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 1ac21c46e..fcd57b2ff 100644
--- a/XCDYouTubeKit/XCDYouTubePlayerScript.m
+++ b/XCDYouTubeKit/XCDYouTubePlayerScript.m
@@ -1,12 +1,12 @@
//
-// Copyright (c) 2013-2015 Cédric Luthi. All rights reserved.
+// Copyright (c) 2013-2016 Cédric Luthi. All rights reserved.
//
#import "XCDYouTubePlayerScript.h"
#import
-#import "XCDYouTubeLogger.h"
+#import "XCDYouTubeLogger+Private.h"
@interface XCDYouTubePlayerScript ()
@property (nonatomic, strong) JSContext *context;
@@ -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/XCDYouTubeVideo+Private.h b/XCDYouTubeKit/XCDYouTubeVideo+Private.h
index 6fb502852..3b50ea3c8 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 8ab776e95..3a2b09fa2 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 dd111955d..2fca78a38 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"
@@ -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.h b/XCDYouTubeKit/XCDYouTubeVideoOperation.h
index b646202d9..5f5f0366e 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 b789b2bea..cd4a112dc 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"
@@ -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,
@@ -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];
@@ -134,23 +155,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 +193,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];
@@ -190,18 +213,18 @@ - (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];
}
}
}
-- (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 +244,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 +260,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 +277,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/XCDYouTubeVideoPlayerViewController.h b/XCDYouTubeKit/XCDYouTubeVideoPlayerViewController.h
index 62240973e..a3f4493b8 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 db7741bbf..b34c50003 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 184084198..750cfdc74 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
@@ -7,11 +7,12 @@
__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;
@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 1fe7bf689..1608b3de6 100644
--- a/XCDYouTubeKit/XCDYouTubeVideoWebpage.m
+++ b/XCDYouTubeKit/XCDYouTubeVideoWebpage.m
@@ -1,48 +1,31 @@
//
-// Copyright (c) 2013-2015 Cédric Luthi. All rights reserved.
+// Copyright (c) 2013-2016 Cédric Luthi. All rights reserved.
//
#import "XCDYouTubeVideoWebpage.h"
-#import "XCDYouTubeLogger.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;
+@synthesize regionsAllowed = _regionsAllowed;
-- (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,12 +95,28 @@ - (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;
}
+- (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