Commit 7c6213fe authored by Felix Paul Kühne's avatar Felix Paul Kühne

Remove support for Hatchet as the service is gone and will not come back :-(

parent d4302a1b
......@@ -62,11 +62,9 @@
81B617F8D26BB10C5726D75E85D21EB7 /* UIButton+AFNetworking.h in Headers */ = {isa = PBXBuildFile; fileRef = 9B8AFD157ABB2E7A49B2A75ABBE339FC /* UIButton+AFNetworking.h */; settings = {ATTRIBUTES = (Public, ); }; };
88AFBE1168EF2949584C8BE347D4ECAA /* XMLRPCEventBasedParser.m in Sources */ = {isa = PBXBuildFile; fileRef = D033C444318272393EB990213F6437AA /* XMLRPCEventBasedParser.m */; settings = {COMPILER_FLAGS = "-DOS_OBJECT_USE_OBJC=0"; }; };
8AB1F0E6EB62D96D3BC7CD6D0CF910DA /* XMLRPCEventBasedParser.h in Headers */ = {isa = PBXBuildFile; fileRef = FB50F53A6DB07082C9CCE2180325160D /* XMLRPCEventBasedParser.h */; settings = {ATTRIBUTES = (Public, ); }; };
987D68B5280109911FB78F0A800E8C58 /* MDFHatchetSessionManager.m in Sources */ = {isa = PBXBuildFile; fileRef = E37FC4B18FCCB4FB36F315EB11463FB6 /* MDFHatchetSessionManager.m */; };
9A036AFD32034D75E4F56CEC26CD4531 /* NSStringAdditions.h in Headers */ = {isa = PBXBuildFile; fileRef = 83B289AA105F5FB708382A91F64E4324 /* NSStringAdditions.h */; settings = {ATTRIBUTES = (Public, ); }; };
9C3D3893DCBDE01370F78BB383435523 /* NSData+Base64-umbrella.h in Headers */ = {isa = PBXBuildFile; fileRef = BEEE49109365C06B7192D8F61C635EDE /* NSData+Base64-umbrella.h */; settings = {ATTRIBUTES = (Public, ); }; };
9E1E90DED74B73ECE53C9AD76DE53E2D /* UIImage+AFNetworking.h in Headers */ = {isa = PBXBuildFile; fileRef = D1B52352B36D874A119F75269193560B /* UIImage+AFNetworking.h */; settings = {ATTRIBUTES = (Public, ); }; };
9FD74AD660CBDF56F4324FB78FFABE07 /* MDFHatchetFetcher.h in Headers */ = {isa = PBXBuildFile; fileRef = 425EBCD2065C4452117DBCF193AEDA0E /* MDFHatchetFetcher.h */; settings = {ATTRIBUTES = (Public, ); }; };
A1FA3419D8C16BEF0DA36DF86A92D877 /* MDFArtist.m in Sources */ = {isa = PBXBuildFile; fileRef = 91832CE569EA6CEB965956A427F0B6A6 /* MDFArtist.m */; };
A462945883F7729B185B64B679A6BFBE /* UIWebView+AFNetworking.m in Sources */ = {isa = PBXBuildFile; fileRef = 54895A47D9033BB4DF7E1A48832F5D5D /* UIWebView+AFNetworking.m */; };
A5E958996FEC2611D9671A39BBC378B6 /* MetaDataFetcherKit.h in Headers */ = {isa = PBXBuildFile; fileRef = 855CA4B8218B43A4E994807862AAB635 /* MetaDataFetcherKit.h */; settings = {ATTRIBUTES = (Public, ); }; };
......@@ -80,9 +78,7 @@
B5852322ADE88AAD56EE042B80BA81E4 /* AFURLResponseSerialization.m in Sources */ = {isa = PBXBuildFile; fileRef = 7459DFE402A09F1706D9A79B14168EED /* AFURLResponseSerialization.m */; };
B642A07852B8A9462C13F0586BF76D76 /* XMLRPCResponse.h in Headers */ = {isa = PBXBuildFile; fileRef = F8FDF4D9FC61ACEE4C31FBED8454AD5B /* XMLRPCResponse.h */; settings = {ATTRIBUTES = (Public, ); }; };
B70A08E7343CC94721DA7DE571D6AD21 /* MDFOSOFetcher.m in Sources */ = {isa = PBXBuildFile; fileRef = DDFE223695DBBE7053A32575F823AF6F /* MDFOSOFetcher.m */; };
B773E73C985736F7D5FBF67BDDC9E4E1 /* MDFHatchetFetcher.m in Sources */ = {isa = PBXBuildFile; fileRef = 63ED4AABC97BF8AD1EEB8CC0BC7E20C3 /* MDFHatchetFetcher.m */; };
B91B28300E089942195F3F0C30A2CC94 /* MDFMovieDBFetcher.h in Headers */ = {isa = PBXBuildFile; fileRef = E0575F81A35D1D2B2275BC54719D27B0 /* MDFMovieDBFetcher.h */; settings = {ATTRIBUTES = (Public, ); }; };
B9B5B310AE620F254978E2B96AEAAEEB /* MDFHatchetSessionManager.h in Headers */ = {isa = PBXBuildFile; fileRef = 19D4F95C4399E7EBA5F8FDD8CFA1D94D /* MDFHatchetSessionManager.h */; settings = {ATTRIBUTES = (Public, ); }; };
C01AC3BAD9037A8A1E45FD17336C15F3 /* Security.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 76F98589C7449E08C238FB561F1A941F /* Security.framework */; };
C192890019DD83EA8863ADB10BDCE78C /* NSData+Base64.m in Sources */ = {isa = PBXBuildFile; fileRef = 7A05EB20B4B473C5C08678971568AF60 /* NSData+Base64.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; };
C2DD28375E1F0B1D0D1D2E4E607C499F /* AFSecurityPolicy.h in Headers */ = {isa = PBXBuildFile; fileRef = FE6D3ECE5A272DCD87F433183AB4D714 /* AFSecurityPolicy.h */; settings = {ATTRIBUTES = (Public, ); }; };
......@@ -207,7 +203,6 @@
15F355042C0EB7D4C32A44C1EACF5AD3 /* XMLRPCConnection.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; path = XMLRPCConnection.m; sourceTree = "<group>"; };
16AC70F10EDE9B6979D228A7819C0640 /* Pods_MDF_iOS_Demo.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_MDF_iOS_Demo.framework; sourceTree = BUILT_PRODUCTS_DIR; };
18AD4026B23395FC980CAF3A8D11B08A /* XMLRPCDefaultEncoder.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = XMLRPCDefaultEncoder.h; sourceTree = "<group>"; };
19D4F95C4399E7EBA5F8FDD8CFA1D94D /* MDFHatchetSessionManager.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = MDFHatchetSessionManager.h; sourceTree = "<group>"; };
1DE1B08FC65B5AAA07A87B6013DACDC7 /* MDFArtist.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = MDFArtist.h; sourceTree = "<group>"; };
1FEB41FF131E60D741AA1247A0902937 /* AFHTTPSessionManager.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = AFHTTPSessionManager.m; path = AFNetworking/AFHTTPSessionManager.m; sourceTree = "<group>"; };
2073F1CBAECC61D034A85C1AB103AE25 /* MobileCoreServices.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = MobileCoreServices.framework; path = Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS9.0.sdk/System/Library/Frameworks/MobileCoreServices.framework; sourceTree = DEVELOPER_DIR; };
......@@ -229,7 +224,6 @@
3F04627351B09ECE79DF83952E99DB7F /* Info.plist */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
418842FF6E114BFB8BDAE723C5E2C6EF /* XMLRPCResponse.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; path = XMLRPCResponse.m; sourceTree = "<group>"; };
41EDD9A31680455989155067F40B438B /* AFAutoPurgingImageCache.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = AFAutoPurgingImageCache.m; path = "UIKit+AFNetworking/AFAutoPurgingImageCache.m"; sourceTree = "<group>"; };
425EBCD2065C4452117DBCF193AEDA0E /* MDFHatchetFetcher.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = MDFHatchetFetcher.h; sourceTree = "<group>"; };
4458695EDF4A2C51AEE216721328290C /* UIKit+AFNetworking.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = "UIKit+AFNetworking.h"; path = "UIKit+AFNetworking/UIKit+AFNetworking.h"; sourceTree = "<group>"; };
47FB916639BF6DB7C0D5C33A066E6BC0 /* XMLRPCRequest.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = XMLRPCRequest.h; sourceTree = "<group>"; };
4B048948EA76DC516E36C3B2A710A1B6 /* XMLRPCRequest.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; path = XMLRPCRequest.m; sourceTree = "<group>"; };
......@@ -243,7 +237,6 @@
5A2C464FD3C16FF2C325F3608B1CE25D /* AFNetworking-dummy.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; path = "AFNetworking-dummy.m"; sourceTree = "<group>"; };
5FD819A49838AA360879DCF4578A2FF9 /* NSData+Base64.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; path = "NSData+Base64.xcconfig"; sourceTree = "<group>"; };
638DB699D7235DA546DAC5F7471C31D7 /* MLTitleDecrapifier.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = MLTitleDecrapifier.h; sourceTree = "<group>"; };
63ED4AABC97BF8AD1EEB8CC0BC7E20C3 /* MDFHatchetFetcher.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; path = MDFHatchetFetcher.m; sourceTree = "<group>"; };
654520A4A087470C7DE44AD65C482EEC /* AFURLRequestSerialization.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = AFURLRequestSerialization.h; path = AFNetworking/AFURLRequestSerialization.h; sourceTree = "<group>"; };
66093EE659383ADCE554545AE1BB4E33 /* MDFMovieDBSessionManager.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; path = MDFMovieDBSessionManager.m; sourceTree = "<group>"; };
666279BAD871CB1C86C11071F74756EE /* UIRefreshControl+AFNetworking.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = "UIRefreshControl+AFNetworking.m"; path = "UIKit+AFNetworking/UIRefreshControl+AFNetworking.m"; sourceTree = "<group>"; };
......@@ -310,7 +303,6 @@
E19F5B7A053A33EE243CC9B282D7C9C3 /* NSData_Base64.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = NSData_Base64.framework; sourceTree = BUILT_PRODUCTS_DIR; };
E2B5B7FE09DAC077C4DF08075BD7BF0A /* Info.plist */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
E2CBE7CE49DD6B220D86E30EED0667DB /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS9.0.sdk/System/Library/Frameworks/CoreGraphics.framework; sourceTree = DEVELOPER_DIR; };
E37FC4B18FCCB4FB36F315EB11463FB6 /* MDFHatchetSessionManager.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; path = MDFHatchetSessionManager.m; sourceTree = "<group>"; };
E3D3D14576462AA45C6C337B025F22B0 /* AFNetworkActivityIndicatorManager.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = AFNetworkActivityIndicatorManager.h; path = "UIKit+AFNetworking/AFNetworkActivityIndicatorManager.h"; sourceTree = "<group>"; };
E423BD24DB555BBBE6F942F1F7ECAB92 /* MDFMediaObject.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = MDFMediaObject.h; sourceTree = "<group>"; };
E477C0CD906C0113D4CE2D321B8443D0 /* AFHTTPSessionManager.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = AFHTTPSessionManager.h; path = AFNetworking/AFHTTPSessionManager.h; sourceTree = "<group>"; };
......@@ -516,10 +508,6 @@
children = (
1DE1B08FC65B5AAA07A87B6013DACDC7 /* MDFArtist.h */,
91832CE569EA6CEB965956A427F0B6A6 /* MDFArtist.m */,
425EBCD2065C4452117DBCF193AEDA0E /* MDFHatchetFetcher.h */,
63ED4AABC97BF8AD1EEB8CC0BC7E20C3 /* MDFHatchetFetcher.m */,
19D4F95C4399E7EBA5F8FDD8CFA1D94D /* MDFHatchetSessionManager.h */,
E37FC4B18FCCB4FB36F315EB11463FB6 /* MDFHatchetSessionManager.m */,
E423BD24DB555BBBE6F942F1F7ECAB92 /* MDFMediaObject.h */,
F5D8ECC774DE6370613AB95C95B62341 /* MDFMediaObject.m */,
05C1B6BE3CC0B3000EEFD2DC530CAED0 /* MDFMovie.h */,
......@@ -741,8 +729,6 @@
buildActionMask = 2147483647;
files = (
45910C931D1260C958913FAB8CD5260E /* MDFArtist.h in Headers */,
9FD74AD660CBDF56F4324FB78FFABE07 /* MDFHatchetFetcher.h in Headers */,
B9B5B310AE620F254978E2B96AEAAEEB /* MDFHatchetSessionManager.h in Headers */,
3AFECD3DEEBF884E0CD66746E5C3EE22 /* MDFMediaObject.h in Headers */,
D19EE7C5BA5140D0593DB2DD0E73E5A0 /* MDFMovie.h in Headers */,
B91B28300E089942195F3F0C30A2CC94 /* MDFMovieDBFetcher.h in Headers */,
......@@ -1011,8 +997,6 @@
buildActionMask = 2147483647;
files = (
A1FA3419D8C16BEF0DA36DF86A92D877 /* MDFArtist.m in Sources */,
B773E73C985736F7D5FBF67BDDC9E4E1 /* MDFHatchetFetcher.m in Sources */,
987D68B5280109911FB78F0A800E8C58 /* MDFHatchetSessionManager.m in Sources */,
EF98D8DF6F6D1C09598DE5B89D2FD0BA /* MDFMediaObject.m in Sources */,
EEE641EAE7925EE47E939627CB06549C /* MDFMovie.m in Sources */,
F5070F64A18E19F5CF7BCFBA91F445F8 /* MDFMovieDBFetcher.m in Sources */,
......
......@@ -2,25 +2,25 @@
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleExecutable</key>
<string>${EXECUTABLE_NAME}</string>
<key>CFBundleIdentifier</key>
<string>org.cocoapods.${PRODUCT_NAME:rfc1034identifier}</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>${PRODUCT_NAME}</string>
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>0.2.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>${CURRENT_PROJECT_VERSION}</string>
<key>NSPrincipalClass</key>
<string></string>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleExecutable</key>
<string>${EXECUTABLE_NAME}</string>
<key>CFBundleIdentifier</key>
<string>org.cocoapods.${PRODUCT_NAME:rfc1034identifier}</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>${PRODUCT_NAME}</string>
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>0.3.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>${CURRENT_PROJECT_VERSION}</string>
<key>NSPrincipalClass</key>
<string></string>
</dict>
</plist>
#import <UIKit/UIKit.h>
#import "MDFArtist.h"
#import "MDFHatchetFetcher.h"
#import "MDFHatchetSessionManager.h"
#import "MDFMediaObject.h"
#import "MDFMovie.h"
#import "MDFMovieDBFetcher.h"
......@@ -16,4 +14,3 @@
FOUNDATION_EXPORT double MetaDataFetcherKitVersionNumber;
FOUNDATION_EXPORT const unsigned char MetaDataFetcherKitVersionString[];
......@@ -71,9 +71,4 @@
*/
@property (readwrite, nonatomic, nullable) NSArray<NSString *> *largeSizedLandscapeImages;
/**
* the Hatchet id of the artist [NSInteger]
*/
@property (readwrite, nonatomic) NSInteger hatchetArtistID;
@end
......@@ -27,10 +27,9 @@
- (NSString *)description
{
return [NSString stringWithFormat:@"%s: name:'%@', Hatchet-ID:%li, medium artist images %@, large artist images %@",
return [NSString stringWithFormat:@"%s: name:'%@', medium artist images %@, large artist images %@",
__PRETTY_FUNCTION__,
self.name,
(long)self.hatchetArtistID,
self.mediumSizedImages,
self.largeSizedImages];
}
......
/*****************************************************************************
* MDFHatchetFetcher.h
*****************************************************************************
* Copyright (C) 2015 Felix Paul Kühne
* $Id$
*
* Authors: Felix Paul Kühne <fkuehne # videolan.org>
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
#import <Foundation/Foundation.h>
@class MDFHatchetFetcher;
@class MDFArtist;
@class MDFMusicAlbum;
@protocol MDFHatchetFetcherDataRecipient <NSObject>
@optional
- (void)MDFHatchetFetcher:(MDFHatchetFetcher * _Nonnull)aFetcher didFindArtist:(MDFArtist * _Nonnull)artist forSearchRequest:(NSString * _Nonnull)searchRequest;
- (void)MDFHatchetFetcher:(MDFHatchetFetcher * _Nonnull)aFetcher didFailToFindArtistForSearchRequest:(NSString * _Nonnull)searchRequest;
- (void)MDFHatchetFetcher:(MDFHatchetFetcher * _Nonnull)aFetcher didFindAlbum:(MDFMusicAlbum * _Nonnull)album byArtist:(MDFArtist * _Nullable)artist forSearchRequest:(NSString * _Nonnull)searchRequest;
- (void)MDFHatchetFetcher:(MDFHatchetFetcher * _Nonnull)aFetcher didFailToFindAlbum:(NSString * _Nonnull)albumName forArtistName:(NSString * _Nonnull)artistName;
@end
@interface MDFHatchetFetcher : NSObject
/**
* the object receiving the responses to requests send to instances of the fetcher
* \param any NSObject implementing the MDFMovieDBFetcherDataRecipient protocol
* \return the current receiver
* \note should be set before doing any requests
*/
@property (weak, nonatomic) id<MDFHatchetFetcherDataRecipient> dataRecipient;
/**
* this method cancels all requests currently performed by the fetcher
*/
- (void)cancelAllRequests;
- (void)searchForArtist:(NSString * _Nonnull)artistName;
- (void)searchForAlbum:(NSString * _Nonnull)albumName ofArtist:(NSString * _Nonnull)artistName;
@end
/*****************************************************************************
* MDFHatchetFetcher.m
*****************************************************************************
* Copyright (C) 2015 Felix Paul Kühne
* $Id$
*
* Authors: Felix Paul Kühne <fkuehne # videolan.org>
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
#import "MDFHatchetFetcher.h"
#import "MDFHatchetSessionManager.h"
#import "MDFArtist.h"
#import "MDFMusicAlbum.h"
@interface MDFHatchetFetcher ()
{
NSMutableArray<NSURLSessionTask *> *_requests;
}
@end
@implementation MDFHatchetFetcher
- (NSString *)description
{
NSString *ret;
@synchronized(_requests) {
ret = [NSString stringWithFormat:@"%s: %lu pending requests",
__PRETTY_FUNCTION__,
(unsigned long)_requests.count];
}
return ret;
}
- (void)cancelAllRequests
{
@synchronized(_requests) {
NSUInteger requestCount = [_requests count];
for (NSUInteger i = 0; i < requestCount; i++) {
[_requests[i] cancel];
}
_requests = [NSMutableArray array];
}
}
- (void)searchForArtist:(NSString *)artistName
{
if (!artistName)
return;
MDFHatchetSessionManager *sessionManager = [MDFHatchetSessionManager sharedInstance];
if (!sessionManager.apiKey)
return;
NSURLSessionTask *task = [sessionManager GET:@"artists" parameters:@{ @"name" : artistName }
success:^(NSURLSessionDataTask *task, NSDictionary *responseObject) {
@synchronized(_requests) {
[_requests removeObject:task];
}
MDFArtist *artist;
if (responseObject != nil) {
NSArray *artistsArray = responseObject[@"artists"];
NSArray *imagesArray = responseObject[@"images"];
if (artistsArray != nil) {
artist = [[MDFArtist alloc] init];
NSDictionary *artistDict = [artistsArray firstObject];
artist.hatchetArtistID = [artistDict[@"id"] integerValue];
artist.name = artistDict[@"name"];
artist.biography = artistDict[@"wikiabstract"];
}
if (imagesArray != nil) {
if (!artist)
artist = [[MDFArtist alloc] init];
NSMutableArray *mediumImages = [NSMutableArray array];
NSMutableArray *mediumPortraitImages = [NSMutableArray array];
NSMutableArray *mediumLandscapeImages = [NSMutableArray array];
NSMutableArray *largeImages = [NSMutableArray array];
NSMutableArray *largePortraitImages = [NSMutableArray array];
NSMutableArray *largeLandscapeImages = [NSMutableArray array];
NSUInteger imageCount = imagesArray.count;
for (NSUInteger x = 0; x < imageCount; x++) {
NSDictionary *imageDict = imagesArray[x];
NSInteger imageWidth = [imageDict[@"width"] integerValue];
NSInteger imageHeight = [imageDict[@"height"] integerValue];
NSString *imageURL = imageDict[@"url"];
if (imageWidth > 1000) {
[largeImages addObject:imageURL];
if (imageWidth > imageHeight) {
[largeLandscapeImages addObject:imageURL];
} else {
[largePortraitImages addObject:imageURL];
}
} else {
[mediumImages addObject:imageDict[@"url"]];
if (imageWidth > imageHeight) {
[mediumLandscapeImages addObject:imageURL];
} else {
[mediumPortraitImages addObject:imageURL];
}
}
}
artist.mediumSizedImages = [mediumImages copy];
artist.mediumSizedPortraitImages = [mediumPortraitImages copy];
artist.mediumSizedLandscapeImages = [mediumLandscapeImages copy];
artist.largeSizedImages = [largeImages copy];
artist.largeSizedPortraitImages = [largePortraitImages copy];
artist.largeSizedLandscapeImages = [largeLandscapeImages copy];
}
}
if (self.dataRecipient) {
if ([self.dataRecipient respondsToSelector:@selector(MDFHatchetFetcher:didFindArtist:forSearchRequest:)]) {
[self.dataRecipient MDFHatchetFetcher:self
didFindArtist:artist
forSearchRequest:artistName];
}
}
}
failure:^(NSURLSessionDataTask *task, NSError *error) {
@synchronized(_requests) {
[_requests removeObject:task];
}
if (self.dataRecipient) {
if ([self.dataRecipient respondsToSelector:@selector(MDFHatchetFetcher:didFailToFindArtistForSearchRequest:)]) {
[self.dataRecipient MDFHatchetFetcher:self didFailToFindArtistForSearchRequest:artistName];
}
}
}];
@synchronized(_requests) {
[_requests addObject:task];
}
}
- (void)searchForAlbum:(NSString *)albumName ofArtist:(NSString *)artistName
{
if (!artistName)
return;
if (!albumName)
return;
MDFHatchetSessionManager *sessionManager = [MDFHatchetSessionManager sharedInstance];
if (!sessionManager.apiKey)
return;
NSURLSessionTask *task = [sessionManager GET:@"albums" parameters:@{ @"artist_name" : artistName,
@"name" : albumName }
success:^(NSURLSessionDataTask *task, NSDictionary *responseObject) {
@synchronized(_requests) {
[_requests removeObject:task];
}
MDFMusicAlbum *musicAlbum = [[MDFMusicAlbum alloc] init];
MDFArtist *artist;
if (responseObject != nil) {
NSArray *albumsArray = responseObject[@"albums"];
NSArray *imagesArray = responseObject[@"images"];
NSArray *artistsArray = responseObject[@"artists"];
NSInteger albumArtImageID = 0;
if (albumsArray != nil) {
NSDictionary *albumDict = [albumsArray firstObject];
musicAlbum.name = albumDict[@"name"];
musicAlbum.releaseDate = [NSDate date]; // FIXME: enter correct date from "releasedate" key
musicAlbum.hatchetAlbumID = [albumDict[@"id"] integerValue];
NSArray *albumImages = albumDict[@"images"];
if (albumImages != nil) {
if (albumImages.count > 0 ) {
albumArtImageID = [[albumImages firstObject] integerValue];
}
}
}
if (imagesArray != nil) {
NSUInteger imageCount = imagesArray.count;
NSMutableArray *mediumImages = [NSMutableArray array];
NSMutableArray *mediumPortraitImages = [NSMutableArray array];
NSMutableArray *mediumLandscapeImages = [NSMutableArray array];
NSMutableArray *largeImages = [NSMutableArray array];
NSMutableArray *largePortraitImages = [NSMutableArray array];
NSMutableArray *largeLandscapeImages = [NSMutableArray array];
for (NSUInteger x = 0; x < imageCount; x++) {
NSDictionary *imageDict = imagesArray[x];
if (albumArtImageID > 0) {
if ([imageDict[@"id"] integerValue] == albumArtImageID) {
musicAlbum.artworkImage = imageDict[@"url"];
albumArtImageID = 0; // speed-up the further processing
continue;
}
NSMutableArray *mediumImages = [NSMutableArray array];
NSMutableArray *mediumPortraitImages = [NSMutableArray array];
NSMutableArray *mediumLandscapeImages = [NSMutableArray array];
NSMutableArray *largeImages = [NSMutableArray array];
NSMutableArray *largePortraitImages = [NSMutableArray array];
NSMutableArray *largeLandscapeImages = [NSMutableArray array];
NSUInteger imageCount = imagesArray.count;
for (NSUInteger x = 0; x < imageCount; x++) {
NSDictionary *imageDict = imagesArray[x];
NSInteger imageWidth = [imageDict[@"width"] integerValue];
NSInteger imageHeight = [imageDict[@"height"] integerValue];
NSString *imageURL = imageDict[@"url"];
if (imageWidth > 1000) {
[largeImages addObject:imageURL];
if (imageWidth > imageHeight) {
[largeLandscapeImages addObject:imageURL];
} else {
[largePortraitImages addObject:imageURL];
}
} else {
[mediumImages addObject:imageDict[@"url"]];
if (imageWidth > imageHeight) {
[mediumLandscapeImages addObject:imageURL];
} else {
[mediumPortraitImages addObject:imageURL];
}
}
}
}
musicAlbum.mediumSizedArtistImages = [mediumImages copy];
musicAlbum.mediumSizedPortraitArtistImages = [mediumPortraitImages copy];
musicAlbum.mediumSizedLandscapeArtistImages = [mediumLandscapeImages copy];
musicAlbum.largeSizedArtistImages = [largeImages copy];
musicAlbum.largeSizedPortraitArtistImages = [largePortraitImages copy];
musicAlbum.largeSizedLandscapeArtistImages = [largeLandscapeImages copy];
}
}
if (artistsArray != nil) {
NSDictionary *artistDict = [artistsArray firstObject];
artist = [[MDFArtist alloc] init];
artist.name = artistDict[@"name"];
artist.hatchetArtistID = [artistDict[@"id"] integerValue];
artist.biography = artistDict[@"wikiabstract"];
}
if (self.dataRecipient) {
if ([self.dataRecipient respondsToSelector:@selector(MDFHatchetFetcher:didFindAlbum:byArtist:forSearchRequest:)]) {
[self.dataRecipient MDFHatchetFetcher:self
didFindAlbum:musicAlbum
byArtist:artist
forSearchRequest:artistName];
}
}
}
}
failure:^(NSURLSessionDataTask *task, NSError *error) {
@synchronized(_requests) {
[_requests removeObject:task];
}
if (self.dataRecipient) {
if ([self.dataRecipient respondsToSelector:@selector(MDFHatchetFetcher:didFailToFindAlbum:forArtistName:)]) {
[self.dataRecipient MDFHatchetFetcher:self
didFailToFindAlbum:albumName
forArtistName:artistName];
}
}
}];
@synchronized(_requests) {
[_requests addObject:task];
}
}
@end
/*****************************************************************************
* MDFHatchetSessionManager.h
*****************************************************************************
* Copyright (C) 2015 Felix Paul Kühne
* $Id$
*
* Authors: Felix Paul Kühne <fkuehne # videolan.org>
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
#import <AFNetworking/AFNetworking.h>
@interface MDFHatchetSessionManager : AFHTTPSessionManager
+ (_Nonnull instancetype)sharedInstance;
/**
* the API key to use for the fetches
* \param the API key to set [STRING]
* \return the current API key [STRING]
* \note API key must be set before doing any requests
*/
@property (retain, nonatomic, nonnull) NSString *apiKey;
@end
/*****************************************************************************
* MDFHatchetSessionManager.m
*****************************************************************************
* Copyright (C) 2015 Felix Paul Kühne
* $Id$
*
* Authors: Felix Paul Kühne <fkuehne # videolan.org>
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
#import "MDFHatchetSessionManager.h"
static NSString * const HatchetBaseURLString = @"https://api.hatchet.is/v2";
@implementation MDFHatchetSessionManager
+ (instancetype)sharedInstance
{
static MDFHatchetSessionManager *_sharedClient = nil;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
_sharedClient = [[MDFHatchetSessionManager alloc] initWithBaseURL:[NSURL URLWithString:HatchetBaseURLString]];
_sharedClient.requestSerializer = [AFJSONRequestSerializer serializer];
AFSecurityPolicy *securityPolicy = [AFSecurityPolicy policyWithPinningMode:AFSSLPinningModeNone];
securityPolicy.validatesDomainName = YES;
securityPolicy.allowInvalidCertificates = NO;
_sharedClient.securityPolicy = securityPolicy;
_sharedClient.apiKey = @"none needed so far";
});
return _sharedClient;
}
@end
......@@ -77,15 +77,4 @@
*/
@property (readwrite, nonatomic, nullable) NSArray<NSString *> *largeSizedLandscapeArtistImages;
/**
* the Hatchet id of the album [NSInteger]
*/
@property (readwrite, nonatomic) NSInteger hatchetAlbumID;
/**
* the Hatchet id of the album artist [NSInteger]
*/
@property (readwrite, nonatomic) NSInteger hatchetArtistID;
@end
......@@ -27,10 +27,9 @@
- (NSString *)description
{
return [NSString stringWithFormat:@"%s: name:'%@', Hatchet-ID:%li, artwork %@, medium artist images %@, large artist images %@",
return [NSString stringWithFormat:@"%s: name:'%@', artwork %@, medium artist images %@, large artist images %@",
__PRETTY_FUNCTION__,
self.name,
(long)self.hatchetAlbumID,
self.artworkImage,
self.mediumSizedArtistImages,
self.largeSizedArtistImages];
......
......@@ -29,8 +29,6 @@
#import "MDFMovie.h"
#import "MDFTVShow.h"
#import "MDFHatchetSessionManager.h"
#import "MDFHatchetFetcher.h"
#import "MDFMusicAlbum.h"
#import "MDFArtist.h"
......
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