From 93d923a99ce454646cd694752045d17a3b090f69 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ce=CC=81dric=20Luthi?= Date: Sat, 28 Dec 2013 16:27:20 +0100 Subject: [PATCH 1/3] Also parse the `adaptive_fmts` key In order to be ready for either 1. YouTube support of HTTP Live Streaming (HLS) 2. iOS support of Dynamic Adaptive Streaming over HTTP (MPEG-DASH) Incidentally it also fixes #19 since YouTube removed the `sig` key and directly includes the `signature` parameter in the video URL. --- .../XCDYouTubeVideoPlayerViewController.m | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/XCDYouTubeVideoPlayerViewController/XCDYouTubeVideoPlayerViewController.m b/XCDYouTubeVideoPlayerViewController/XCDYouTubeVideoPlayerViewController.m index f95de8ed7..da556e116 100644 --- a/XCDYouTubeVideoPlayerViewController/XCDYouTubeVideoPlayerViewController.m +++ b/XCDYouTubeVideoPlayerViewController/XCDYouTubeVideoPlayerViewController.m @@ -242,7 +242,8 @@ - (NSURL *) videoURLWithData:(NSData *)data error:(NSError * __autoreleasing *)e NSString *videoQuery = [[NSString alloc] initWithData:data encoding:NSASCIIStringEncoding]; NSStringEncoding queryEncoding = NSUTF8StringEncoding; NSDictionary *video = DictionaryWithQueryString(videoQuery, queryEncoding); - NSArray *streamQueries = [video[@"url_encoded_fmt_stream_map"] componentsSeparatedByString:@","]; + NSMutableArray *streamQueries = [[video[@"url_encoded_fmt_stream_map"] componentsSeparatedByString:@","] mutableCopy]; + [streamQueries addObjectsFromArray:[video[@"adaptive_fmts"] componentsSeparatedByString:@","]]; NSMutableDictionary *streamURLs = [NSMutableDictionary new]; for (NSString *streamQuery in streamQueries) @@ -250,11 +251,15 @@ - (NSURL *) videoURLWithData:(NSData *)data error:(NSError * __autoreleasing *)e NSDictionary *stream = DictionaryWithQueryString(streamQuery, queryEncoding); NSString *type = stream[@"type"]; NSString *urlString = stream[@"url"]; - NSString *signature = stream[@"sig"]; - if (urlString && signature && [AVURLAsset isPlayableExtendedMIMEType:type]) + if (urlString && [AVURLAsset isPlayableExtendedMIMEType:type]) { - NSURL *streamURL = [NSURL URLWithString:[NSString stringWithFormat:@"%@&signature=%@", urlString, signature]]; - streamURLs[@([stream[@"itag"] integerValue])] = streamURL; + NSURL *streamURL = [NSURL URLWithString:urlString]; + NSString *signature = stream[@"sig"]; + if (signature) + streamURL = [NSURL URLWithString:[NSString stringWithFormat:@"%@&signature=%@", urlString, signature]]; + + if ([[DictionaryWithQueryString(streamURL.query, queryEncoding) allKeys] containsObject:@"signature"]) + streamURLs[@([stream[@"itag"] integerValue])] = streamURL; } } From 25bcad03159f621db62e0a53bceb73b9277fe1f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ce=CC=81dric=20Luthi?= Date: Fri, 28 Feb 2014 14:16:48 +0100 Subject: [PATCH 2/3] Version 1.1.2 --- XCDYouTubeVideoPlayerViewController.podspec | 2 +- XCDYouTubeVideoPlayerViewController.xcodeproj/project.pbxproj | 4 ++-- .../Supporting Files/YouTube Video Player Demo-Info.plist | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/XCDYouTubeVideoPlayerViewController.podspec b/XCDYouTubeVideoPlayerViewController.podspec index 9a92b4b8f..249b16a07 100644 --- a/XCDYouTubeVideoPlayerViewController.podspec +++ b/XCDYouTubeVideoPlayerViewController.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = "XCDYouTubeVideoPlayerViewController" - s.version = "1.1.1" + s.version = "1.1.2" s.summary = "YouTube video player for iPhone and iPad." s.homepage = "https://github.com/0xced/XCDYouTubeVideoPlayerViewController" s.license = 'MIT' diff --git a/XCDYouTubeVideoPlayerViewController.xcodeproj/project.pbxproj b/XCDYouTubeVideoPlayerViewController.xcodeproj/project.pbxproj index bfbb87cf5..8b892f1a7 100644 --- a/XCDYouTubeVideoPlayerViewController.xcodeproj/project.pbxproj +++ b/XCDYouTubeVideoPlayerViewController.xcodeproj/project.pbxproj @@ -157,7 +157,7 @@ CLANG_WARN_INT_CONVERSION = YES; CLANG_WARN_SUSPICIOUS_IMPLICIT_CONVERSION = YES; COPY_PHASE_STRIP = NO; - DYLIB_COMPATIBILITY_VERSION = 1.1.1; + DYLIB_COMPATIBILITY_VERSION = 1.1.2; GCC_C_LANGUAGE_STANDARD = gnu99; GCC_OPTIMIZATION_LEVEL = 0; GCC_TREAT_WARNINGS_AS_ERRORS = YES; @@ -199,7 +199,7 @@ CLANG_WARN_INT_CONVERSION = YES; CLANG_WARN_SUSPICIOUS_IMPLICIT_CONVERSION = YES; COPY_PHASE_STRIP = YES; - DYLIB_COMPATIBILITY_VERSION = 1.1.1; + DYLIB_COMPATIBILITY_VERSION = 1.1.2; GCC_C_LANGUAGE_STANDARD = gnu99; GCC_TREAT_WARNINGS_AS_ERRORS = YES; GCC_WARN_64_TO_32_BIT_CONVERSION = YES; diff --git a/YouTube Video Player Demo/Supporting Files/YouTube Video Player Demo-Info.plist b/YouTube Video Player Demo/Supporting Files/YouTube Video Player Demo-Info.plist index 5abf8ea07..b94a4c45f 100644 --- a/YouTube Video Player Demo/Supporting Files/YouTube Video Player Demo-Info.plist +++ b/YouTube Video Player Demo/Supporting Files/YouTube Video Player Demo-Info.plist @@ -17,7 +17,7 @@ CFBundlePackageType APPL CFBundleShortVersionString - 1.1.1 + 1.1.2 CFBundleVersion 0 LSRequiresIPhoneOS From d1ad3c4c439e42b585e8178dabe768ed9b405842 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ce=CC=81dric=20Luthi?= Date: Fri, 28 Feb 2014 14:20:12 +0100 Subject: [PATCH 3/3] Update CHANGELOG for version 1.1.2 --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index caccbc0fe..5f0c24051 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +#### Version 1.1.2 + +* Adaptation to YouTube API change. (#19) + #### Version 1.1.1 * For errors of the `XCDYouTubeVideoErrorDomain` domain, `-[NSError localizedDescription]` is actually localized and doesn’t contain HTML tags, making it suitable for displaying to the user.