Skip to content

Commit

Permalink
Merge branch 'release/2.7.4'
Browse files Browse the repository at this point in the history
  • Loading branch information
SoneeJohn committed May 7, 2019
2 parents 4dc4119 + 3c53047 commit 01a5793
Show file tree
Hide file tree
Showing 28 changed files with 760 additions and 391 deletions.
32 changes: 32 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
version: 2
jobs:
build:
macos:
xcode: '10.2.1'
environment:
LANG: en_US.UTF-8
LC_ALL: en_US.UTF-8
FASTLANE_DISABLE_ANIMATION: 1
FASTLANE_SKIP_UPDATE_CHECK: 1
SKIP_SLOW_FASTLANE_WARNING: 1
steps:
- checkout
- run: xcodebuild -version -sdk
- run: xcrun simctl list
- run: make test_macOS
- run: make test_tvOS
- run: make test_iOS
- run: make test_macOS_report
- run: make test_tvOS_report
- run: make test_iOS_report
- run:
name: Upload to CodeCov
command: bash <(curl -s https://codecov.io/bash) -J XCDYouTubeKit -X coveragepy -X gcov -X xcodeplist -X xcodepartials
- store_test_results:
path: test_reports
- store_artifacts:
path: /Users/distiller/Library/Developer/Xcode/DerivedData/XCDYouTubeKit-byvnmvumvdztmngymdsxlhlsgpgd/Logs/Test
destination: xcresults
- store_artifacts:
path: artifacts
destination: buildlogs
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.3
module_version: 2.7.4

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.3/XCDYouTubeKit
github_file_prefix: https://github.com/0xced/XCDYouTubeKit/tree/2.7.4/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.4

* Add the ability to fetch certain age-gate videos. (#431)

#### Version 2.7.3

* Adaptation to YouTube API change. (#419, #422. #421)
Expand Down
14 changes: 7 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,22 +22,22 @@ test_iOS_report: check_scan
fastlane scan --output_directory "${CIRCLE_TEST_REPORTS}" --output_types junit --output_files $@.xml --device "iPhone 5s" --code_coverage --xcargs "OBJROOT=build GCC_GENERATE_TEST_COVERAGE_FILES=YES GCC_INSTRUMENT_PROGRAM_FLOW_ARCS=YES"

test_tvOS_report: check_scan
fastlane scan --output_directory "${CIRCLE_TEST_REPORTS}" --output_types junit --output_files $@.xml --device "Apple TV 1080p"
fastlane scan --output_directory "${CIRCLE_TEST_REPORTS}" --output_types junit --output_files $@.xml --device "Apple TV"

test_macOS: check_scan
fastlane scan --configuration Release --xcargs "RUN_CLANG_STATIC_ANALYZER=YES CLANG_STATIC_ANALYZER_MODE=Deep MACOSX_DEPLOYMENT_TARGET=`xcrun --sdk "macosx" --show-sdk-version`"
fastlane scan --configuration Release --xcargs "RUN_CLANG_STATIC_ANALYZER=YES CLANG_STATIC_ANALYZER_MODE=Deep MACOSX_DEPLOYMENT_TARGET=`xcrun --sdk "macosx" --show-sdk-version`"

test_iOS: check_scan
fastlane scan --configuration Release --device "iPhone 5s" --xcargs "RUN_CLANG_STATIC_ANALYZER=YES CLANG_STATIC_ANALYZER_MODE=Deep IPHONEOS_DEPLOYMENT_TARGET=`xcrun --sdk "iphonesimulator" --show-sdk-version`"
fastlane scan --configuration Release --device "iPhone 5s" --xcargs "RUN_CLANG_STATIC_ANALYZER=YES CLANG_STATIC_ANALYZER_MODE=Deep IPHONEOS_DEPLOYMENT_TARGET=`xcrun --sdk "iphonesimulator" --show-sdk-version`"

test_tvOS: check_scan
fastlane scan --configuration Release --device "Apple TV 1080p" --xcargs "RUN_CLANG_STATIC_ANALYZER=YES CLANG_STATIC_ANALYZER_MODE=Deep TVOS_DEPLOYMENT_TARGET=`xcrun --sdk "appletvsimulator" --show-sdk-version`"
fastlane scan --configuration Release --device "Apple TV" --xcargs "RUN_CLANG_STATIC_ANALYZER=YES CLANG_STATIC_ANALYZER_MODE=Deep TVOS_DEPLOYMENT_TARGET=`xcrun --sdk "appletvsimulator" --show-sdk-version`"

test_iOS_9: check_scan
fastlane scan --device "iPhone 5s (9.0)"
test_iOS_10: check_scan
fastlane scan --device "iPhone 5s (10.3.1)"

check_scan:
@fastlane scan --version > /dev/null 2>&1 || (printf "❌ Please install \e[1;30mscan\e[0m (https://github.com/fastlane/fastlane/tree/master/scan) to run unit tests: $$ [sudo] \e[1;30mgem install scan\e[0m\n" && false)
@fastlane scan --version > /dev/null 2>&1 || (printf "❌ Please install \e[1;30mfastlane scan\e[0m (https://docs.fastlane.tools/actions/scan/) to run unit tests: $$ [sudo] \e[1;30mgem install fastlane\e[0m\n" && false)

check_slather:
@slather version > /dev/null 2>&1 || printf "⚠️ Please install \e[1;30mslather\e[0m (https://github.com/SlatherOrg/slather) to get a code coverage report: $$ [sudo] \e[1;30mgem install slather\e[0m\n"
12 changes: 8 additions & 4 deletions Scripts/analyzer.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,16 @@
if not run_clang_static_analyzer[:1] in 'YyTt123456789':
sys.exit(0)

analyzer_results_dir = os.path.join(os.environ['TARGET_TEMP_DIR'], 'StaticAnalyzer', os.environ['PROJECT_NAME'], os.environ['TARGET_NAME'], os.environ['CURRENT_VARIANT'], os.environ['CURRENT_ARCH'])
if not os.path.exists(analyzer_results_dir):
sys.exit("error: Static Anaylzer results not found, expected in %s" % analyzer_results_dir)
base_dir = os.path.join(os.environ['TARGET_TEMP_DIR'], 'StaticAnalyzer', os.environ['PROJECT_NAME'], os.environ['TARGET_NAME'], os.environ['CURRENT_VARIANT'])
analyzer_results_dirs = map(lambda arch : os.path.join(base_dir, arch), os.environ['ARCHS'].split(' '))
results = []
for analyzer_results_dir in analyzer_results_dirs:
results.extend(glob.iglob(os.path.join(analyzer_results_dir, "*.plist")))
if len(results) == 0:
sys.exit("error: Static Anaylzer plist results not found, searched inside <%s>" % '> and <'.join(analyzer_results_dirs))

exit_code = 0
for result in glob.iglob(os.path.join(analyzer_results_dir, "*.plist")):
for result in results:
with open(result) as f:
plist = plistlib.readPlist(f)
for diagnostic in plist['diagnostics']:
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.3;
CURRENT_PROJECT_VERSION = 2.7.4;
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.3;
CURRENT_PROJECT_VERSION = 2.7.4;
ENABLE_STRICT_OBJC_MSGSEND = YES;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_NO_COMMON_BLOCKS = YES;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"domain" : "NSURLErrorDomain"
},
"method" : "GET",
"status" : 0,
"status" : 404,
"uri" : "https:\/\/manifest.googlevideo.com\/api\/manifest\/dash\/pl\/18\/id\/60b83e2c29185db2\/fvip\/4\/ms\/au%2Conr\/mm\/31%2C26\/mv\/m\/initcwndbps\/81250\/source\/youtube\/sparams\/as%2Cei%2Chfr%2Cid%2Cinitcwndbps%2Cip%2Cipbits%2Citag%2Cmm%2Cmn%2Cms%2Cmv%2Cpl%2Cplayback_host%2Crequiressl%2Csource%2Cexpire\/mn\/sn-o097znl6%2Csn-a5meknsy\/mt\/1541595266\/ip\/107.170.239.51\/key\/yt6\/hfr\/all\/expire\/1541616988\/ipbits\/0\/as\/fmp4_audio_clear%2Cfmp4_sd_hd_clear\/itag\/0\/requiressl\/yes\/signature\/55DBE87B69362A07203FDA0794E12D8646FF861C.399D1A0D174914F0CDF87E13DE2ECFFA2BE76B95\/ei\/_ODiW6W9EMzSkgb3uLH4Cw\/playback_host\/r2---sn-o097znl6.googlevideo.com"
}
]
]

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

This file was deleted.

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.
45 changes: 45 additions & 0 deletions XCDYouTubeKit Tests/XCDYouTubeClientTestCase.m
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,51 @@ - (void) testLiveVideo
[self waitForExpectationsWithTimeout:5 handler:nil];
}

// Test for https://github.com/0xced/XCDYouTubeKit/issues/420

- (void) testVideo1
{
__weak XCTestExpectation *expectation = [self expectationWithDescription:@""];
[[XCDYouTubeClient defaultClient] getVideoWithIdentifier:@"8vISc8dZ_bc" completionHandler:^(XCDYouTubeVideo *video, NSError *error)
{
XCTAssertNil(error);
XCTAssertNotNil(video.title);
XCTAssertNotNil(video.thumbnailURL);
XCTAssertTrue(video.streamURLs.count > 0);
XCTAssertTrue(video.duration > 0);
[video.streamURLs enumerateKeysAndObjectsUsingBlock:^(NSNumber *key, NSURL *streamURL, BOOL *stop) {
XCTAssertTrue([streamURL.query rangeOfString:@"signature="].location != NSNotFound);
}];
[expectation fulfill];
}];
[self waitForExpectationsWithTimeout:5 handler:nil];
}

// See https://github.com/0xced/XCDYouTubeKit/issues/420#issue-400541618

- (void) testVideo1IsPlayable
{
__weak XCTestExpectation *expectation = [self expectationWithDescription:@""];
[[XCDYouTubeClient defaultClient] getVideoWithIdentifier:@"8vISc8dZ_bc" completionHandler:^(XCDYouTubeVideo *video, NSError *error)
{
XCTAssertNil(error);
XCTAssertNotNil(video.title);
XCTAssertNotNil(video.expirationDate);
XCTAssertNotNil(video.thumbnailURL);
XCTAssertTrue(video.streamURLs.count > 0);
XCTAssertTrue(video.duration > 0);
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:video.streamURLs[@(XCDYouTubeVideoQualityMedium360)]];
request.HTTPMethod = @"HEAD";
NSURLSessionDataTask *dataTask = [[NSURLSession sharedSession] dataTaskWithRequest:request completionHandler:^(NSData *data, NSURLResponse *response, NSError *connectionError)
{
XCTAssertEqual([(NSHTTPURLResponse *)response statusCode], 200);
[expectation fulfill];
}];
[dataTask resume];
}];
[self waitForExpectationsWithTimeout:5 handler:nil];
}

- (void) testExpiredLiveVideo
{
__weak XCTestExpectation *expectation = [self expectationWithDescription:@""];
Expand Down
60 changes: 45 additions & 15 deletions XCDYouTubeKit Tests/XCDYouTubeProtectedVideosTestCase.m
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,10 @@ @implementation XCDYouTubeProtectedVideosTestCase
NSCAssert(cookieURL != nil, @"Cookie data could not be found!");
NSData *cookieData = [NSData dataWithContentsOfURL:cookieURL];
NSCAssert(cookieData != nil, @"Cookie data could not be found!");
NSArray <NSHTTPCookie *>*cookies = [NSKeyedUnarchiver unarchiveObjectWithData:cookieData];
NSKeyedUnarchiver *unArchiver = [[NSKeyedUnarchiver alloc]initForReadingFromData:cookieData error:nil];
unArchiver.requiresSecureCoding = NO;
NSSet *codingClasses = [NSSet setWithArray:@[ [NSArray classForCoder],[NSHTTPCookie classForCoder] ]];
NSArray <NSHTTPCookie *>*cookies = [unArchiver decodeObjectOfClasses:codingClasses forKey:NSKeyedArchiveRootObjectKey];
NSCAssert(cookies.count != 0, @"No cookies found!");
return cookies;
}
Expand All @@ -32,7 +35,10 @@ @implementation XCDYouTubeProtectedVideosTestCase
NSCAssert(cookieURL != nil, @"Cookie data could not be found!");
NSData *cookieData = [NSData dataWithContentsOfURL:cookieURL];
NSCAssert(cookieData != nil, @"Cookie data could not be found!");
NSArray <NSHTTPCookie *>*cookies = [NSKeyedUnarchiver unarchiveObjectWithData:cookieData];
NSKeyedUnarchiver *unArchiver = [[NSKeyedUnarchiver alloc]initForReadingFromData:cookieData error:nil];
unArchiver.requiresSecureCoding = NO;
NSSet *codingClasses = [NSSet setWithArray:@[ [NSArray classForCoder],[NSHTTPCookie classForCoder] ]];
NSArray <NSHTTPCookie *>*cookies = [unArchiver decodeObjectOfClasses:codingClasses forKey:NSKeyedArchiveRootObjectKey];
NSCAssert(cookies.count != 0, @"No cookies found!");
return cookies;
}
Expand Down Expand Up @@ -376,19 +382,6 @@ - (void) testAgeRestrictedVEVOVideoWithMinorUserCookiesIsPlayable_online
[self waitForExpectationsWithTimeout:30 handler:nil];
}

- (void)testAgeRestrictedVEVOVideoWithoutCookies
{
__weak XCTestExpectation *expectation = [self expectationWithDescription:@""];
[[XCDYouTubeClient defaultClient] getVideoWithIdentifier:@"07FYdnEawAQ" completionHandler:^(XCDYouTubeVideo *video, NSError *error)
{
XCTAssertNotNil(error);
XCTAssertNil(video);
[expectation fulfill];
}];

[self waitForExpectationsWithTimeout:5 handler:nil];
}

// With Charles
// * Enable SSL proxying for *.youtube.com
// * Tools -> Black List... -> Add host:www.youtube.com and path:watch to simulate connection error on the web page
Expand Down Expand Up @@ -497,4 +490,41 @@ - (void) testAgeRestrictedVEVOVideoWithEmbedWebPageConnectionError_offline
[self waitForExpectationsWithTimeout:1 handler:nil];
}

// See https://github.com/0xced/XCDYouTubeKit/issues/431
- (void) testAgeRestrictedVideo1
{
__weak XCTestExpectation *expectation = [self expectationWithDescription:@""];
[[XCDYouTubeClient defaultClient] getVideoWithIdentifier:@"6kLq3WMV1nU" completionHandler:^(XCDYouTubeVideo *video, NSError *error)
{
XCTAssertNil(error);
XCTAssertNotNil(video.title);
XCTAssertNotNil(video.expirationDate);
XCTAssertNotNil(video.thumbnailURL);
XCTAssertTrue(video.streamURLs.count > 0);
XCTAssertTrue(video.duration > 0);
[video.streamURLs enumerateKeysAndObjectsUsingBlock:^(NSNumber *key, NSURL *streamURL, BOOL *stop)
{
XCTAssertTrue([streamURL.query rangeOfString:@"signature="].location != NSNotFound);
}];
[expectation fulfill];
}];
[self waitForExpectationsWithTimeout:5 handler:nil];
}

// See https://github.com/0xced/XCDYouTubeKit/issues/431
// Remove \\/yts\\/jsbin\\/player_ias-vfl61X81T\\/en_US\\/base.js\ from testAgeRestrictedVideo1WithNoJavaScriptPlayerURL.json
- (void) testAgeRestrictedVideo1WithNoJavaScriptPlayerURL_offline
{
__weak XCTestExpectation *expectation = [self expectationWithDescription:@""];
[[XCDYouTubeClient defaultClient] getVideoWithIdentifier:@"6kLq3WMV1nU" completionHandler:^(XCDYouTubeVideo *video, NSError *error)
{
XCTAssertNil(video);
XCTAssertEqualObjects(error.domain, XCDYouTubeVideoErrorDomain);
XCTAssertEqual(error.code, XCDYouTubeErrorRestrictedPlayback);
XCTAssertEqualObjects(error.localizedDescription, @"Sign in to confirm your age");
[expectation fulfill];
}];
[self waitForExpectationsWithTimeout:1 handler:nil];
}

@end
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.3"
s.version = "2.7.4"
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
Loading

0 comments on commit 01a5793

Please sign in to comment.