File tree Expand file tree Collapse file tree 1 file changed +12
-18
lines changed
Expand file tree Collapse file tree 1 file changed +12
-18
lines changed Original file line number Diff line number Diff line change @@ -48,29 +48,23 @@ + (NSURL *)getPhotoUrlForMedia:(IGMedia *)media {
4848
4949 return [SCIUtils getPhotoUrl: photo];
5050}
51-
5251+ (NSURL *)getVideoUrl : (IGVideo *)video {
5352 if (!video) return nil ;
54-
55- // Before Instagram v398
53+
54+ // The past (pre v398)
5655 if ([video respondsToSelector: @selector (sortedVideoURLsBySize )]) {
57- // Sort videos by quality
58- NSArray <NSDictionary *> *sortedVideoUrls = [video sortedVideoURLsBySize ];
59- if ([sortedVideoUrls count ] < 1 || sortedVideoUrls[0 ] == nil ) return nil ;
60-
61- // First element in array is highest quality
62- NSURL *videoUrl = [NSURL URLWithString: [sortedVideoUrls[0 ] objectForKey: @" url" ]];
63-
64- return videoUrl;
56+ NSArray <NSDictionary *> *sorted = [video sortedVideoURLsBySize ];
57+ NSString *urlString = sorted.firstObject [@" url" ];
58+ return urlString.length ? [NSURL URLWithString: urlString] : nil ;
6559 }
66-
67- // After Instagram v398
68- else if ([video respondsToSelector: @selector (allVideoURLs )]) {
69- // Get first video url, using janky workaround
70- NSSet *allVideoSet = [video allVideoURLs ];
71-
72- return [allVideoSet anyObject ];
60+
61+ // The present (post v398)
62+ if ([video respondsToSelector: @selector (allVideoURLs )]) {
63+ return [[video allVideoURLs ] anyObject ];
7364 }
65+
66+ // The future
67+ return nil ;
7468}
7569+ (NSURL *)getVideoUrlForMedia : (IGMedia *)media {
7670 if (!media) return nil ;
You can’t perform that action at this time.
0 commit comments