1
0
mirror of https://github.com/mitb-archive/filebot synced 2024-11-16 14:25:02 -05:00

* added support for movieInfo.productionCompanies

@see https://www.filebot.net/forums/viewtopic.php?f=6&t=2648
This commit is contained in:
Reinhard Pointner 2015-05-04 14:29:30 +00:00
parent bf8826229f
commit 6bd1f347f1
2 changed files with 19 additions and 4 deletions

View File

@ -1,5 +1,6 @@
package net.filebot.web;
import static java.util.Collections.*;
import static net.filebot.web.WebRequest.*;
import java.io.File;
@ -28,7 +29,6 @@ import net.filebot.ResourceManager;
import net.filebot.web.TMDbClient.MovieInfo;
import net.filebot.web.TMDbClient.MovieInfo.MovieProperty;
import net.filebot.web.TMDbClient.Person;
import net.filebot.web.TMDbClient.Trailer;
import net.sf.ehcache.Cache;
import net.sf.ehcache.CacheManager;
@ -237,6 +237,6 @@ public class OMDbClient implements MovieIdentificationService {
actors.add(new Person(writer, null, "Writer"));
}
return new MovieInfo(fields, new ArrayList<String>(), genres, new ArrayList<String>(), new ArrayList<String>(), actors, new ArrayList<Trailer>());
return new MovieInfo(fields, emptyList(), genres, emptyList(), emptyList(), emptyList(), actors, emptyList());
}
}

View File

@ -234,6 +234,15 @@ public class TMDbClient implements MovieIdentificationService {
Logger.getLogger(getClass().getName()).log(Level.WARNING, "Illegal production_countries data: " + response);
}
List<String> productionCompanies = new ArrayList<String>();
try {
for (JSONObject it : jsonList(response.get("production_companies"))) {
productionCompanies.add((String) it.get("name"));
}
} catch (Exception e) {
Logger.getLogger(getClass().getName()).log(Level.WARNING, "Illegal production_companies data: " + response);
}
List<String> alternativeTitles = new ArrayList<String>();
try {
JSONObject titles = (JSONObject) response.get("alternative_titles");
@ -303,7 +312,7 @@ public class TMDbClient implements MovieIdentificationService {
Logger.getLogger(getClass().getName()).log(Level.WARNING, "Illegal trailers data: " + response);
}
return new MovieInfo(fields, alternativeTitles, genres, spokenLanguages, productionCountries, cast, trailers);
return new MovieInfo(fields, alternativeTitles, genres, spokenLanguages, productionCountries, productionCompanies, cast, trailers);
}
public List<Artwork> getArtwork(String id) throws IOException {
@ -400,6 +409,7 @@ public class TMDbClient implements MovieIdentificationService {
protected String[] genres;
protected String[] spokenLanguages;
protected String[] productionCountries;
protected String[] productionCompanies;
protected Person[] people;
protected Trailer[] trailers;
@ -408,12 +418,13 @@ public class TMDbClient implements MovieIdentificationService {
// used by serializer
}
protected MovieInfo(Map<MovieProperty, String> fields, List<String> alternativeTitles, List<String> genres, List<String> spokenLanguages, List<String> productionCountries, List<Person> people, List<Trailer> trailers) {
protected MovieInfo(Map<MovieProperty, String> fields, List<String> alternativeTitles, List<String> genres, List<String> spokenLanguages, List<String> productionCountries, List<String> productionCompanies, List<Person> people, List<Trailer> trailers) {
this.fields = new EnumMap<MovieProperty, String>(fields);
this.alternativeTitles = alternativeTitles.toArray(new String[0]);
this.genres = genres.toArray(new String[0]);
this.spokenLanguages = spokenLanguages.toArray(new String[0]);
this.productionCountries = productionCountries.toArray(new String[0]);
this.productionCompanies = productionCompanies.toArray(new String[0]);
this.people = people.toArray(new Person[0]);
this.trailers = trailers.toArray(new Trailer[0]);
}
@ -446,6 +457,10 @@ public class TMDbClient implements MovieIdentificationService {
return unmodifiableList(asList(productionCountries));
}
public List<String> getProductionCompanies() {
return unmodifiableList(asList(productionCompanies));
}
public String getOriginalName() {
return get(MovieProperty.original_title);
}