Commit 6c0070f4 authored by Felix Paul Kühne's avatar Felix Paul Kühne

Demo show case for MetaDataFetcherKit

parent 5fdc2f26
......@@ -30,5 +30,6 @@ pod 'SSKeychain', :git => 'git://github.com/fkuehne/sskeychain.git' #iCloud Keyc
pod 'box-ios-sdk-v2', :git => 'git://github.com/fkuehne/box-ios-sdk-v2.git' #has tvOS support added
pod 'upnpx', '~>1.3.6'
pod 'CocoaHTTPServer', :git => 'git://github.com/fkuehne/CocoaHTTPServer.git' # has our fixes
pod 'MetaDataFetcherKit'
end
PODS:
- AFNetworking (3.0.0-beta.1):
- AFNetworking/NSURLSession (= 3.0.0-beta.1)
- AFNetworking/Reachability (= 3.0.0-beta.1)
- AFNetworking/Security (= 3.0.0-beta.1)
- AFNetworking/Serialization (= 3.0.0-beta.1)
- AFNetworking/UIKit (= 3.0.0-beta.1)
- AFNetworking/NSURLSession (3.0.0-beta.1):
- AFNetworking/Reachability
- AFNetworking/Security
- AFNetworking/Serialization
- AFNetworking/Reachability (3.0.0-beta.1)
- AFNetworking/Security (3.0.0-beta.1)
- AFNetworking/Serialization (3.0.0-beta.1)
- AFNetworking/UIKit (3.0.0-beta.1):
- AFNetworking/NSURLSession
- box-ios-sdk-v2 (1.2.3):
- box-ios-sdk-v2/no-arc (= 1.2.3)
- box-ios-sdk-v2/no-arc (1.2.3)
- CocoaHTTPServer (2.3)
- HockeySDK (3.6.4)
- InAppSettingsKit (2.2.2)
- MetaDataFetcherKit (0.1.0):
- AFNetworking (= 3.0.0-beta.1)
- OBSlider (1.1.0)
- RESideMenu (4.0.7)
- SSKeychain (1.2.3)
......@@ -16,6 +33,7 @@ DEPENDENCIES:
- HockeySDK (~> 3.6.4)
- InAppSettingsKit (from `git://github.com/fkuehne/InAppSettingsKit.git`, commit
`415ea6bb`)
- MetaDataFetcherKit
- OBSlider (= 1.1.0)
- RESideMenu (~> 4.0.7)
- SSKeychain (from `git://github.com/fkuehne/sskeychain.git`)
......@@ -47,10 +65,12 @@ CHECKOUT OPTIONS:
:git: git://github.com/fkuehne/sskeychain.git
SPEC CHECKSUMS:
AFNetworking: 1100906802d9479aa0949e8e2cbc1d4e6beba327
box-ios-sdk-v2: 9423bd75373350ea40b92f3d2d6e89f81d96d634
CocoaHTTPServer: 07df8b05a8bde406fe367d22c90a24a2fd4ca49f
HockeySDK: c07cdd580296737edcd0963e292c19885a53f563
InAppSettingsKit: 76d5cfbaa3e3f8aa53fe3628516da7eb1aa6a5cb
MetaDataFetcherKit: c28ea384506120500f7c84b29557ac9b079c3f89
OBSlider: 490f108007bfdd5414a38650b211fe403a95b8a0
RESideMenu: f24c508404b49c667344c54aba7e590883533958
SSKeychain: 3f42991739c6c60a9cf1bbd4dff6c0d3694bcf3d
......
......@@ -13,6 +13,7 @@
#import "VLCServerBrowsingController.h"
#import "NSString+SupportedMedia.h"
#import "UIDevice+VLC.h"
#import "MetaDataFetcherKit.h"
#import "VLCPlaybackController.h"
......@@ -32,6 +33,9 @@
if (self) {
_viewController = viewController;
_serverBrowser = browser;
MDFMovieDBSessionManager *movieDBSessionManager = [MDFMovieDBSessionManager sharedInstance];
movieDBSessionManager.apiKey = kVLCfortvOSMovieDBKey;
[movieDBSessionManager fetchProperties];
}
return self;
}
......@@ -91,14 +95,13 @@
#if DOWNLOAD_SUPPORTED
cell.isDownloadable = self.allowsFileDownload;
#endif
NSURL *thumbnailURL = nil;
if ([item respondsToSelector:@selector(thumbnailURL)]) {
thumbnailURL = item.thumbnailURL;
}
if (thumbnailURL) {
[cell setThumbnailURL:thumbnailURL];
}
[cell setThumbnailURL:thumbnailURL];
}
}
......
......@@ -37,7 +37,6 @@
- (instancetype)initWithPath:(NSString *)path
{
NSLog(@"%s", __PRETTY_FUNCTION__);
self = [super init];
if (self) {
self.currentPath = path;
......
......@@ -16,7 +16,10 @@
extern NSString *const VLCServerBrowsingTVCellIdentifier;
@interface VLCServerBrowsingTVCell : UITableViewCell <VLCServerBrowsingCell>
@property (nonatomic, weak) IBOutlet VLCNetworkImageView *thumbnailImageView;
@property (nonatomic, weak) IBOutlet UILabel *titleLabel;
@property (nonatomic, weak) IBOutlet UILabel *subtitleLabel;
@property (nonatomic) BOOL isShowingAContainer;
@end
......@@ -10,50 +10,149 @@
*****************************************************************************/
#import "VLCServerBrowsingTVCell.h"
#import "MetaDataFetcherKit.h"
NSString *const VLCServerBrowsingTVCellIdentifier = @"VLCServerBrowsingTVCell";
@interface VLCServerBrowsingTVCell () <MDFMovieDBFetcherDataRecipient>
{
MDFMovieDBFetcher *_metadataFetcher;
}
@end
@implementation VLCServerBrowsingTVCell
@synthesize thumbnailURL = _thumbnailURL, isDirectory = _isDirectory;
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
return [super initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:reuseIdentifier];
}
- (void)setThumbnailURL:(NSURL *)thumbnailURL {
- (void)awakeFromNib
{
[super awakeFromNib];
[self prepareForReuse];
}
- (void)prepareForReuse
{
[super prepareForReuse];
if (_metadataFetcher) {
[_metadataFetcher cancelAllRequests];
} else {
_metadataFetcher = [[MDFMovieDBFetcher alloc] init];
_metadataFetcher.dataRecipient = self;
}
[self.thumbnailImageView cancelLoading];
self.title = nil;
self.subtitle = nil;
}
- (void)setThumbnailURL:(NSURL *)thumbnailURL
{
_thumbnailURL = thumbnailURL;
[self.thumbnailImageView setImageWithURL:thumbnailURL];
if (_thumbnailURL) {
[self.thumbnailImageView setImageWithURL:thumbnailURL];
} else {
NSString *searchString = self.title;
if (searchString != nil && !_isDirectory) {
[_metadataFetcher searchForMovie:searchString];
}
}
}
- (void)setThumbnailImage:(UIImage *)thumbnailImage {
- (void)setThumbnailImage:(UIImage *)thumbnailImage
{
[self.thumbnailImageView setImage:thumbnailImage];
}
-(UIImage *)thumbnailImage {
-(UIImage *)thumbnailImage
{
return self.thumbnailImageView.image;
}
- (void)setTitle:(NSString *)title {
- (void)setTitle:(NSString *)title
{
self.titleLabel.text = title;
if (title != nil && !_isDirectory) {
[_metadataFetcher searchForMovie:title];
}
}
- (NSString *)title {
- (NSString *)title
{
return self.titleLabel.text;
}
- (void)setSubtitle:(NSString *)subtitle {
- (void)setSubtitle:(NSString *)subtitle
{
self.subtitleLabel.text = subtitle;
}
- (NSString *)subtitle {
- (NSString *)subtitle
{
return self.subtitleLabel.text;
}
- (void)awakeFromNib {
[super awakeFromNib];
[self prepareForReuse];
- (void)MDFMovieDBFetcher:(MDFMovieDBFetcher *)aFetcher didFindMovie:(MDFMovie *)details forSearchRequest:(NSString *)searchRequest
{
if (details == nil)
return;
[aFetcher cancelAllRequests];
MDFMovieDBSessionManager *sessionManager = [MDFMovieDBSessionManager sharedInstance];
if (!sessionManager.hasFetchedProperties)
return;
if (details.movieDBID == 0) {
/* we found nothing, let's see if it's a TV show */
[_metadataFetcher searchForTVShow:searchRequest];
return;
}
NSString *imagePath = details.posterPath;
if (!imagePath)
imagePath = details.backdropPath;
if (!imagePath)
return;
NSString *thumbnailURLString = [NSString stringWithFormat:@"%@%@%@",
sessionManager.imageBaseURL,
sessionManager.posterSizes.firstObject,
details.posterPath];
self.thumbnailURL = [NSURL URLWithString:thumbnailURLString];
}
- (void)prepareForReuse {
[super prepareForReuse];
[self.thumbnailImageView cancelLoading];
self.title = nil;
self.subtitle = nil;
- (void)MDFMovieDBFetcher:(MDFMovieDBFetcher *)aFetcher didFailToFindMovieForSearchRequest:(NSString *)searchRequest
{
APLog(@"Failed to find a movie for '%@'", searchRequest);
}
@end
-(void)MDFMovieDBFetcher:(MDFMovieDBFetcher *)aFetcher didFindTVShow:(MDFTVShow *)details forSearchRequest:(NSString *)searchRequest
{
if (details == nil)
return;
[aFetcher cancelAllRequests];
MDFMovieDBSessionManager *sessionManager = [MDFMovieDBSessionManager sharedInstance];
if (!sessionManager.hasFetchedProperties)
return;
NSString *imagePath = details.posterPath;
if (!imagePath)
imagePath = details.backdropPath;
if (!imagePath)
return;
NSString *thumbnailURLString = [NSString stringWithFormat:@"%@%@%@",
sessionManager.imageBaseURL,
sessionManager.posterSizes.firstObject,
details.posterPath];
self.thumbnailURL = [NSURL URLWithString:thumbnailURLString];
}
- (void)MDFMovieDBFetcher:(MDFMovieDBFetcher *)aFetcher didFailToFindTVShowForSearchRequest:(NSString *)searchRequest
{
APLog(@"failed to find TV show");
}
@end
......@@ -240,7 +240,6 @@
- (void)discoveryFoundSomethingNew
{
[self.tableView reloadData];
NSLog(@"%s",__PRETTY_FUNCTION__);
_nothingFoundLabel.hidden = self.discoveryController.foundAnythingAtAll;
}
......
......@@ -65,5 +65,7 @@
#if TARGET_IPHONE_SIMULATOR
#define WifiInterfaceName @"en1"
#else
#define WifiInterfaceName @"en0"
#define WifiInterfaceName @"en1"
#endif
#define kVLCfortvOSMovieDBKey @""
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment