Commit 4fd4ab8c authored by Felix Paul Kühne's avatar Felix Paul Kühne

TMDb fetcher: prevent recursive search request crappification and fix TV show lookups

parent d220f6e7
......@@ -70,6 +70,8 @@
if (!sessionManager.apiKey)
return;
NSString *originalSearchRequest = [searchRequest copy];
@synchronized(_requests) {
if (!_requests)
_requests = [NSMutableArray array];
......@@ -123,7 +125,7 @@
if ([self.dataRecipient respondsToSelector:@selector(MDFMovieDBFetcher:didFindMovie:forSearchRequest:)]) {
[self.dataRecipient MDFMovieDBFetcher:self
didFindMovie:movie
forSearchRequest:searchRequest];
forSearchRequest:originalSearchRequest];
}
}
} failure:^(NSURLSessionDataTask *task, NSError *error) {
......@@ -134,7 +136,7 @@
if (self.dataRecipient) {
if ([self.dataRecipient respondsToSelector:@selector(MDFMovieDBFetcher:didFailToFindMovieForSearchRequest:)]) {
[self.dataRecipient MDFMovieDBFetcher:self
didFailToFindMovieForSearchRequest:searchRequest];
didFailToFindMovieForSearchRequest:originalSearchRequest];
}
}
}];
......@@ -161,6 +163,7 @@
if (!_requests)
_requests = [NSMutableArray array];
}
NSString *originalSearchRequest = [searchRequest copy];
if (self.shouldDecrapifyInputStrings) {
NSDictionary *decrapificationResults = [MLTitleDecrapifier tvShowEpisodeInfoFromString:searchRequest];
......@@ -178,7 +181,7 @@
if (languageCode != nil)
[parameters setObject:languageCode forKey:@"language"];
NSURLSessionTask *task = [sessionManager GET:@"search/movie"
NSURLSessionTask *task = [sessionManager GET:@"search/tv"
parameters:parameters
success:^(NSURLSessionDataTask *task, NSDictionary *responseObject) {
@synchronized(_requests) {
......@@ -209,7 +212,7 @@
if (self.dataRecipient) {
if ([self.dataRecipient respondsToSelector:@selector(MDFMovieDBFetcher:didFindTVShow:forSearchRequest:)]) {
[self.dataRecipient MDFMovieDBFetcher:self
didFindTVShow:tvShow forSearchRequest:searchRequest];
didFindTVShow:tvShow forSearchRequest:originalSearchRequest];
}
}
} failure:^(NSURLSessionDataTask *task, NSError *error) {
......@@ -220,7 +223,7 @@
if (self.dataRecipient) {
if ([self.dataRecipient respondsToSelector:@selector(MDFMovieDBFetcher:didFailToFindTVShowForSearchRequest:)]) {
[self.dataRecipient MDFMovieDBFetcher:self
didFailToFindTVShowForSearchRequest:searchRequest];
didFailToFindTVShowForSearchRequest:originalSearchRequest];
}
}
}];
......
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