Skip to content

Commit

Permalink
Merge branch 'hotfix/2.3.3'
Browse files Browse the repository at this point in the history
  • Loading branch information
0xced committed Nov 12, 2015
2 parents 432d078 + 04bbd3c commit 493aeca
Show file tree
Hide file tree
Showing 9 changed files with 169 additions and 179 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
#### Version 2.3.3

* Adaptation to YouTube API change. (#193, #194, #196, #197, #198, #202)

#### Version 2.3.2

* Adaptation to YouTube API change. (#186)
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@ XCDYouTubeKit is available through CocoaPods and Carthage.

CocoaPods:
```ruby
pod "XCDYouTubeKit", "~> 2.3.2"
pod "XCDYouTubeKit", "~> 2.3.3"
```

Carthage:
```objc
github "0xced/XCDYouTubeKit" ~> 2.3.2
github "0xced/XCDYouTubeKit" ~> 2.3.3
```

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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -532,7 +532,7 @@
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
COPY_PHASE_STRIP = NO;
CURRENT_PROJECT_VERSION = 2.3.2;
CURRENT_PROJECT_VERSION = 2.3.3;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_DYNAMIC_NO_PIC = NO;
GCC_OPTIMIZATION_LEVEL = 0;
Expand Down Expand Up @@ -568,7 +568,7 @@
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
COPY_PHASE_STRIP = YES;
CURRENT_PROJECT_VERSION = 2.3.2;
CURRENT_PROJECT_VERSION = 2.3.3;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_PREPROCESSOR_DEFINITIONS = (
"NS_BLOCK_ASSERTIONS=1",
Expand Down

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion XCDYouTubeKit.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = "XCDYouTubeKit"
s.version = "2.3.2"
s.version = "2.3.3"
s.summary = "YouTube video player for iOS and OS X."
s.homepage = "https://github.com/0xced/XCDYouTubeKit"
s.screenshot = "https://raw.github.com/0xced/XCDYouTubeKit/#{s.version}/Screenshots/XCDYouTubeVideoPlayerViewController.png"
Expand Down
6 changes: 3 additions & 3 deletions XCDYouTubeKit.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -870,7 +870,7 @@
COPY_PHASE_STRIP = NO;
CURRENT_PROJECT_VERSION = "$(DYLIB_CURRENT_VERSION)";
DYLIB_COMPATIBILITY_VERSION = 2.0.0;
DYLIB_CURRENT_VERSION = 2.3.2;
DYLIB_CURRENT_VERSION = 2.3.3;
DYLIB_INSTALL_NAME_BASE = "@rpath";
ENABLE_STRICT_OBJC_MSGSEND = YES;
GCC_C_LANGUAGE_STANDARD = gnu99;
Expand Down Expand Up @@ -924,7 +924,7 @@
COPY_PHASE_STRIP = YES;
CURRENT_PROJECT_VERSION = "$(DYLIB_CURRENT_VERSION)";
DYLIB_COMPATIBILITY_VERSION = 2.0.0;
DYLIB_CURRENT_VERSION = 2.3.2;
DYLIB_CURRENT_VERSION = 2.3.3;
DYLIB_INSTALL_NAME_BASE = "@rpath";
ENABLE_STRICT_OBJC_MSGSEND = YES;
GCC_C_LANGUAGE_STANDARD = gnu99;
Expand Down Expand Up @@ -991,7 +991,7 @@
COPY_PHASE_STRIP = NO;
CURRENT_PROJECT_VERSION = "$(DYLIB_CURRENT_VERSION)";
DYLIB_COMPATIBILITY_VERSION = 2.0.0;
DYLIB_CURRENT_VERSION = 2.3.2;
DYLIB_CURRENT_VERSION = 2.3.3;
DYLIB_INSTALL_NAME_BASE = "@rpath";
ENABLE_STRICT_OBJC_MSGSEND = YES;
GCC_C_LANGUAGE_STANDARD = gnu99;
Expand Down
29 changes: 15 additions & 14 deletions XCDYouTubeKit/XCDYouTubePlayerScript.m
Original file line number Diff line number Diff line change
Expand Up @@ -22,39 +22,40 @@ - (instancetype) initWithString:(NSString *)string

NSString *script = [string stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
XCDYouTubeLogTrace(@"%@", script);
static NSString *jsPrologue = @"(function()";
static NSString *jsEpilogue = @")();";
if ([script hasPrefix:jsPrologue] && [script hasSuffix:jsEpilogue])
script = [script substringWithRange:NSMakeRange(jsPrologue.length, script.length - (jsPrologue.length + jsEpilogue.length))];
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)
script = [script substringWithRange:[anonymousFunctionResult rangeAtIndex:1]];
else
XCDYouTubeLogWarning(@"Unexpected player script (not an anonymous function)");
XCDYouTubeLogWarning(@"Unexpected player script (no anonymous function found)");

_context = [JSContext new];
_context.exceptionHandler = ^(JSContext *context, JSValue *exception) {
XCDYouTubeLogWarning(@"JavaScript exception: %@", exception);
};

NSDictionary *environment = @{
@"document": @{},
@"document": @{
@"documentElement": @{}
},
@"location": @{
@"hash": @""
},
@"navigator": @{},
@"window": @{
@"location": @{
@"hash": @""
},
@"navigator": @{}
}
};
_context[@"window"] = @{};
for (NSString *propertyName in environment)
{
JSValue *value = [JSValue valueWithObject:environment[propertyName] inContext:_context];
_context[propertyName] = value;
_context[@"window"][propertyName] = value;
}

[_context evaluateScript:script];

NSRegularExpression *signatureRegularExpression = [NSRegularExpression regularExpressionWithPattern:@"[\"']signature[\"']\\s*,\\s*([^\\(]+)" options:NSRegularExpressionCaseInsensitive error:NULL];
NSTextCheckingResult *result = [signatureRegularExpression firstMatchInString:script options:(NSMatchingOptions)0 range:NSMakeRange(0, script.length)];
NSString *signatureFunctionName = result.numberOfRanges > 1 ? [script substringWithRange:[result rangeAtIndex:1]] : nil;
NSTextCheckingResult *signatureResult = [signatureRegularExpression firstMatchInString:script options:(NSMatchingOptions)0 range:NSMakeRange(0, script.length)];
NSString *signatureFunctionName = signatureResult.numberOfRanges > 1 ? [script substringWithRange:[signatureResult rangeAtIndex:1]] : nil;

if (signatureFunctionName)
_signatureFunction = self.context[signatureFunctionName];
Expand Down

0 comments on commit 493aeca

Please sign in to comment.