From d80f87b5e3f51dca8dbf8395278f5f706c2ad2a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sone=C3=A9=20John?= Date: Sun, 27 Dec 2015 11:46:01 -0400 Subject: [PATCH] Add two convenience methods - These are used to quickly extract specific streams. For example, you can now quickly get the highest stream URL or the lowest stream URL. --- YTVimeoExtractor/YTVimeoVideo.h | 14 ++++++++++++++ YTVimeoExtractor/YTVimeoVideo.m | 14 ++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/YTVimeoExtractor/YTVimeoVideo.h b/YTVimeoExtractor/YTVimeoVideo.h index 9779ff7..aac4c9a 100644 --- a/YTVimeoExtractor/YTVimeoVideo.h +++ b/YTVimeoExtractor/YTVimeoVideo.h @@ -114,5 +114,19 @@ typedef NS_ENUM(NSUInteger, YTVimeoVideoQuality) { * A `NSDictionary` object that contains all the metadata about the video. */ @property (nonatomic, readonly) NSDictionary *__nullable metaData; +/** + * Convenience method to get the highest quality stream URL. + * + * @see YTVimeoVideoQuality + * @return The highest quality stream URL. + */ +-(NSURL *__nullable)highestQualityStreamURL; +/** + * Convenience method to get the lowest quality stream URL. + * + * @see YTVimeoVideoQuality + * @return The lowest quality stream URL. + */ +-(NSURL *__nullable)lowestQualityStreamURL; @end diff --git a/YTVimeoExtractor/YTVimeoVideo.m b/YTVimeoExtractor/YTVimeoVideo.m index d188e43..05a5d8a 100644 --- a/YTVimeoExtractor/YTVimeoVideo.m +++ b/YTVimeoExtractor/YTVimeoVideo.m @@ -110,6 +110,20 @@ - (void)extractVideoInfoWithCompletionHandler:(void (^)(NSError *error))completi }); } +#pragma mark - +-(NSURL *)highestQualityStreamURL{ + + NSURL *url = self.streamURLs[@(YTVimeoVideoQualityHD1080)] ?: self.streamURLs[@(YTVimeoVideoQualityHD720)] ?: self.streamURLs [@(YTVimeoVideoQualityMedium480)]?: self.streamURLs[@(YTVimeoVideoQualityMedium360)]?:self.streamURLs[@(YTVimeoVideoQualityLow270)]; + + return url; +} + +-(NSURL *)lowestQualityStreamURL{ + + NSURL *url = self.streamURLs[@(YTVimeoVideoQualityLow270)] ?: self.streamURLs[@(YTVimeoVideoQualityMedium360)] ?: self.streamURLs [@(YTVimeoVideoQualityMedium480)]?: self.streamURLs[@(YTVimeoVideoQualityHD720)]?:self.streamURLs[@(YTVimeoVideoQualityHD1080)]; + + return url; +} #pragma mark - NSObject - (NSString *) description