From 641284e1846959da15b3c05002100a9f55eb74b0 Mon Sep 17 00:00:00 2001 From: smudgeio Date: Tue, 20 Jun 2017 14:44:23 +0800 Subject: [PATCH 1/2] Resolver crash caused by missing iurl Resolve crash caused by iurl not being set in the parts dictionary when setting the options dictionary. *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** setObjectForKey: object cannot be nil (key: iurl)' --- YoutubeParser/Classes/HCYoutubeParser.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/YoutubeParser/Classes/HCYoutubeParser.m b/YoutubeParser/Classes/HCYoutubeParser.m index 079e05b..4f75849 100644 --- a/YoutubeParser/Classes/HCYoutubeParser.m +++ b/YoutubeParser/Classes/HCYoutubeParser.m @@ -159,7 +159,7 @@ + (NSDictionary *)h264videosWithYoutubeID:(NSString *)youtubeID { NSMutableDictionary *optionsDict = [NSMutableDictionary dictionary]; NSArray *keys = @[//@"author", // youtube channel name //@"avg_rating", // average ratings on yt when downloaded - @"iurl", //@"iurlmaxres", @"iurlsd", // thumbnail urls + //@"iurl", //@"iurlmaxres", @"iurlsd", // thumbnail urls //@"keywords", // author defined keywords @"length_seconds", // total duration in seconds @"title", // video title From b0cfb62d339d776d5a3883e1c401ac21d7d54102 Mon Sep 17 00:00:00 2001 From: smudgeio Date: Tue, 20 Jun 2017 16:29:43 +0800 Subject: [PATCH 2/2] Resolve crash for missing attributes Check if a key exists prior to adding it to the options dictionary. --- YoutubeParser/Classes/HCYoutubeParser.m | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/YoutubeParser/Classes/HCYoutubeParser.m b/YoutubeParser/Classes/HCYoutubeParser.m index 4f75849..aee5626 100644 --- a/YoutubeParser/Classes/HCYoutubeParser.m +++ b/YoutubeParser/Classes/HCYoutubeParser.m @@ -168,7 +168,9 @@ + (NSDictionary *)h264videosWithYoutubeID:(NSString *)youtubeID { for (NSString *key in keys) { - [optionsDict setObject:parts[key][0] forKey:key]; // [0] because we want the object and not the array + if ([parts objectForKey:key]) { + [optionsDict setObject:parts[key][0] forKey:key]; // [0] because we want the object and not the array + } } [videoDictionary setObject:optionsDict forKey:@"moreInfo"];