mirror of
https://github.com/mitb-archive/filebot
synced 2024-12-24 08:48:51 -05:00
* make imdb host (e.g. akas.imdb.com) configurable via -Dimdb.hostname
This commit is contained in:
parent
d2ab91e846
commit
f053ecd8be
@ -43,9 +43,6 @@ import org.xml.sax.SAXException;
|
||||
|
||||
public class IMDbClient implements MovieIdentificationService {
|
||||
|
||||
private final String host = "akas.imdb.com";
|
||||
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "IMDb";
|
||||
@ -58,6 +55,12 @@ public class IMDbClient implements MovieIdentificationService {
|
||||
}
|
||||
|
||||
|
||||
protected String getHost() {
|
||||
String host = System.getProperty("imdb.hostname"); // default to akas.imdb.com but allow override via -Dimdb.host
|
||||
return host == null ? "akas.imdb.com" : host;
|
||||
}
|
||||
|
||||
|
||||
protected int getImdbId(String link) {
|
||||
Matcher matcher = Pattern.compile("tt(\\d{7})").matcher(link);
|
||||
|
||||
@ -72,7 +75,7 @@ public class IMDbClient implements MovieIdentificationService {
|
||||
|
||||
@Override
|
||||
public List<Movie> searchMovie(String query, Locale locale) throws Exception {
|
||||
Document dom = parsePage(new URL("http", host, "/find?s=tt&q=" + encode(query)));
|
||||
Document dom = parsePage(new URL("http", getHost(), "/find?s=tt&q=" + encode(query)));
|
||||
|
||||
// select movie links followed by year in parenthesis
|
||||
List<Node> nodes = selectNodes("//TABLE[@class='findList']//TD/A[substring-after(substring-before(following::text(),')'),'(')]", dom);
|
||||
@ -152,7 +155,7 @@ public class IMDbClient implements MovieIdentificationService {
|
||||
@Override
|
||||
public Movie getMovieDescriptor(int imdbid, Locale locale) throws Exception {
|
||||
try {
|
||||
return scrapeMovie(parsePage(new URL("http", host, String.format("/title/tt%07d/releaseinfo", imdbid))), locale);
|
||||
return scrapeMovie(parsePage(new URL("http", getHost(), String.format("/title/tt%07d/releaseinfo", imdbid))), locale);
|
||||
} catch (FileNotFoundException e) {
|
||||
return null; // illegal imdbid
|
||||
}
|
||||
|
@ -28,12 +28,12 @@ public class IMDbClientTest {
|
||||
|
||||
@Test
|
||||
public void searchMovie2() throws Exception {
|
||||
List<Movie> results = imdb.searchMovie("Heat", null);
|
||||
List<Movie> results = imdb.searchMovie("the illusionist", null);
|
||||
Movie movie = results.get(0);
|
||||
|
||||
assertEquals("Heat", movie.getName());
|
||||
assertEquals(1995, movie.getYear());
|
||||
assertEquals(113277, movie.getImdbId(), 0);
|
||||
assertEquals("The Illusionist", movie.getName());
|
||||
assertEquals(2006, movie.getYear());
|
||||
assertEquals(443543, movie.getImdbId(), 0);
|
||||
}
|
||||
|
||||
|
||||
|
@ -79,7 +79,7 @@ input = input.findAll{ it?.exists() }.collect{ it.canonicalFile }.unique()
|
||||
input = input.findAll{ it.isVideo() || it.isSubtitle() || it.isDisk() }
|
||||
|
||||
// ignore clutter files
|
||||
input = input.findAll{ !(it.path =~ /\b(?i:sample|trailer|extras|deleted.scenes|music.video|scrapbook)\b/) }
|
||||
input = input.findAll{ !(it.path =~ /\b(?i:sample|trailer|extras|deleted.scenes|music.video|scrapbook|behind.the.scenes)\b/) }
|
||||
|
||||
// print input fileset
|
||||
input.each{ f -> _log.finest("Input: $f") }
|
||||
|
Loading…
Reference in New Issue
Block a user