1
0
mirror of https://github.com/mitb-archive/filebot synced 2024-11-04 16:35:08 -05:00

+ shortcut to grabbing just episode list or movie info without the files directly from rename panel (if files is empty)

This commit is contained in:
Reinhard Pointner 2014-01-10 10:55:57 +00:00
parent 53ad37930d
commit 1e9d0899b0
5 changed files with 55 additions and 10 deletions

View File

@ -171,6 +171,10 @@ class EpisodeListMatcher implements AutoCompleteMatcher {
@Override
public List<Match<File, ?>> match(List<File> files, final SortOrder sortOrder, final Locale locale, final boolean autodetection, final Component parent) throws Exception {
if (files.isEmpty()) {
return justFetchEpisodeList(sortOrder, locale, parent);
}
// ignore sample files
final List<File> fileset = filter(files, not(getClutterFileFilter()));
@ -304,4 +308,21 @@ class EpisodeListMatcher implements AutoCompleteMatcher {
return matches;
}
public List<Match<File, ?>> justFetchEpisodeList(final SortOrder sortOrder, final Locale locale, final Component parent) throws Exception {
// require user input
String input = showInputDialog("Enter series name:", "", "Fetch Episode List", parent);
List<Match<File, ?>> matches = new ArrayList<Match<File, ?>>();
if (input != null && input.length() > 0) {
synchronized (providerLock) {
Set<Episode> episodes = fetchEpisodeSet(singleton(input), sortOrder, locale, new HashMap<String, SearchResult>(), parent);
for (Episode it : episodes) {
matches.add(new Match<File, Episode>(null, it));
}
}
}
return matches;
}
}

View File

@ -238,7 +238,7 @@ public class FormatDialog extends JDialog {
if (locked) {
this.setTitle(String.format("%s Format", mode));
title.setText(String.format("%s Format - %s ⇔ %s", mode, bindings.getInfoObject(), bindings.getMediaFile().getName()));
title.setText(String.format("%s Format - %s ⇔ %s", mode, bindings.getInfoObject(), bindings.getMediaFile() == null ? null : bindings.getMediaFile().getName()));
} else {
this.setTitle(String.format("%s Format", mode));
title.setText(String.format("%s Format", mode));

View File

@ -18,6 +18,7 @@ import java.util.Collection;
import java.util.Comparator;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Locale;
@ -65,6 +66,10 @@ class MovieHashMatcher implements AutoCompleteMatcher {
@Override
public List<Match<File, ?>> match(final List<File> files, final SortOrder sortOrder, final Locale locale, final boolean autodetect, final Component parent) throws Exception {
if (files.isEmpty()) {
return justFetchMovieInfo(locale, parent);
}
// ignore sample files
List<File> fileset = filter(files, not(getClutterFileFilter()));
@ -412,4 +417,25 @@ class MovieHashMatcher implements AutoCompleteMatcher {
selectionMemory.put(fileQuery, showSelectDialog.get());
return showSelectDialog.get();
}
public List<Match<File, ?>> justFetchMovieInfo(final Locale locale, final Component parent) throws Exception {
// require user input
String input = showInputDialog("Enter movie name:", "", "Fetch Movie Info", parent);
List<Match<File, ?>> matches = new ArrayList<Match<File, ?>>();
if (input != null && input.length() > 0) {
Collection<Movie> results = new LinkedHashSet<Movie>();
results.addAll(service.searchMovie(input, locale));
results.addAll(matchMovieName(singleton(input), false, 2));
// improve ranking
results = sortBySimilarity(results, singleton(input), getMovieMatchMetric(), false);
for (Movie it : results) {
matches.add(new Match<File, Movie>(null, it));
}
}
return matches;
}
}

View File

@ -261,7 +261,7 @@ public class RenamePanel extends JComponent {
showFormatEditor(sample);
}
} catch (Exception e) {
Logger.getLogger(RenamePanel.class.getName()).log(Level.WARNING, e.getMessage());
Logger.getLogger(RenamePanel.class.getName()).log(Level.WARNING, e.getMessage(), e);
} finally {
getWindow(evt.getSource()).setCursor(Cursor.getDefaultCursor());
}
@ -546,11 +546,6 @@ public class RenamePanel extends JComponent {
@Override
public void actionPerformed(final ActionEvent evt) {
if (renameModel.files().isEmpty()) {
UILogger.info("Original Files is empty. Please add some files first.");
return;
}
// clear names list
renameModel.values().clear();

View File

@ -20,6 +20,7 @@ import java.awt.image.BufferedImage;
import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.List;
import java.util.regex.Pattern;
import javax.swing.AbstractAction;
import javax.swing.Action;
@ -140,10 +141,12 @@ public final class TunedUtilities {
return emptyList();
}
for (char separator : new char[] { '|', ';', ',' }) {
for (char separator : new char[] { '|', ';' }) {
if (input.indexOf(separator) >= 0) {
List<String> values = new ArrayList<String>();
for (String field : input.split(Character.toString(separator))) {
for (String field : input.split(Pattern.quote(Character.toString(separator)))) {
field = field.trim();
if (field.length() > 0) {
values.add(field);
}
@ -167,7 +170,7 @@ public final class TunedUtilities {
public void run() {
Object value = JOptionPane.showInputDialog(parent, text, title, PLAIN_MESSAGE, null, null, initialValue);
if (value != null) {
buffer.append(value);
buffer.append(value.toString().trim());
}
}
};