* added lookup by filename/foldername to movie mode
* search order is now like this: lookup moviehash->lookup imdbid from .nfo->search by filename->search by foldername
This commit is contained in:
parent
ac774306f4
commit
b59ab7e6ee
|
@ -143,6 +143,7 @@ class MovieHashMatcher implements AutoCompleteMatcher {
|
||||||
protected MovieDescriptor determineMovie(File movieFile) throws Exception {
|
protected MovieDescriptor determineMovie(File movieFile) throws Exception {
|
||||||
List<MovieDescriptor> options = new ArrayList<MovieDescriptor>();
|
List<MovieDescriptor> options = new ArrayList<MovieDescriptor>();
|
||||||
|
|
||||||
|
// try to grep imdb id from nfo files
|
||||||
for (int imdbid : grepImdbId(movieFile.getParentFile().listFiles(getDefaultFilter("application/nfo")))) {
|
for (int imdbid : grepImdbId(movieFile.getParentFile().listFiles(getDefaultFilter("application/nfo")))) {
|
||||||
MovieDescriptor movie = service.getMovieDescriptor(imdbid);
|
MovieDescriptor movie = service.getMovieDescriptor(imdbid);
|
||||||
|
|
||||||
|
@ -151,6 +152,18 @@ class MovieHashMatcher implements AutoCompleteMatcher {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// search by file name
|
||||||
|
if (options.isEmpty()) {
|
||||||
|
String query = getName(movieFile).replaceAll("\\p{Punct}", "").trim();
|
||||||
|
options = service.searchMovie(query);
|
||||||
|
|
||||||
|
// search by folder name
|
||||||
|
if (options.isEmpty()) {
|
||||||
|
query = getName(movieFile.getParentFile()).replaceAll("\\p{Punct}", "").trim();
|
||||||
|
options = service.searchMovie(query);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return options.isEmpty() ? null : selectMovie(options);
|
return options.isEmpty() ? null : selectMovie(options);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3,10 +3,14 @@ package net.sourceforge.filebot.web;
|
||||||
|
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
|
||||||
public interface MovieIdentificationService {
|
public interface MovieIdentificationService {
|
||||||
|
|
||||||
|
public List<MovieDescriptor> searchMovie(String query) throws Exception;
|
||||||
|
|
||||||
|
|
||||||
public MovieDescriptor getMovieDescriptor(int imdbid) throws Exception;
|
public MovieDescriptor getMovieDescriptor(int imdbid) throws Exception;
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -146,6 +146,15 @@ public class OpenSubtitlesClient implements SubtitleProvider, VideoHashSubtitleS
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<MovieDescriptor> searchMovie(String query) throws Exception {
|
||||||
|
// require login
|
||||||
|
login();
|
||||||
|
|
||||||
|
return xmlrpc.searchMoviesOnIMDB(query);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public MovieDescriptor getMovieDescriptor(int imdbid) throws Exception {
|
public MovieDescriptor getMovieDescriptor(int imdbid) throws Exception {
|
||||||
// require login
|
// require login
|
||||||
|
|
|
@ -10,8 +10,11 @@ import java.io.IOException;
|
||||||
import java.net.MalformedURLException;
|
import java.net.MalformedURLException;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Scanner;
|
import java.util.Scanner;
|
||||||
|
import java.util.logging.Level;
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
import javax.swing.Icon;
|
import javax.swing.Icon;
|
||||||
|
|
||||||
|
@ -44,8 +47,15 @@ public class TMDbClient implements MovieIdentificationService {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public List<MovieDescriptor> searchMovie(String query) throws IOException, SAXException {
|
@Override
|
||||||
return getMovies("Movie.search", query);
|
public List<MovieDescriptor> searchMovie(String query) throws IOException {
|
||||||
|
try {
|
||||||
|
return getMovies("Movie.search", query);
|
||||||
|
} catch (SAXException e) {
|
||||||
|
// TMDb output is sometimes malformed xml
|
||||||
|
Logger.getLogger(getClass().getName()).log(Level.WARNING, e.getMessage());
|
||||||
|
return Collections.emptyList();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -59,6 +69,7 @@ public class TMDbClient implements MovieIdentificationService {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
public MovieDescriptor getMovieDescriptor(int imdbid) throws Exception {
|
public MovieDescriptor getMovieDescriptor(int imdbid) throws Exception {
|
||||||
URL resource = getResource("Movie.imdbLookup", String.format("tt%07d", imdbid));
|
URL resource = getResource("Movie.imdbLookup", String.format("tt%07d", imdbid));
|
||||||
Node movie = selectNode("//movie", getDocument(resource));
|
Node movie = selectNode("//movie", getDocument(resource));
|
||||||
|
|
|
@ -198,7 +198,7 @@ public final class FileUtilities {
|
||||||
|
|
||||||
|
|
||||||
public static Map<String, List<File>> mapByExtension(Iterable<File> files) {
|
public static Map<String, List<File>> mapByExtension(Iterable<File> files) {
|
||||||
HashMap<String, List<File>> map = new HashMap<String, List<File>>();
|
Map<String, List<File>> map = new HashMap<String, List<File>>();
|
||||||
|
|
||||||
for (File file : files) {
|
for (File file : files) {
|
||||||
String key = getExtension(file);
|
String key = getExtension(file);
|
||||||
|
|
Loading…
Reference in New Issue