diff --git a/.jazzy.yaml b/.jazzy.yaml index 020700e1..38383580 100644 --- a/.jazzy.yaml +++ b/.jazzy.yaml @@ -4,11 +4,11 @@ source_directory: XCDYouTubeKit framework_root: . umbrella_header: XCDYouTubeKit/XCDYouTubeKit.h module: XCDYouTubeKit -module_version: 2.7.7 +module_version: 2.7.8 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.7/XCDYouTubeKit +github_file_prefix: https://github.com/0xced/XCDYouTubeKit/tree/2.7.8/XCDYouTubeKit diff --git a/CHANGELOG.md b/CHANGELOG.md index 5d0ae6ea..f6f818ec 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +#### Version 2.7.8 + +* Adaptation to YouTube API change. (#443) + #### Version 2.7.7 * Add another player script regular expression (#438) diff --git a/XCDYouTubeKit Demo/XCDYouTubeKit Demo.xcodeproj/project.pbxproj b/XCDYouTubeKit Demo/XCDYouTubeKit Demo.xcodeproj/project.pbxproj index 0a08dee6..35b92372 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.7.7; + CURRENT_PROJECT_VERSION = 2.7.8; ENABLE_STRICT_OBJC_MSGSEND = YES; ENABLE_TESTABILITY = YES; GCC_C_LANGUAGE_STANDARD = gnu99; @@ -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.7; + CURRENT_PROJECT_VERSION = 2.7.8; ENABLE_STRICT_OBJC_MSGSEND = YES; GCC_C_LANGUAGE_STANDARD = gnu99; GCC_NO_COMMON_BLOCKS = YES; diff --git a/XCDYouTubeKit.podspec b/XCDYouTubeKit.podspec index 44bca788..d92ddce2 100644 --- a/XCDYouTubeKit.podspec +++ b/XCDYouTubeKit.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = "XCDYouTubeKit" - s.version = "2.7.7" + s.version = "2.7.8" 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" diff --git a/XCDYouTubeKit.xcodeproj/project.pbxproj b/XCDYouTubeKit.xcodeproj/project.pbxproj index f5090a67..365ae969 100644 --- a/XCDYouTubeKit.xcodeproj/project.pbxproj +++ b/XCDYouTubeKit.xcodeproj/project.pbxproj @@ -613,10 +613,10 @@ CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; COMBINE_HIDPI_IMAGES = YES; COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 37; + CURRENT_PROJECT_VERSION = 38; DEFINES_MODULE = YES; DYLIB_COMPATIBILITY_VERSION = 2.0.0; - DYLIB_CURRENT_VERSION = 2.7.7; + DYLIB_CURRENT_VERSION = 2.7.8; DYLIB_INSTALL_NAME_BASE = "@rpath"; ENABLE_STRICT_OBJC_MSGSEND = YES; ENABLE_TESTABILITY = YES; @@ -691,10 +691,10 @@ CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; COMBINE_HIDPI_IMAGES = YES; COPY_PHASE_STRIP = YES; - CURRENT_PROJECT_VERSION = 37; + CURRENT_PROJECT_VERSION = 38; DEFINES_MODULE = YES; DYLIB_COMPATIBILITY_VERSION = 2.0.0; - DYLIB_CURRENT_VERSION = 2.7.7; + DYLIB_CURRENT_VERSION = 2.7.8; DYLIB_INSTALL_NAME_BASE = "@rpath"; ENABLE_NS_ASSERTIONS = NO; ENABLE_STRICT_OBJC_MSGSEND = YES; diff --git a/XCDYouTubeKit/XCDYouTubeVideo+Private.h b/XCDYouTubeKit/XCDYouTubeVideo+Private.h index 1c4c5304..ba1a8953 100644 --- a/XCDYouTubeKit/XCDYouTubeVideo+Private.h +++ b/XCDYouTubeKit/XCDYouTubeVideo+Private.h @@ -15,6 +15,7 @@ extern NSString *XCDQueryStringWithDictionary(NSDictionary *dictionary); extern NSArray *XCDCaptionArrayWithString(NSString *string); extern NSArray *XCDThumnailArrayWithString(NSString *string); extern NSString *XCDHTTPLiveStreamingStringWithString(NSString *string); +extern NSDictionary *XCDDictionaryWithString(NSString *string); @interface XCDYouTubeVideo () diff --git a/XCDYouTubeKit/XCDYouTubeVideo.m b/XCDYouTubeKit/XCDYouTubeVideo.m index f0ce2c5d..cdd65bf3 100644 --- a/XCDYouTubeKit/XCDYouTubeVideo.m +++ b/XCDYouTubeKit/XCDYouTubeVideo.m @@ -65,6 +65,15 @@ return captionTracks; } +NSDictionary *XCDDictionaryWithString(NSString *string) +{ + NSError *error = nil; + NSData *data = [string dataUsingEncoding:NSUTF8StringEncoding]; + if (!data) { return nil; } + + return [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingAllowFragments error:&error]; +} + NSDictionary *XCDDictionaryWithQueryString(NSString *string) { NSMutableDictionary *dictionary = [NSMutableDictionary new]; @@ -157,6 +166,7 @@ - (instancetype) initWithIdentifier:(NSString *)identifier info:(NSDictionary *) NSString *playerResponse = info[@"player_response"]; NSString *httpLiveStream = info[@"hlsvp"] ?: XCDHTTPLiveStreamingStringWithString(playerResponse); NSString *adaptiveFormats = info[@"adaptive_fmts"]; + NSDictionary *videoDetails = XCDDictionaryWithString(playerResponse)[@"videoDetails"]; NSMutableDictionary *userInfo = response.URL ? [@{ NSURLErrorKey: (id)response.URL } mutableCopy] : [NSMutableDictionary new]; @@ -165,9 +175,12 @@ - (instancetype) initWithIdentifier:(NSString *)identifier info:(NSDictionary *) NSMutableArray *streamQueries = [[streamMap componentsSeparatedByString:@","] mutableCopy]; [streamQueries addObjectsFromArray:[adaptiveFormats componentsSeparatedByString:@","]]; - NSString *title = info[@"title"] ?: @""; + NSString *title = info[@"title"] == nil? videoDetails[@"title"] : info[@"title"]; + if (title == nil) + title = @""; _title = title; - _duration = [(NSString *)info[@"length_seconds"] doubleValue]; + + _duration = info[@"length_seconds"] == nil? [(NSString *)videoDetails[@"lengthSeconds"] doubleValue] : [(NSString *)info[@"length_seconds"] doubleValue]; NSString *thumbnail = info[@"thumbnail_url"] ?: info[@"iurl"]; _thumbnailURL = thumbnail ? [NSURL URLWithString:thumbnail] : nil;