Commit 1df9c92a authored by Felix Paul Kühne's avatar Felix Paul Kühne

Remove Hatchet integration based on MetaDataFetcherKit as the service is gone...

Remove Hatchet integration based on MetaDataFetcherKit as the service is gone and won't come back (and so will be its API in the next version of MDF)
parent cfe79e68
......@@ -15,7 +15,6 @@
#import "VLCIRTVTapGestureRecognizer.h"
#import "VLCHTTPUploaderController.h"
#import "VLCSiriRemoteGestureRecognizer.h"
#import "MetaDataFetcherKit.h"
#import "VLCNetworkImageView.h"
typedef NS_ENUM(NSInteger, VLCPlayerScanState)
......@@ -28,7 +27,7 @@ typedef NS_ENUM(NSInteger, VLCPlayerScanState)
@interface VLCFullscreenMovieTVViewController (UIViewControllerTransitioningDelegate) <UIViewControllerTransitioningDelegate, UIGestureRecognizerDelegate>
@end
@interface VLCFullscreenMovieTVViewController () <MDFHatchetFetcherDataRecipient>
@interface VLCFullscreenMovieTVViewController ()
@property (nonatomic) CADisplayLink *displayLink;
@property (nonatomic) NSTimer *audioDescriptionScrollTimer;
......@@ -36,7 +35,6 @@ typedef NS_ENUM(NSInteger, VLCPlayerScanState)
@property (nonatomic) VLCPlaybackInfoTVViewController *infoViewController;
@property (nonatomic) NSNumber *scanSavedPlaybackRate;
@property (nonatomic) VLCPlayerScanState scanState;
@property (nonatomic) MDFHatchetFetcher *audioMetaDataFetcher;
@property (nonatomic) NSString *lastArtist;
@property (nonatomic, readonly, getter=isSeekable) BOOL seekable;
......@@ -850,13 +848,6 @@ currentMediaHasTrackToChooseFrom:(BOOL)currentMediaHasTrackToChooseFrom
self.audioDescriptionTextView.hidden = YES;
[self stopAudioDescriptionAnimation];
if (!self.audioMetaDataFetcher) {
self.audioMetaDataFetcher = [[MDFHatchetFetcher alloc] init];
self.audioMetaDataFetcher.dataRecipient = self;
}
[self.audioMetaDataFetcher cancelAllRequests];
if (artist != nil && album != nil) {
[UIView animateWithDuration:.3 animations:^{
self.audioArtistLabel.text = artist;
......@@ -896,17 +887,10 @@ currentMediaHasTrackToChooseFrom:(BOOL)currentMediaHasTrackToChooseFrom
self.audioTitleLabel.text = title;
self.audioTitleLabel.hidden = NO;
if (artist != nil) {
if (album != nil) {
[self.audioMetaDataFetcher searchForAlbum:album ofArtist:artist];
} else
[self.audioMetaDataFetcher searchForArtist:artist];
}
[UIView animateWithDuration:0.3 animations:^{
self.audioView.hidden = NO;
}];
} else if (!self.audioView.hidden) {
[self.audioMetaDataFetcher cancelAllRequests];
self.audioView.hidden = YES;
self.audioArtworkImageView.image = nil;
[self.audioLargeBackgroundImageView stopAnimating];
......@@ -947,113 +931,6 @@ currentMediaHasTrackToChooseFrom:(BOOL)currentMediaHasTrackToChooseFrom
return [self.simultaneousGestureRecognizers containsObject:gestureRecognizer];
}
#pragma mark - meta data recipient
- (void)MDFHatchetFetcher:(MDFHatchetFetcher * _Nonnull)aFetcher
didFindAlbum:(MDFMusicAlbum * _Nonnull)album
byArtist:(MDFArtist * _Nullable)artist
forSearchRequest:(NSString *)searchRequest
{
/* we have no match */
if (!artist) {
[self _simplifyMetaDataSearchString:searchRequest];
return;
}
if (artist.biography) {
[self scrollAudioDescriptionAnimationToTop];
[UIView animateWithDuration:.3 animations:^{
self.audioDescriptionTextView.hidden = NO;
self.audioDescriptionTextView.text = artist.biography;
}];
[self startAudioDescriptionAnimation];
} else
[self stopAudioDescriptionAnimation];
NSString *imageURLString = album.artworkImage;
if (!imageURLString) {
NSArray *imageURLStrings = album.largeSizedArtistImages;
if (imageURLStrings.count > 0) {
imageURLString = imageURLStrings.firstObject;
} else {
imageURLStrings = artist.mediumSizedImages;
if (imageURLStrings.count > 0) {
imageURLString = imageURLStrings.firstObject;
}
}
}
if (imageURLString) {
[self.audioArtworkImageView setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@?height=500&width=500", imageURLString]]];
[self.audioLargeBackgroundImageView setImageWithURL:[NSURL URLWithString:imageURLString]];
} else {
UIImage *dummyImage = [UIImage imageNamed:@"about-app-icon"];
self.audioArtworkImageView.image = dummyImage;
self.audioLargeBackgroundImageView.image = dummyImage;
[self _simplifyMetaDataSearchString:searchRequest];
}
}
- (void)MDFHatchetFetcher:(MDFHatchetFetcher *)aFetcher didFailToFindAlbum:(NSString *)albumName forArtistName:(NSString *)artistName
{
APLog(@"%s: %@ %@", __PRETTY_FUNCTION__, albumName, artistName);
UIImage *dummyImage = [UIImage imageNamed:@"about-app-icon"];
self.audioArtworkImageView.image = dummyImage;
self.audioLargeBackgroundImageView.image = dummyImage;
}
- (void)MDFHatchetFetcher:(MDFHatchetFetcher *)aFetcher didFindArtist:(MDFArtist *)artist forSearchRequest:(NSString *)searchRequest
{
/* we have no match */
if (!artist) {
[self _simplifyMetaDataSearchString:searchRequest];
return;
}
if (artist.biography) {
[self scrollAudioDescriptionAnimationToTop];
[UIView animateWithDuration:.3 animations:^{
self.audioDescriptionTextView.text = artist.biography;
self.audioDescriptionTextView.hidden = NO;
}];
[self startAudioDescriptionAnimation];
} else
[self stopAudioDescriptionAnimation];
NSArray *imageURLStrings = artist.largeSizedImages;
NSString *imageURLString;
if (imageURLStrings.count > 0) {
imageURLString = imageURLStrings.firstObject;
} else {
imageURLStrings = artist.mediumSizedImages;
if (imageURLStrings.count > 0) {
imageURLString = imageURLStrings.firstObject;
}
}
if (imageURLString) {
[self.audioArtworkImageView setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@?height=500&width=500",imageURLString]]];
[self.audioLargeBackgroundImageView setImageWithURL:[NSURL URLWithString:imageURLString]];
} else {
[self _simplifyMetaDataSearchString:searchRequest];
}
}
- (void)_simplifyMetaDataSearchString:(NSString *)searchString
{
NSRange lastRange = [searchString rangeOfString:@" " options:NSBackwardsSearch];
if (lastRange.location != NSNotFound)
[self.audioMetaDataFetcher searchForArtist:[searchString substringToIndex:lastRange.location]];
}
- (void)MDFHatchetFetcher:(MDFHatchetFetcher *)aFetcher didFailToFindArtistForSearchRequest:(NSString *)searchRequest
{
APLog(@"%s: %@", __PRETTY_FUNCTION__, searchRequest);
UIImage *dummyImage = [UIImage imageNamed:@"about-app-icon"];
self.audioArtworkImageView.image = dummyImage;
self.audioLargeBackgroundImageView.image = dummyImage;
}
- (void)scrollAudioDescriptionAnimationToTop
{
[self stopAudioDescriptionAnimation];
......
......@@ -12,10 +12,9 @@
#import "VLCMDFBrowsingArtworkProvider.h"
#import "MetaDataFetcherKit.h"
@interface VLCMDFBrowsingArtworkProvider () <MDFMovieDBFetcherDataRecipient, MDFHatchetFetcherDataRecipient>
@interface VLCMDFBrowsingArtworkProvider () <MDFMovieDBFetcherDataRecipient>
{
MDFMovieDBFetcher *_tmdbFetcher;
MDFHatchetFetcher *_hatchetFetcher;
}
@end
......@@ -26,27 +25,16 @@
{
if (_tmdbFetcher) {
[_tmdbFetcher cancelAllRequests];
if (_hatchetFetcher)
[_hatchetFetcher cancelAllRequests];
} else {
_tmdbFetcher = [[MDFMovieDBFetcher alloc] init];
_tmdbFetcher.dataRecipient = self;
_tmdbFetcher.shouldDecrapifyInputStrings = YES;
if (_searchForAudioMetadata) {
_hatchetFetcher = [[MDFHatchetFetcher alloc] init];
_hatchetFetcher.dataRecipient = self;
}
}
}
- (void)setSearchForAudioMetadata:(BOOL)searchForAudioMetadata
{
if (searchForAudioMetadata) {
_hatchetFetcher = [[MDFHatchetFetcher alloc] init];
_hatchetFetcher.dataRecipient = self;
}
_searchForAudioMetadata = searchForAudioMetadata;
NSLog(@"there is currently no audio metadata fetcher :-(");
}
- (void)searchForArtworkForVideoRelatedString:(NSString *)string
......@@ -107,18 +95,11 @@
- (void)MDFMovieDBFetcher:(MDFMovieDBFetcher *)aFetcher didFailToFindMovieForSearchRequest:(NSString *)searchRequest
{
APLog(@"Failed to find a movie for '%@'", searchRequest);
if (_searchForAudioMetadata) {
[_hatchetFetcher searchForArtist:searchRequest];
}
}
- (void)MDFMovieDBFetcher:(MDFMovieDBFetcher *)aFetcher didFindTVShow:(MDFTVShow *)details forSearchRequest:(NSString *)searchRequest
{
if (details == nil) {
if (_searchForAudioMetadata) {
[_hatchetFetcher searchForArtist:searchRequest];
}
return;
}
......@@ -148,9 +129,6 @@
}
}
if (!imagePath) {
if (_searchForAudioMetadata) {
[_hatchetFetcher searchForArtist:searchRequest];
}
return;
}
......@@ -164,49 +142,6 @@
- (void)MDFMovieDBFetcher:(MDFMovieDBFetcher *)aFetcher didFailToFindTVShowForSearchRequest:(NSString *)searchRequest
{
APLog(@"failed to find TV show");
if (_searchForAudioMetadata) {
[_hatchetFetcher searchForArtist:searchRequest];
}
}
- (void)MDFHatchetFetcher:(MDFHatchetFetcher *)aFetcher didFindArtist:(MDFArtist *)artist forSearchRequest:(NSString *)searchRequest
{
/* we have no match */
if (!artist) {
[self _simplifyMetaDataSearchString:searchRequest];
return;
}
NSArray *imageURLStrings = artist.largeSizedImages;
NSString *imageURLString;
if (imageURLStrings.count > 0) {
imageURLString = imageURLStrings.firstObject;
} else {
imageURLStrings = artist.mediumSizedImages;
if (imageURLStrings.count > 0) {
imageURLString = imageURLStrings.firstObject;
}
}
if (imageURLString) {
self.artworkReceiver.thumbnailURL = [NSURL URLWithString:[NSString stringWithFormat:@"%@?height=300&width=250",imageURLString]];
} else {
[self _simplifyMetaDataSearchString:searchRequest];
}
}
- (void)MDFHatchetFetcher:(MDFHatchetFetcher *)aFetcher didFailToFindArtistForSearchRequest:(NSString *)searchRequest
{
[self _simplifyMetaDataSearchString:searchRequest];
}
- (void)_simplifyMetaDataSearchString:(NSString *)searchString
{
NSRange lastRange = [searchString rangeOfString:@" " options:NSBackwardsSearch];
if (lastRange.location != NSNotFound)
[_hatchetFetcher searchForArtist:[searchString substringToIndex:lastRange.location]];
}
@end
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