Skip to content

Commit

Permalink
Merge branch 'release/2.7.6'
Browse files Browse the repository at this point in the history
  • Loading branch information
SoneeJohn committed Jun 21, 2019
2 parents 7fead77 + 1f392ed commit cb87e63
Show file tree
Hide file tree
Showing 28 changed files with 405 additions and 309 deletions.
4 changes: 2 additions & 2 deletions .jazzy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ source_directory: XCDYouTubeKit
framework_root: .
umbrella_header: XCDYouTubeKit/XCDYouTubeKit.h
module: XCDYouTubeKit
module_version: 2.7.5
module_version: 2.7.6

author: Cédric Luthi
author_url: https://twitter.com/0xced

readme: README.md
github_url: https://github.com/0xced/XCDYouTubeKit
github_file_prefix: https://github.com/0xced/XCDYouTubeKit/tree/2.7.5/XCDYouTubeKit
github_file_prefix: https://github.com/0xced/XCDYouTubeKit/tree/2.7.6/XCDYouTubeKit
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
#### Version 2.7.6

* Adaptation to YouTube API change. (#437)

#### Version 2.7.5

* Adaptation to YouTube API change. (#433)
Expand Down
16 changes: 16 additions & 0 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// swift-tools-version:4.2
import PackageDescription

let package = Package(
name: "XCDYouTubeKit",
// platforms: [.iOS("8.0"), .macOS("10.10"), tvOS("9.0")],
products: [
.library(name: "XCDYouTubeKit", targets: ["XCDYouTubeKit"])
],
targets: [
.target(
name: "XCDYouTubeKit",
path: "XCDYouTubeKit"
)
]
)
9 changes: 8 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
[![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/)
[![Accio supported](https://img.shields.io/badge/Accio-supported-0A7CF5.svg?style=flat)](https://github.com/JamitLabs/Accio)
[![License](https://img.shields.io/cocoapods/l/XCDYouTubeKit.svg?style=flat)](LICENSE)

**XCDYouTubeKit** is a YouTube video player for iOS, tvOS and macOS.
Expand All @@ -27,7 +28,7 @@ XCDYouTubeKit is against the YouTube [Terms of Service](https://www.youtube.com/

## Installation

XCDYouTubeKit is available through CocoaPods and Carthage.
XCDYouTubeKit is available through [CocoaPods](https://cocoapods.org/), [Carthage](https://github.com/Carthage/Carthage) and [Accio](https://github.com/JamitLabs/Accio).

CocoaPods:

Expand All @@ -41,6 +42,12 @@ Carthage:
github "0xced/XCDYouTubeKit" ~> 2.7
```

Accio:

```swift
.package(url: "https://github.com/0xced/XCDYouTubeKit.git", .upToNextMajor(from: "2.7.3")),
```

Alternatively, you can manually use the provided static library or dynamic framework. In order to use the static library, you must:

1. Create a workspace (File → New → Workspace…)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -760,7 +760,7 @@
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
COPY_PHASE_STRIP = NO;
CURRENT_PROJECT_VERSION = 2.7.5;
CURRENT_PROJECT_VERSION = 2.7.6;
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_TESTABILITY = YES;
GCC_C_LANGUAGE_STANDARD = gnu99;
Expand Down Expand Up @@ -804,7 +804,7 @@
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
COPY_PHASE_STRIP = YES;
CURRENT_PROJECT_VERSION = 2.7.5;
CURRENT_PROJECT_VERSION = 2.7.6;
ENABLE_STRICT_OBJC_MSGSEND = YES;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_NO_COMMON_BLOCKS = YES;
Expand Down

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Binary file modified XCDYouTubeKit Tests/Cookies/adultUserCookieData
Binary file not shown.
Binary file modified XCDYouTubeKit Tests/Cookies/minorUserCookieData
Binary file not shown.
9 changes: 6 additions & 3 deletions XCDYouTubeKit Tests/XCDYouTubeProtectedVideosTestCase.m
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,8 @@ - (void) testProtectedVideoWithPlayerScriptConnectionError_offline
[self waitForExpectationsWithTimeout:1 handler:nil];
}

// Edit testProtectedVideoWithoutSignatureFunction.json by replacing `c&&d.set(b,encodeURIComponent(` with `c&&d.Xset(b,encodeURIComponent(`
// Edit testProtectedVideoWithoutSignatureFunction.json by replacing `c&&a.set(b,encodeURIComponent(Bv(` with `c.&&a.set(b,encodeURIComponent(Bv(` and
//`s&&f.set(k.sp,encodeURIComponent(Bv()` with `s.&&f.set(k.sp,encodeURIComponent(Bv(`
- (void) testProtectedVideoWithoutSignatureFunction_offline
{
__weak XCTestExpectation *expectation = [self expectationWithDescription:@""];
Expand All @@ -431,7 +432,8 @@ - (void) testProtectedVideoWithoutSignatureFunction_offline
}

// Edit testProtectedVideoWithBrokenSignatureFunction.json by returning null in the signature function
//Replace `(function(g){var window` with `(function(g){return void 0!==a};{var window`
//Replace `s&&f.set(k.sp,encodeURIComponent `X.&&f.set(k.sp,encodeURIComponent
// & `c&&a.set(b,encodeURIComponent` with `X.&&a.set(b,encodeURIComponent`
- (void) testProtectedVideoWithBrokenSignatureFunction_offline
{
__weak XCTestExpectation *expectation = [self expectationWithDescription:@""];
Expand Down Expand Up @@ -461,7 +463,8 @@ - (void) testProtectedVideoWithoutJavaScriptPlayerURL_offline
[self waitForExpectationsWithTimeout:1 handler:nil];
}

// Edit testProtectedVideoWithNonAnonymousJavaScriptPlayerFunction.json by replacing `"(function()` with `"(xunction()`
// Edit testProtectedVideoWithNonAnonymousJavaScriptPlayerFunction.json by replacing all `(function` with `(Xfunction`
// And replace `s&&f.set(k` with `x.&&f.set(k` and `c&&a.set(b` with `x.&&a.set(b`
- (void) testProtectedVideoWithNonAnonymousJavaScriptPlayerFunction_offline
{
__weak XCTestExpectation *expectation = [self expectationWithDescription:@""];
Expand Down
2 changes: 1 addition & 1 deletion XCDYouTubeKit.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = "XCDYouTubeKit"
s.version = "2.7.5"
s.version = "2.7.6"
s.summary = "YouTube video player for iOS and OS X."
s.homepage = "https://github.com/0xced/XCDYouTubeKit"
s.screenshot = "https://raw.github.com/0xced/XCDYouTubeKit/#{s.version}/Screenshots/XCDYouTubeVideoPlayerViewController.png"
Expand Down
8 changes: 4 additions & 4 deletions XCDYouTubeKit.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -613,10 +613,10 @@
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
COMBINE_HIDPI_IMAGES = YES;
COPY_PHASE_STRIP = NO;
CURRENT_PROJECT_VERSION = 35;
CURRENT_PROJECT_VERSION = 36;
DEFINES_MODULE = YES;
DYLIB_COMPATIBILITY_VERSION = 2.0.0;
DYLIB_CURRENT_VERSION = 2.7.5;
DYLIB_CURRENT_VERSION = 2.7.6;
DYLIB_INSTALL_NAME_BASE = "@rpath";
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_TESTABILITY = YES;
Expand Down Expand Up @@ -691,10 +691,10 @@
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
COMBINE_HIDPI_IMAGES = YES;
COPY_PHASE_STRIP = YES;
CURRENT_PROJECT_VERSION = 35;
CURRENT_PROJECT_VERSION = 36;
DEFINES_MODULE = YES;
DYLIB_COMPATIBILITY_VERSION = 2.0.0;
DYLIB_CURRENT_VERSION = 2.7.5;
DYLIB_CURRENT_VERSION = 2.7.6;
DYLIB_INSTALL_NAME_BASE = "@rpath";
ENABLE_NS_ASSERTIONS = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
Expand Down
Binary file not shown.
27 changes: 17 additions & 10 deletions XCDYouTubeKit/XCDYouTubePlayerScript.m
Original file line number Diff line number Diff line change
Expand Up @@ -74,13 +74,18 @@ - (instancetype) initWithString:(NSString *)string
}

//See list of regex patterns here https://github.com/rg3/youtube-dl/blob/master/youtube_dl/extractor/youtube.py#L1179
NSArray<NSString *>*patterns = @[@"\\.sig\\|\\|([a-zA-Z0-9$]+)\\(",
@"[\"']signature[\"']\\s*,\\s*([^\\(]+)",
@"yt\\.akamaized\\.net/\\)\\s*\\|\\|\\s*.*?\\s*c\\s*&&\\s*d\\.set\\([^,]+\\s*,\\s*(?:encodeURIComponent\\s*\\()?([a-zA-Z0-9$]+)\\(",
@"\\bc\\s*&&\\s*d\\.set\\([^,]+\\s*,\\s*(?:encodeURIComponent\\s*\\()?\\s*([a-zA-Z0-9$]+)\\(",
@"\\bc\\s*&&\\s*d\\.set\\([^,]+\\s*,\\s*\\([^)]*\\)\\s*\\(\\s*([a-zA-Z0-9$]+)\\("
NSArray<NSString *>*patterns = @[@"\\b[cs]\\s*&&\\s*[adf]\\.set\\([^,]+\\s*,\\s*encodeURIComponent\\s*\\(\\s*([a-zA-Z0-9$]+)\\(",
@"\\b[a-zA-Z0-9]+\\s*&&\\s*[a-zA-Z0-9]+\\.set\\([^,]+\\s*,\\s*encodeURIComponent\\s*\\(\\s*([a-zA-Z0-9$]+)\\(",
@"([\"\\\'])signature\\1\\s*,\\s*([a-zA-Z0-9$]+)\\(",
@"\\.sig\\|\\|([a-zA-Z0-9$]+)\\(",
@"yt\\.akamaized\\.net/\\)\\s*\\|\\|\\s*.*?\\s*[cs]\\s*&&\\s*[adf]\\.set\\([^,]+\\s*,\\s*(?:encodeURIComponent\\s*\\()?\\s*([a-zA-Z0-9$]+)\\(",
@"\\b[cs]\\s*&&\\s*[adf]\\.set\\([^,]+\\s*,\\s*([a-zA-Z0-9$]+)\\(",
@"\\b[a-zA-Z0-9]+\\s*&&\\s*[a-zA-Z0-9]+\\.set\\([^,]+\\s*,\\s*([a-zA-Z0-9$]+)\\(",
@"\\bc\\s*&&\\s*a\\.set\\([^,]+\\s*,\\s*\\([^)]*\\)\\s*\\(\\s*([a-zA-Z0-9$]+)\\(",
@"\\bc\\s*&&\\s*[a-zA-Z0-9]+\\.set\\([^,]+\\s*,\\s*\\([^)]*\\)\\s*\\(\\s*([a-zA-Z0-9$]+)\\(",
@"\\bc\\s*&&\\s*[a-zA-Z0-9]+\\.set\\([^,]+\\s*,\\s*\\([^)]*\\)\\s*\\(\\s*([a-zA-Z0-9$]+)\\("
];

NSMutableArray<NSRegularExpression *>*validRegularExpressions = [NSMutableArray new];

for (NSString *pattern in patterns) {
Expand All @@ -92,15 +97,17 @@ - (instancetype) initWithString:(NSString *)string
}

for (NSRegularExpression *regularExpression in validRegularExpressions) {
if (_signatureFunction)
break;

NSArray<NSTextCheckingResult *> *regexResults = [regularExpression matchesInString:script options:(NSMatchingOptions)0 range:NSMakeRange(0, script.length)];

for (NSTextCheckingResult *signatureResult in regexResults)
{
NSString *signatureFunctionName = signatureResult.numberOfRanges > 1 ? [script substringWithRange:[signatureResult rangeAtIndex:1]] : nil;
if (!signatureFunctionName)
continue;
NSString *signatureFunctionName = signatureResult.numberOfRanges > 1 ? [script substringWithRange:[signatureResult rangeAtIndex:1]] : nil;
if (!signatureFunctionName)
continue;

JSValue *signatureFunction = self.context[signatureFunctionName];
if (signatureFunction.isObject)
{
Expand Down
1 change: 1 addition & 0 deletions XCDYouTubeKit/XCDYouTubeVideo+Private.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ extern NSString *const XCDYouTubeNoStreamVideoUserInfoKey;
extern NSDictionary *XCDDictionaryWithQueryString(NSString *string);
extern NSString *XCDQueryStringWithDictionary(NSDictionary *dictionary);
extern NSArray *XCDCaptionArrayWithString(NSString *string);
extern NSArray *XCDThumnailArrayWithString(NSString *string);
extern NSString *XCDHTTPLiveStreamingStringWithString(NSString *string);

@interface XCDYouTubeVideo ()
Expand Down
25 changes: 25 additions & 0 deletions XCDYouTubeKit/XCDYouTubeVideo.m
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,23 @@
return manifestURL;
}

NSArray <NSDictionary *> *XCDThumnailArrayWithString(NSString *string)
{
NSError *error = nil;
NSData *data = [string dataUsingEncoding:NSUTF8StringEncoding];
if (!data) { return nil; }
NSDictionary *JSON = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingAllowFragments error:&error];

if (error) { return nil; }

NSDictionary *videoDetails = JSON[@"videoDetails"];
NSDictionary *thumbnail = videoDetails[@"thumbnail"];
NSArray *thumbnails = thumbnail[@"thumbnails"];

if (thumbnails.count == 0 || thumbnails == nil) { return nil; }
return thumbnails;
}

NSArray <NSDictionary *> *XCDCaptionArrayWithString(NSString *string)
{
NSError *error = nil;
Expand Down Expand Up @@ -155,6 +172,14 @@ - (instancetype) initWithIdentifier:(NSString *)identifier info:(NSDictionary *)
NSString *thumbnail = info[@"thumbnail_url"] ?: info[@"iurl"];
_thumbnailURL = thumbnail ? [NSURL URLWithString:thumbnail] : nil;

if (!_thumbnailURL) {
NSArray <NSDictionary *>*thumnails = XCDThumnailArrayWithString(playerResponse);
if (thumnails.count >= 1) {
NSString *thumbnailURLString = thumnails[0][@"url"];
_thumbnailURL = thumbnailURLString ? [NSURL URLWithString:thumbnailURLString] : nil;
}
}

NSMutableDictionary *streamURLs = [NSMutableDictionary new];

if (httpLiveStream)
Expand Down

0 comments on commit cb87e63

Please sign in to comment.