Skip to content
This repository has been archived by the owner on Mar 29, 2022. It is now read-only.

Update key for thumbnail url and Prevent crashing #70

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions YoutubeParser/Classes/HCYoutubeParser.m
Original file line number Diff line number Diff line change
Expand Up @@ -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
@"thumbnail_url", //@"iurl", //@"iurlmaxres", @"iurlsd", // thumbnail urls
//@"keywords", // author defined keywords
@"length_seconds", // total duration in seconds
@"title", // video title
Expand All @@ -168,7 +168,10 @@ + (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
NSArray* value = parts[key];
if (value && value.count > 0) {
[optionsDict setObject:value[0] forKey:key]; // [0] because we want the object and not the array
}
}

[videoDictionary setObject:optionsDict forKey:@"moreInfo"];
Expand Down