mirror of
https://github.com/mitb-archive/filebot
synced 2025-01-11 13:58:16 -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 {
|
public class IMDbClient implements MovieIdentificationService {
|
||||||
|
|
||||||
private final String host = "akas.imdb.com";
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return "IMDb";
|
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) {
|
protected int getImdbId(String link) {
|
||||||
Matcher matcher = Pattern.compile("tt(\\d{7})").matcher(link);
|
Matcher matcher = Pattern.compile("tt(\\d{7})").matcher(link);
|
||||||
|
|
||||||
@ -72,7 +75,7 @@ public class IMDbClient implements MovieIdentificationService {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Movie> searchMovie(String query, Locale locale) throws Exception {
|
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
|
// select movie links followed by year in parenthesis
|
||||||
List<Node> nodes = selectNodes("//TABLE[@class='findList']//TD/A[substring-after(substring-before(following::text(),')'),'(')]", dom);
|
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
|
@Override
|
||||||
public Movie getMovieDescriptor(int imdbid, Locale locale) throws Exception {
|
public Movie getMovieDescriptor(int imdbid, Locale locale) throws Exception {
|
||||||
try {
|
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) {
|
} catch (FileNotFoundException e) {
|
||||||
return null; // illegal imdbid
|
return null; // illegal imdbid
|
||||||
}
|
}
|
||||||
|
@ -28,12 +28,12 @@ public class IMDbClientTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void searchMovie2() throws Exception {
|
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);
|
Movie movie = results.get(0);
|
||||||
|
|
||||||
assertEquals("Heat", movie.getName());
|
assertEquals("The Illusionist", movie.getName());
|
||||||
assertEquals(1995, movie.getYear());
|
assertEquals(2006, movie.getYear());
|
||||||
assertEquals(113277, movie.getImdbId(), 0);
|
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() }
|
input = input.findAll{ it.isVideo() || it.isSubtitle() || it.isDisk() }
|
||||||
|
|
||||||
// ignore clutter files
|
// 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
|
// print input fileset
|
||||||
input.each{ f -> _log.finest("Input: $f") }
|
input.each{ f -> _log.finest("Input: $f") }
|
||||||
|
Loading…
Reference in New Issue
Block a user