Commit 213d1d08 authored by Felix Paul Kühne's avatar Felix Paul Kühne

Add decrapification support

parent 80a99ad7
......@@ -47,6 +47,15 @@
*/
@property (weak, nonatomic) id<MDFMovieDBFetcherDataRecipient> dataRecipient;
/**
* The fetcher can process input strings by removing stray characters, file extensions, etc.,
* which can lead to improve search results.
* \param turn on/off the feature [BOOLEAN]
* \return current state of the feature [BOOLEAN]
* \note OFF by default
*/
@property (nonatomic, readwrite) BOOL shouldDecrapifyInputStrings;
/**
* this method cancels all requests currently performed by the fetcher
*/
......
......@@ -25,6 +25,7 @@
#import "MDFMovieDBSessionManager.h"
#import "MDFMovie.h"
#import "MDFTVShow.h"
#import "MLTitleDecrapifier.h"
@interface MDFMovieDBFetcher ()
{
......@@ -75,6 +76,10 @@
_requests = [NSMutableArray array];
}
if (self.shouldDecrapifyInputStrings) {
searchRequest = [MLTitleDecrapifier decrapify:searchRequest];
}
NSMutableDictionary *parameters = [NSMutableDictionary dictionaryWithObjectsAndKeys:sessionManager.apiKey, @"api_key",
[searchRequest stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet newlineCharacterSet]], @"query", nil];
......@@ -158,6 +163,14 @@
_requests = [NSMutableArray array];
}
if (self.shouldDecrapifyInputStrings) {
NSDictionary *decrapificationResults = [MLTitleDecrapifier tvShowEpisodeInfoFromString:searchRequest];
NSString *showName = decrapificationResults[@"tvShowName"];
if (showName) {
searchRequest = showName;
}
}
NSMutableDictionary *parameters = [NSMutableDictionary dictionaryWithObjectsAndKeys:sessionManager.apiKey, @"api_key",
[searchRequest stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet newlineCharacterSet]], @"query", nil];
......
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