diff --git a/CHANGELOG.md b/CHANGELOG.md
new file mode 100644
index 0000000..70e1668
--- /dev/null
+++ b/CHANGELOG.md
@@ -0,0 +1,9 @@
+### Version 1.1.0
+
+* The `streamURLs` and `thumbnailURLs` are now dictionaries that contain NSURLs ([e179efc](https://github.com/lilfaf/YTVimeoExtractor/commit/e179efc395ea8f287a9a9acb1b4b1398e92e24ce), [385ae37](https://github.com/lilfaf/YTVimeoExtractor/commit/385ae372660f52a0061b3c73f7d5df0cd5b33cc3))
+ * Add support for Objective-C generics
+* Add two methods to easily retrieve certain URLs from the `streamURLs` dictionary:
+ * `- highestQualityStreamURL` & `- lowestQualityStreamURL` ([d80f87b](https://github.com/lilfaf/YTVimeoExtractor/commit/d80f87b5e3f51dca8dbf8395278f5f706c2ad2a8))
+
+### Version 1.0.0
+* Intial version
diff --git a/README.md b/README.md
index 11eaf1c..ebae879 100644
--- a/README.md
+++ b/README.md
@@ -19,7 +19,7 @@ YTVimeoExtractor extracts the MP4 streams of Vimeo videos, which then can be use
|---------------|----------------|
| `YTVimeoExtractor` | The `YTVimeoExtractor` is the main class and its sole purpose is to fetch information about Vimeo videos. Use the two main methods `fetchVideoWithIdentifier:withReferer:completionHandler:` or `fetchVideoWithVimeoURL:withReferer:completionHandler:` to obtain video information. |
| `YTVimeoExtractorOperation` | `YTVimeoExtractorOperation` is a subclass of `NSOperation` and is used to fetch and parse out information about Vimeo videos. This a low level class. Generally speaking, you should use the higher level `YTVimeoExtractor` class. |
-|`YTVimeoURLParser` | `YTVimeoURLParser` is used to validate and parse put Vimeo URLs. The sole purpose of the class is to check if a given URL can be handled by the `YTVimeoExtractor` class.|
+|`YTVimeoURLParser` | `YTVimeoURLParser` is used to validate and parse put Vimeo URLs. The main purpose of the class is to check if a given URL can be handled by the `YTVimeoExtractor` class.|
|`YTVimeoVideo`| `YTVimeoVideo` represents a Vimeo video. Use this class to access information about a particular video. Generally, you should not initialize this class, instead use the two main methods of the `YTVimeoExtractor` class.|
## Installation
@@ -74,16 +74,22 @@ Use the two block methods in the `YTVimeoExtractor` class. Both methods will cal
if (video) {
- NSDictionary *streamURLs = video.streamURLs;
+ [self.titleTextField setStringValue:video.title];
+
+ //Will get the lowest available quality.
+ //NSURL *lowQualityURL = [video lowestQualityStreamURL];
+
//Will get the highest available quality.
- NSString *url = streamURLs[@(YTVimeoVideoQualityHD1080)] ?: streamURLs[@(YTVimeoVideoQualityHD720)] ?: streamURLs [@(YTVimeoVideoQualityMedium480)]?: streamURLs[@(YTVimeoVideoQualityMedium360)]?:streamURLs[@(YTVimeoVideoQualityLow270)];
+ NSURL *highQualityURL = [video highestQualityStreamURL];
+
- AVPlayer *player = [[AVPlayer alloc]initWithURL:[NSURL URLWithString:url]];
+ AVPlayer *player = [[AVPlayer alloc]initWithURL:highQualityURL];
self.playerView.player = player;
self.playerView.videoGravity = AVLayerVideoGravityResizeAspectFill;
[self.playerView.player play];
-
+ [self.playerView becomeFirstResponder];
+
}else{
[[NSAlert alertWithError:error]runModal];
@@ -91,6 +97,7 @@ Use the two block methods in the `YTVimeoExtractor` class. Both methods will cal
}];
+
```
### iOS Example
@@ -101,13 +108,15 @@ Use the two block methods in the `YTVimeoExtractor` class. Both methods will cal
if (video) {
- NSDictionary *streamURLs = video.streamURLs;
+ self.titleLabel.text = [NSString stringWithFormat:@"Video Title: %@",video.title];
+ //Will get the lowest available quality.
+ //NSURL *lowQualityURL = [video lowestQualityStreamURL];
+
//Will get the highest available quality.
- NSString *url = streamURLs[@(YTVimeoVideoQualityHD1080)] ?: streamURLs[@(YTVimeoVideoQualityHD720)] ?: streamURLs [@(YTVimeoVideoQualityMedium480)]?: streamURLs[@(YTVimeoVideoQualityMedium360)]?:streamURLs[@(YTVimeoVideoQualityLow270)];
+ NSURL *highQualityURL = [video highestQualityStreamURL];
- NSURL *movieURL = [NSURL URLWithString:url];
- MPMoviePlayerViewController *moviePlayerViewController = [[MPMoviePlayerViewController alloc]initWithContentURL:movieURL];
-
+ MPMoviePlayerViewController *moviePlayerViewController = [[MPMoviePlayerViewController alloc]initWithContentURL:highQualityURL];
+
[self presentMoviePlayerViewControllerAnimated:moviePlayerViewController];
}else{
@@ -132,12 +141,13 @@ If the Vimeo video has domain-level restrictions and can only be played from par
if (video) {
- NSDictionary *streamURLs = video.streamURLs;
+ //Will get the lowest available quality.
+ //NSURL *lowQualityURL = [video lowestQualityStreamURL];
+
//Will get the highest available quality.
- NSString *url = streamURLs[@(YTVimeoVideoQualityHD1080)] ?: streamURLs[@(YTVimeoVideoQualityHD720)] ?: streamURLs [@(YTVimeoVideoQualityMedium480)]?: streamURLs[@(YTVimeoVideoQualityMedium360)]?:streamURLs[@(YTVimeoVideoQualityLow270)];
+ NSURL *highQualityURL = [video highestQualityStreamURL];
- NSURL *movieURL = [NSURL URLWithString:url];
- MPMoviePlayerViewController *moviePlayerViewController = [[MPMoviePlayerViewController alloc]initWithContentURL:movieURL];
+ MPMoviePlayerViewController *moviePlayerViewController = [[MPMoviePlayerViewController alloc]initWithContentURL:highQualityURL];
[self presentMoviePlayerViewControllerAnimated:moviePlayerViewController];
}else{
diff --git a/YTVimeoExtractor Demo/YTVimeoExtractor OS X Demo/ViewController.m b/YTVimeoExtractor Demo/YTVimeoExtractor OS X Demo/ViewController.m
index 10511fc..df4d90c 100644
--- a/YTVimeoExtractor Demo/YTVimeoExtractor OS X Demo/ViewController.m
+++ b/YTVimeoExtractor Demo/YTVimeoExtractor OS X Demo/ViewController.m
@@ -29,12 +29,14 @@ - (IBAction)playAction:(id)sender {
[self.titleTextField setStringValue:video.title];
- NSDictionary *streamURLs = video.streamURLs;
+ //Will get the lowest available quality.
+ //NSURL *lowQualityURL = [video lowestQualityStreamURL];
+
//Will get the highest available quality.
- NSString *url = streamURLs[@(YTVimeoVideoQualityHD1080)] ?: streamURLs[@(YTVimeoVideoQualityHD720)] ?: streamURLs [@(YTVimeoVideoQualityMedium480)]?: streamURLs[@(YTVimeoVideoQualityMedium360)]?:streamURLs[@(YTVimeoVideoQualityLow270)];
+ NSURL *highQualityURL = [video highestQualityStreamURL];
- AVPlayer *player = [[AVPlayer alloc]initWithURL:[NSURL URLWithString:url]];
+ AVPlayer *player = [[AVPlayer alloc]initWithURL:highQualityURL];
self.playerView.player = player;
self.playerView.videoGravity = AVLayerVideoGravityResizeAspectFill;
diff --git a/YTVimeoExtractor Demo/YTVimeoExtractor iOS Demo/ViewController.m b/YTVimeoExtractor Demo/YTVimeoExtractor iOS Demo/ViewController.m
index 8978e57..9028371 100644
--- a/YTVimeoExtractor Demo/YTVimeoExtractor iOS Demo/ViewController.m
+++ b/YTVimeoExtractor Demo/YTVimeoExtractor iOS Demo/ViewController.m
@@ -35,12 +35,13 @@ -(IBAction)playVideoAction:(id)sender{
if (video) {
self.titleLabel.text = [NSString stringWithFormat:@"Video Title: %@",video.title];
- NSDictionary *streamURLs = video.streamURLs;
+ //Will get the lowest available quality.
+ //NSURL *lowQualityURL = [video lowestQualityStreamURL];
+
//Will get the highest available quality.
- NSString *url = streamURLs[@(YTVimeoVideoQualityHD1080)] ?: streamURLs[@(YTVimeoVideoQualityHD720)] ?: streamURLs [@(YTVimeoVideoQualityMedium480)]?: streamURLs[@(YTVimeoVideoQualityMedium360)]?:streamURLs[@(YTVimeoVideoQualityLow270)];
+ NSURL *highQualityURL = [video highestQualityStreamURL];
- NSURL *movieURL = [NSURL URLWithString:url];
- MPMoviePlayerViewController *moviePlayerViewController = [[MPMoviePlayerViewController alloc]initWithContentURL:movieURL];
+ MPMoviePlayerViewController *moviePlayerViewController = [[MPMoviePlayerViewController alloc]initWithContentURL:highQualityURL];
[self presentMoviePlayerViewControllerAnimated:moviePlayerViewController];
}else{
diff --git a/YTVimeoExtractor.podspec b/YTVimeoExtractor.podspec
index d46b506..c11d122 100644
--- a/YTVimeoExtractor.podspec
+++ b/YTVimeoExtractor.podspec
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = "YTVimeoExtractor"
- s.version = "1.0.0"
+ s.version = "1.1.0"
s.summary = "Fetches Vimeo's mp4 URLs for iOS."
s.description = <<-DESC
YTVimeoExtractor is a class which lets you get the iOS
@@ -10,7 +10,7 @@ Pod::Spec.new do |s|
s.homepage = "https://github.com/lilfaf/YTVimeoExtractor"
s.license = { :type => 'MIT', :file => 'LICENSE' }
s.author = { "Louis Larpin" => "louis.larpin@gmail.com" }
- s.source = { :git => "https://github.com/lilfaf/YTVimeoExtractor.git", :tag => "1.0.0" }
+ s.source = { :git => "https://github.com/lilfaf/YTVimeoExtractor.git", :tag => "1.1.0" }
s.ios.deployment_target = '7.0'
s.osx.deployment_target = '10.9'
diff --git a/YTVimeoExtractor/Info.plist b/YTVimeoExtractor/Info.plist
index 0bff09c..6be6456 100644
--- a/YTVimeoExtractor/Info.plist
+++ b/YTVimeoExtractor/Info.plist
@@ -15,11 +15,11 @@
CFBundlePackageType
FMWK
CFBundleShortVersionString
- 1.0.0
+ 1.1.0
CFBundleSignature
????
CFBundleVersion
- $(CURRENT_PROJECT_VERSION)
+ 1.1.0
NSHumanReadableCopyright
Copyright © 2015 Louis Larpin. All rights reserved.
NSPrincipalClass
diff --git a/YTVimeoExtractor/YTVimeoVideo.h b/YTVimeoExtractor/YTVimeoVideo.h
index 6fc40ab..ae93b7f 100644
--- a/YTVimeoExtractor/YTVimeoVideo.h
+++ b/YTVimeoExtractor/YTVimeoVideo.h
@@ -104,15 +104,29 @@ typedef NS_ENUM(NSUInteger, YTVimeoVideoQuality) {
* A `NSDictionary` object that contains the various stream URLs.
* @see YTVimeoVideoQuality
*/
-@property (nonatomic, readonly) NSDictionary *__nullable streamURLs;
+@property (nonatomic, readonly) NSDictionary *__nullable streamURLs;
/**
* A `NSDictionary` object that contains the various thumbnail URLs.
* @see YTVimeoVideoThumbnailQuality
*/
-@property (nonatomic, readonly) NSDictionary *__nullable thumbnailURLs;
+@property (nonatomic, readonly) NSDictionary *__nullable thumbnailURLs;
/**
* A `NSDictionary` object that contains all the metadata about the video.
*/
@property (nonatomic, readonly) NSDictionary *__nullable metaData;
+/**
+ * Get the highest quality stream URL.
+ *
+ * @see YTVimeoVideoQuality
+ * @return The highest quality stream URL.
+ */
+-(NSURL *__nullable)highestQualityStreamURL;
+/**
+ * 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 beddfbf..05a5d8a 100644
--- a/YTVimeoExtractor/YTVimeoVideo.m
+++ b/YTVimeoExtractor/YTVimeoVideo.m
@@ -72,11 +72,12 @@ - (void)extractVideoInfoWithCompletionHandler:(void (^)(NSError *error))completi
NSInteger quality = [[info valueForKey:@"quality"]integerValue];
NSString *urlString = info[@"url"];
+ NSURL *url = [NSURL URLWithString:urlString];
//Only if the file is playable on OS X or iOS natively
if([urlString rangeOfString:@".mp4"].location != NSNotFound){
- streamURLs[@(quality)] = urlString;
+ streamURLs[@(quality)] = url;
}
}
@@ -97,7 +98,8 @@ - (void)extractVideoInfoWithCompletionHandler:(void (^)(NSError *error))completi
for (NSString *key in thumbnailsInfo) {
NSInteger thumbnailquality = [key integerValue];
- NSString *thumbnailURL = thumbnailsInfo[key];
+ NSString *thumbnailString = thumbnailsInfo[key];
+ NSURL *thumbnailURL = [NSURL URLWithString:thumbnailString];
thumbnailURLs [@(thumbnailquality)] = thumbnailURL;
}
@@ -108,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
diff --git a/YTVimeoExtractorTests/YTVimeoVideoTestCase.m b/YTVimeoExtractorTests/YTVimeoVideoTestCase.m
index a7c5f6b..f46a28b 100644
--- a/YTVimeoExtractorTests/YTVimeoVideoTestCase.m
+++ b/YTVimeoExtractorTests/YTVimeoVideoTestCase.m
@@ -80,6 +80,35 @@ -(void)testThumbnails{
[self waitForExpectationsWithTimeout:15 handler:nil];
}
+-(void)testConvenienceMethods{
+ __weak XCTestExpectation *expectation = [self expectationWithDescription:@""];
+
+ NSString *filePath = [[[NSBundle bundleForClass:[self class]] resourcePath] stringByAppendingPathComponent:@"testdata.plist"];
+
+ NSData *buffer = [NSData dataWithContentsOfFile:filePath];
+ NSDictionary *myDictionary = (NSDictionary*) [NSKeyedUnarchiver unarchiveObjectWithData:buffer];
+
+ YTVimeoVideo *video = [[YTVimeoVideo alloc]initWithIdentifier:@"147318819" info:myDictionary];
+
+ [video extractVideoInfoWithCompletionHandler:^(NSError * _Nullable error) {
+
+ XCTAssertNotNil(video.streamURLs);
+
+ NSURL *highestURL = video.streamURLs[@(YTVimeoVideoQualityHD1080)] ?: video.streamURLs[@(YTVimeoVideoQualityHD720)] ?: video.streamURLs [@(YTVimeoVideoQualityMedium480)]?: video.streamURLs[@(YTVimeoVideoQualityMedium360)]?:video.streamURLs[@(YTVimeoVideoQualityLow270)];
+
+ NSURL *lowestURL = video.streamURLs[@(YTVimeoVideoQualityLow270)] ?: video.streamURLs[@(YTVimeoVideoQualityMedium360)] ?: video.streamURLs[@(YTVimeoVideoQualityMedium480)]?: video.streamURLs[@(YTVimeoVideoQualityHD720)]?:video.streamURLs[@(YTVimeoVideoQualityHD1080)];
+
+ XCTAssertEqual(highestURL, [video highestQualityStreamURL]);
+
+ XCTAssertEqual(lowestURL, [video lowestQualityStreamURL]);
+
+
+ [expectation fulfill];
+ }];
+
+ [self waitForExpectationsWithTimeout:15 handler:nil];
+}
+
/*
-(void)testUnsuitableStreamThatAlsoHasSuitableStreams{
__weak XCTestExpectation *expectation = [self expectationWithDescription:@""];