mirror of
https://github.com/mitb-archive/filebot
synced 2024-12-24 16:58:51 -05:00
* clean release info from any auto-detected series name word sequence
This commit is contained in:
parent
b93e85b9dd
commit
9cb97bf93a
@ -8,7 +8,7 @@ import static net.sourceforge.filebot.MediaTypes.*;
|
|||||||
import static net.sourceforge.filebot.WebServices.*;
|
import static net.sourceforge.filebot.WebServices.*;
|
||||||
import static net.sourceforge.filebot.cli.CLILogging.*;
|
import static net.sourceforge.filebot.cli.CLILogging.*;
|
||||||
import static net.sourceforge.filebot.hash.VerificationUtilities.*;
|
import static net.sourceforge.filebot.hash.VerificationUtilities.*;
|
||||||
import static net.sourceforge.filebot.similarity.SeriesNameMatcher.*;
|
import static net.sourceforge.filebot.mediainfo.ReleaseInfo.*;
|
||||||
import static net.sourceforge.filebot.subtitle.SubtitleUtilities.*;
|
import static net.sourceforge.filebot.subtitle.SubtitleUtilities.*;
|
||||||
import static net.sourceforge.tuned.FileUtilities.*;
|
import static net.sourceforge.tuned.FileUtilities.*;
|
||||||
|
|
||||||
@ -46,7 +46,6 @@ import net.sourceforge.filebot.format.MediaBindingBean;
|
|||||||
import net.sourceforge.filebot.hash.HashType;
|
import net.sourceforge.filebot.hash.HashType;
|
||||||
import net.sourceforge.filebot.hash.VerificationFileReader;
|
import net.sourceforge.filebot.hash.VerificationFileReader;
|
||||||
import net.sourceforge.filebot.hash.VerificationFileWriter;
|
import net.sourceforge.filebot.hash.VerificationFileWriter;
|
||||||
import net.sourceforge.filebot.mediainfo.ReleaseInfo;
|
|
||||||
import net.sourceforge.filebot.similarity.EpisodeMetrics;
|
import net.sourceforge.filebot.similarity.EpisodeMetrics;
|
||||||
import net.sourceforge.filebot.similarity.Match;
|
import net.sourceforge.filebot.similarity.Match;
|
||||||
import net.sourceforge.filebot.similarity.Matcher;
|
import net.sourceforge.filebot.similarity.Matcher;
|
||||||
@ -98,7 +97,7 @@ public class CmdlineOperations implements CmdlineInterface {
|
|||||||
|
|
||||||
Collection<String> cwsList = emptySet();
|
Collection<String> cwsList = emptySet();
|
||||||
if (max >= 5) {
|
if (max >= 5) {
|
||||||
cwsList = detectSeriesName(mediaFiles);
|
cwsList = detectSeriesNames(mediaFiles);
|
||||||
}
|
}
|
||||||
|
|
||||||
SeriesNameMatcher nameMatcher = new SeriesNameMatcher();
|
SeriesNameMatcher nameMatcher = new SeriesNameMatcher();
|
||||||
@ -557,10 +556,7 @@ public class CmdlineOperations implements CmdlineInterface {
|
|||||||
|
|
||||||
|
|
||||||
private Collection<String> detectQuery(Collection<File> mediaFiles, boolean strict) throws Exception {
|
private Collection<String> detectQuery(Collection<File> mediaFiles, boolean strict) throws Exception {
|
||||||
Collection<String> names = detectSeriesName(mediaFiles);
|
Collection<String> names = detectSeriesNames(mediaFiles);
|
||||||
|
|
||||||
// clean detected word sequence from unwanted data
|
|
||||||
names = new LinkedHashSet<String>(new ReleaseInfo().cleanRG(names));
|
|
||||||
|
|
||||||
if (names.isEmpty() || (strict && names.size() > 1)) {
|
if (names.isEmpty() || (strict && names.size() > 1)) {
|
||||||
throw new Exception("Unable to auto-select query: " + names);
|
throw new Exception("Unable to auto-select query: " + names);
|
||||||
|
@ -12,15 +12,28 @@ import java.io.IOException;
|
|||||||
import java.nio.ByteBuffer;
|
import java.nio.ByteBuffer;
|
||||||
import java.nio.charset.Charset;
|
import java.nio.charset.Charset;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.LinkedHashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
|
import net.sourceforge.filebot.similarity.SeriesNameMatcher;
|
||||||
import net.sourceforge.filebot.web.CachedResource;
|
import net.sourceforge.filebot.web.CachedResource;
|
||||||
|
|
||||||
|
|
||||||
public class ReleaseInfo {
|
public class ReleaseInfo {
|
||||||
|
|
||||||
|
public static Collection<String> detectSeriesNames(Collection<File> files) throws IOException {
|
||||||
|
SeriesNameMatcher matcher = new SeriesNameMatcher();
|
||||||
|
ReleaseInfo cleaner = new ReleaseInfo();
|
||||||
|
|
||||||
|
// match common word sequence and clean detected word sequence from unwanted elements
|
||||||
|
Collection<String> names = matcher.matchAll(files.toArray(new File[files.size()]));
|
||||||
|
return new LinkedHashSet<String>(cleaner.cleanRG(names));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public String getVideoSource(File file) {
|
public String getVideoSource(File file) {
|
||||||
// check parent and itself for group names
|
// check parent and itself for group names
|
||||||
return matchLast(getVideoSourcePattern(), file.getParent(), file.getName());
|
return matchLast(getVideoSourcePattern(), file.getParent(), file.getName());
|
||||||
|
@ -15,9 +15,9 @@ import java.util.Iterator;
|
|||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Map.Entry;
|
||||||
import java.util.Scanner;
|
import java.util.Scanner;
|
||||||
import java.util.TreeMap;
|
import java.util.TreeMap;
|
||||||
import java.util.Map.Entry;
|
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
@ -28,11 +28,6 @@ import net.sourceforge.tuned.FileUtilities;
|
|||||||
|
|
||||||
public class SeriesNameMatcher {
|
public class SeriesNameMatcher {
|
||||||
|
|
||||||
public static Collection<String> detectSeriesName(Collection<File> files) {
|
|
||||||
return new SeriesNameMatcher().matchAll(files.toArray(new File[files.size()]));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
protected final SeasonEpisodeMatcher seasonEpisodeMatcher = new SeasonEpisodeMatcher(new SeasonEpisodeFilter(30, 50, 1000));
|
protected final SeasonEpisodeMatcher seasonEpisodeMatcher = new SeasonEpisodeMatcher(new SeasonEpisodeFilter(30, 50, 1000));
|
||||||
protected final NameSimilarityMetric nameSimilarityMetric = new NameSimilarityMetric();
|
protected final NameSimilarityMetric nameSimilarityMetric = new NameSimilarityMetric();
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@ package net.sourceforge.filebot.ui.rename;
|
|||||||
|
|
||||||
import static java.util.Collections.*;
|
import static java.util.Collections.*;
|
||||||
import static net.sourceforge.filebot.MediaTypes.*;
|
import static net.sourceforge.filebot.MediaTypes.*;
|
||||||
import static net.sourceforge.filebot.similarity.SeriesNameMatcher.*;
|
import static net.sourceforge.filebot.mediainfo.ReleaseInfo.*;
|
||||||
import static net.sourceforge.filebot.web.EpisodeUtilities.*;
|
import static net.sourceforge.filebot.web.EpisodeUtilities.*;
|
||||||
import static net.sourceforge.tuned.FileUtilities.*;
|
import static net.sourceforge.tuned.FileUtilities.*;
|
||||||
import static net.sourceforge.tuned.ui.TunedUtilities.*;
|
import static net.sourceforge.tuned.ui.TunedUtilities.*;
|
||||||
@ -173,7 +173,7 @@ class EpisodeListMatcher implements AutoCompleteMatcher {
|
|||||||
final Map<File, List<File>> filesByFolder = mapByFolder(mediaFiles);
|
final Map<File, List<File>> filesByFolder = mapByFolder(mediaFiles);
|
||||||
|
|
||||||
// do matching all at once
|
// do matching all at once
|
||||||
if (filesByFolder.keySet().size() <= 5 || detectSeriesName(mediaFiles).size() <= 5) {
|
if (filesByFolder.keySet().size() <= 5 || detectSeriesNames(mediaFiles).size() <= 5) {
|
||||||
return matchEpisodeSet(mediaFiles, locale, autodetection, parent);
|
return matchEpisodeSet(mediaFiles, locale, autodetection, parent);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -215,7 +215,7 @@ class EpisodeListMatcher implements AutoCompleteMatcher {
|
|||||||
|
|
||||||
// detect series name and fetch episode list
|
// detect series name and fetch episode list
|
||||||
if (autodetection) {
|
if (autodetection) {
|
||||||
Collection<String> names = detectSeriesName(files);
|
Collection<String> names = detectSeriesNames(files);
|
||||||
if (names.size() > 0) {
|
if (names.size() > 0) {
|
||||||
// only allow one fetch session at a time so later requests can make use of cached results
|
// only allow one fetch session at a time so later requests can make use of cached results
|
||||||
synchronized (provider) {
|
synchronized (provider) {
|
||||||
|
@ -4,7 +4,7 @@ package net.sourceforge.filebot.ui.subtitle;
|
|||||||
|
|
||||||
import static javax.swing.BorderFactory.*;
|
import static javax.swing.BorderFactory.*;
|
||||||
import static javax.swing.JOptionPane.*;
|
import static javax.swing.JOptionPane.*;
|
||||||
import static net.sourceforge.filebot.similarity.SeriesNameMatcher.*;
|
import static net.sourceforge.filebot.mediainfo.ReleaseInfo.*;
|
||||||
import static net.sourceforge.filebot.subtitle.SubtitleUtilities.*;
|
import static net.sourceforge.filebot.subtitle.SubtitleUtilities.*;
|
||||||
import static net.sourceforge.tuned.FileUtilities.*;
|
import static net.sourceforge.tuned.FileUtilities.*;
|
||||||
import static net.sourceforge.tuned.StringUtilities.*;
|
import static net.sourceforge.tuned.StringUtilities.*;
|
||||||
@ -27,8 +27,8 @@ import java.util.HashMap;
|
|||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.TreeSet;
|
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
|
import java.util.TreeSet;
|
||||||
import java.util.concurrent.CancellationException;
|
import java.util.concurrent.CancellationException;
|
||||||
import java.util.concurrent.ExecutorService;
|
import java.util.concurrent.ExecutorService;
|
||||||
import java.util.concurrent.Executors;
|
import java.util.concurrent.Executors;
|
||||||
@ -973,7 +973,7 @@ class SubtitleAutoMatchDialog extends JDialog {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// auto-detect query and search for subtitles
|
// auto-detect query and search for subtitles
|
||||||
Collection<String> querySet = detectSeriesName(files);
|
Collection<String> querySet = detectSeriesNames(files);
|
||||||
List<SubtitleDescriptor> subtitles = findSubtitles(service, querySet, languageName);
|
List<SubtitleDescriptor> subtitles = findSubtitles(service, querySet, languageName);
|
||||||
|
|
||||||
// if auto-detection fails, ask user for input
|
// if auto-detection fails, ask user for input
|
||||||
|
Loading…
Reference in New Issue
Block a user