* make sure every matched object is a unique object (as required by Matcher)
This commit is contained in:
parent
2fa9b625fa
commit
dd9e0bdc22
|
@ -218,8 +218,8 @@ class EpisodeListMatcher implements AutoCompleteMatcher {
|
|||
|
||||
for (File file : derivateFiles) {
|
||||
for (Match<File, ?> match : matches) {
|
||||
if (file.getParentFile().equals(match.getValue().getParentFile()) && isDerived(file, match.getValue())) {
|
||||
derivateMatches.add(new Match<File, Object>(file, match.getCandidate()));
|
||||
if (file.getParentFile().equals(match.getValue().getParentFile()) && isDerived(file, match.getValue()) && match.getCandidate() instanceof Episode) {
|
||||
derivateMatches.add(new Match<File, Object>(file, new Episode((Episode) match.getCandidate())));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,8 +25,8 @@ import net.sourceforge.filebot.similarity.Match;
|
|||
import net.sourceforge.filebot.similarity.Matcher;
|
||||
import net.sourceforge.filebot.similarity.SimilarityMetric;
|
||||
import net.sourceforge.tuned.ui.ProgressDialog;
|
||||
import net.sourceforge.tuned.ui.SwingWorkerPropertyChangeAdapter;
|
||||
import net.sourceforge.tuned.ui.ProgressDialog.Cancellable;
|
||||
import net.sourceforge.tuned.ui.SwingWorkerPropertyChangeAdapter;
|
||||
|
||||
|
||||
class MatchAction extends AbstractAction {
|
||||
|
@ -47,12 +47,12 @@ class MatchAction extends AbstractAction {
|
|||
if (model.names().isEmpty() || model.files().isEmpty())
|
||||
return;
|
||||
|
||||
Window window = getWindow(evt.getSource());
|
||||
window.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
|
||||
|
||||
BackgroundMatcher backgroundMatcher = new BackgroundMatcher(model, EpisodeMetrics.defaultSequence(true));
|
||||
backgroundMatcher.execute();
|
||||
|
||||
Window window = getWindow(evt.getSource());
|
||||
window.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
|
||||
|
||||
try {
|
||||
// wait a for little while (matcher might finish in less than a second)
|
||||
backgroundMatcher.get(2, TimeUnit.SECONDS);
|
||||
|
@ -65,9 +65,9 @@ class MatchAction extends AbstractAction {
|
|||
dialog.setVisible(true);
|
||||
} catch (Exception e) {
|
||||
Logger.getLogger(getClass().getName()).log(Level.SEVERE, e.toString(), e);
|
||||
} finally {
|
||||
window.setCursor(Cursor.getDefaultCursor());
|
||||
}
|
||||
|
||||
window.setCursor(Cursor.getDefaultCursor());
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -180,13 +180,13 @@ class MovieHashMatcher implements AutoCompleteMatcher {
|
|||
moviePart = new MoviePart(moviePart, i + 1, fileSet.size());
|
||||
}
|
||||
|
||||
matches.add(new Match<File, Movie>(fileSet.get(i), moviePart));
|
||||
matches.add(new Match<File, Movie>(fileSet.get(i), moviePart.clone()));
|
||||
|
||||
// automatically add matches for derivate files
|
||||
List<File> derivates = derivatesByMovieFile.get(fileSet.get(i));
|
||||
if (derivates != null) {
|
||||
for (File derivate : derivates) {
|
||||
matches.add(new Match<File, Movie>(derivate, moviePart));
|
||||
matches.add(new Match<File, Movie>(derivate, moviePart.clone()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -30,6 +30,11 @@ public class Episode implements Serializable {
|
|||
}
|
||||
|
||||
|
||||
public Episode(Episode obj) {
|
||||
this(obj.seriesName, obj.seriesStartDate, obj.season, obj.episode, obj.title, obj.absolute, obj.special, obj.airdate);
|
||||
}
|
||||
|
||||
|
||||
public Episode(String seriesName, Date seriesStartDate, Integer season, Integer episode, String title) {
|
||||
this(seriesName, seriesStartDate, season, episode, title, null, null, null);
|
||||
}
|
||||
|
|
|
@ -16,6 +16,11 @@ public class Movie extends SearchResult {
|
|||
}
|
||||
|
||||
|
||||
public Movie(Movie obj) {
|
||||
this(obj.name, obj.year, obj.imdbId);
|
||||
}
|
||||
|
||||
|
||||
public Movie(String name, int year, int imdbId) {
|
||||
super(name);
|
||||
this.year = year;
|
||||
|
@ -44,6 +49,12 @@ public class Movie extends SearchResult {
|
|||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Movie clone() {
|
||||
return new Movie(this);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Arrays.hashCode(new Object[] { name, year, imdbId });
|
||||
|
|
|
@ -8,8 +8,18 @@ public class MoviePart extends Movie {
|
|||
protected final int partCount;
|
||||
|
||||
|
||||
public MoviePart(MoviePart obj) {
|
||||
this(obj.name, obj.year, obj.imdbId, obj.partIndex, obj.partCount);
|
||||
}
|
||||
|
||||
|
||||
public MoviePart(Movie movie, int partIndex, int partCount) {
|
||||
super(movie.name, movie.year, movie.imdbId);
|
||||
this(movie.name, movie.year, movie.imdbId, partIndex, partCount);
|
||||
}
|
||||
|
||||
|
||||
public MoviePart(String name, int year, int imdbId, int partIndex, int partCount) {
|
||||
super(name, year, imdbId);
|
||||
this.partIndex = partIndex;
|
||||
this.partCount = partCount;
|
||||
}
|
||||
|
@ -25,6 +35,23 @@ public class MoviePart extends Movie {
|
|||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean equals(Object object) {
|
||||
if (object instanceof MoviePart && super.equals(object)) {
|
||||
MoviePart other = (MoviePart) object;
|
||||
return partIndex == other.partIndex && partCount == other.partCount;
|
||||
}
|
||||
|
||||
return super.equals(object);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public MoviePart clone() {
|
||||
return new MoviePart(this);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return String.format("%s (%d) [%d]", name, year, partIndex);
|
||||
|
|
Loading…
Reference in New Issue