1
0
mirror of https://github.com/mitb-archive/filebot synced 2024-08-13 17:03:45 -04:00

* make sure to ignore illegal imdbids

This commit is contained in:
Reinhard Pointner 2014-05-26 16:47:04 +00:00
parent ba02c192d3
commit 6bea36f30e
5 changed files with 22 additions and 3 deletions

View File

@ -1174,7 +1174,10 @@ public class MediaDetection {
Set<Integer> collection = new LinkedHashSet<Integer>();
while (imdbMatch.find()) {
collection.add(Integer.parseInt(imdbMatch.group()));
int imdbid = Integer.parseInt(imdbMatch.group());
if (imdbid > 0) {
collection.add(imdbid);
}
}
return collection;

View File

@ -24,13 +24,13 @@ import java.util.regex.Pattern;
import javax.swing.Icon;
import net.sf.ehcache.Cache;
import net.sf.ehcache.CacheManager;
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;
import org.w3c.dom.Document;
import org.w3c.dom.Node;
@ -118,6 +118,10 @@ public class IMDbClient implements MovieIdentificationService {
@Override
public Movie getMovieDescriptor(int imdbid, Locale locale) throws Exception {
if (imdbid <= 0) {
throw new IllegalArgumentException("id must not be " + imdbid);
}
try {
return scrapeMovie(parsePage(new URL("http", host, String.format("/title/tt%07d/", imdbid))), locale);
} catch (FileNotFoundException e) {

View File

@ -397,6 +397,10 @@ public class OpenSubtitlesClient implements SubtitleProvider, VideoHashSubtitleS
@Override
public Movie getMovieDescriptor(int imdbid, Locale locale) throws Exception {
if (imdbid <= 0) {
throw new IllegalArgumentException("id must not be " + imdbid);
}
Movie result = getCache().getData("getMovieDescriptor", imdbid, locale, Movie.class);
if (result != null) {
return result;

View File

@ -150,6 +150,10 @@ public class TMDbClient implements MovieIdentificationService {
}
public Movie getMovieDescriptor(int imdbtmdbid, Locale locale, boolean byIMDB) throws IOException {
if (imdbtmdbid <= 0) {
throw new IllegalArgumentException("id must not be " + imdbtmdbid);
}
String id = byIMDB ? String.format("tt%07d", imdbtmdbid) : String.valueOf(imdbtmdbid);
try {
MovieInfo info = getMovieInfo(id, locale, false, false);

View File

@ -194,6 +194,10 @@ public class TheTVDBClient extends AbstractEpisodeListProvider {
}
public TheTVDBSearchResult lookupByIMDbID(int imdbid, Locale locale) throws Exception {
if (imdbid <= 0) {
throw new IllegalArgumentException("id must not be " + imdbid);
}
TheTVDBSearchResult cachedItem = getCache().getData("lookupByIMDbID", imdbid, locale, TheTVDBSearchResult.class);
if (cachedItem != null) {
return cachedItem;