1
0
mirror of https://github.com/mitb-archive/filebot synced 2024-12-23 00:08:51 -05:00

* fixed various scripting issues and added tivo auto-sort script

This commit is contained in:
Reinhard Pointner 2012-03-02 07:08:54 +00:00
parent f7c2d8eb69
commit 4f6663a385
5 changed files with 46 additions and 9 deletions

View File

@ -405,7 +405,7 @@ public class CmdlineOperations implements CmdlineInterface {
File file = match.getValue();
Object movie = match.getCandidate();
String newName = (format != null) ? format.format(new MediaBindingBean(movie, file)) : validateFileName(MovieFormat.NameYear.format(movie));
File newFile = new File(newName + "." + getExtension(file));
File newFile = new File(outputDir, newName + "." + getExtension(file));
if (isInvalidFilePath(newFile)) {
CLILogger.config("Stripping invalid characters from new path: " + newName);
@ -680,7 +680,7 @@ public class CmdlineOperations implements CmdlineInterface {
public List<SearchResult> findProbableMatches(final String query, Iterable<? extends SearchResult> searchResults, boolean strict) {
// auto-select most probable search result
Map<String, SearchResult> probableMatches = new TreeMap<String, SearchResult>(String.CASE_INSENSITIVE_ORDER);
Map<String, SearchResult> probableMatches = new LinkedHashMap<String, SearchResult>();
// use name similarity metric
final SimilarityMetric metric = new NameSimilarityMetric();
@ -689,8 +689,8 @@ public class CmdlineOperations implements CmdlineInterface {
for (SearchResult result : searchResults) {
float f = (query == null) ? 1 : metric.getSimilarity(query, result.getName());
if (f >= (strict ? 0.9 : 0.8) || (f >= 0.6 && result.getName().toLowerCase().startsWith(query.toLowerCase()))) {
if (!probableMatches.containsKey(result.toString())) {
probableMatches.put(result.toString(), result);
if (!probableMatches.containsKey(result.toString().toLowerCase())) {
probableMatches.put(result.toString().toLowerCase(), result);
}
}
}

View File

@ -160,7 +160,8 @@ def parseEpisodeNumber(path, strict = true) {
}
def parseDate(path) {
return new DateMetric().parse(path)
def input = path instanceof File ? path.name : path.toString()
return new DateMetric().parse(input)
}
def detectSeriesName(files, locale = Locale.ENGLISH) {
@ -186,7 +187,7 @@ List.metaClass.sortBySimilarity = { prime, Closure toStringFunction = { obj -> o
// CLI bindings
def rename(args) { args = _defaults(args)
synchronized (_cli) {
_guarded { _cli.rename(_files(args), args.query, args.format, args.db, args.order, args.lang, args.strict) }
_guarded { _cli.rename(_files(args), args.query, args.output, args.format, args.db, args.order, args.lang, args.strict) }
}
}
@ -257,7 +258,7 @@ def _defaults(args) {
args.lang = args.lang ?: _args.lang
args.output = args.output ?: _args.output
args.encoding = args.encoding ?: _args.encoding
args.strict = args.strict ?: !_args.nonStrict
args.strict = args.strict != null ? args.strict : !_args.nonStrict
return args
}

View File

@ -358,6 +358,9 @@ public class MediaDetection {
// search for id in sibling nfo files
for (File folder : mapByFolder(files).keySet()) {
if (!folder.exists())
continue;
for (File nfo : folder.listFiles(MediaTypes.getDefaultFilter("application/nfo"))) {
String text = new String(readFile(nfo), "UTF-8");
@ -452,7 +455,7 @@ public class MediaDetection {
public String normalize(String sequence) {
return normalizePunctuation(sequence).toLowerCase(); // only normalize punctuation, make sure we keep the year (important for movie matching)
return normalizePunctuation(sequence); // only normalize punctuation, make sure we keep the year (important for movie matching)
}
}

View File

@ -98,7 +98,7 @@
<code><span class="block start">{</span><span class="variable">n</span>.<span class="method">space</span>(<span class="string">'.'</span>).<span class="method">lower</span>()<span class="block end">}</span>.<span class="block start">{</span><span class="variable">s</span><span class="block end">}</span><span class="block start">{</span><span class="variable">e</span>.<span class="method">pad</span>(<span class="numeral">2</span>)<span class="block end">}</span></code>dark.angel.301
</p>
<p>
<code><span class="block start">{</span><span class="variable">n</span><span class="block end">}</span> (<span class="block start">{</span><span class="variable">y</span><span class="block end">}</span>) (<span class="block start">{</span><span class="string">" CD<span class="variable">$pi</span>"</span><span class="block end">}</span>)</code>The Man from Earth (2007) CD1
<code><span class="block start">{</span><span class="variable">n</span><span class="block end">}</span> (<span class="block start">{</span><span class="variable">y</span><span class="block end">}</span>) <span class="block start">{</span><span class="string">" CD<span class="variable">$pi</span>"</span><span class="block end">}</span></code>The Man from Earth (2007) CD1
</p>
<p>
<code><span class="block start">{</span><span class="variable">n</span><span class="block end">}</span> [<span class="block start">{</span><span class="variable">y</span><span class="block end">}</span>] <span class="block start">{</span><span class="variable">vf</span><span class="block end">}</span> <span class="block start">{</span><span class="variable">af</span><span class="block end">}</span></code>The Man from Earth [2007] 720p 6ch

View File

@ -0,0 +1,33 @@
// filebot -script "http://filebot.sf.net/scripts/sortivo.groovy" <folder> [-non-strict] [--output path/to/folder]
/*
* Move/Rename a mix of episodes and movies that are all in the same folder.
*/
args.getFiles{ it.isVideo() }.each{
def tvs = detectSeriesName(it)
def mov = detectMovie(it, false)
println "$it.name [series: $tvs, movie: $mov]"
// DECIDE EPISODE VS MOVIE (IF NOT CLEAR)
if (tvs && mov) {
if (it.name =~ "(?i:$tvs - .+)") {
println "Exclude Movie: $mov"
mov = null
}
if (detectMovie(it, true)) {
println "Exclude Series: $tvs"
tvs = null
}
}
// EPISODE MODE
if (tvs && !mov) {
return rename(file:it, format:'{n} - {s00e00} - {t}', db:'TheTVDB')
}
// MOVIE MODE
if (mov && !tvs) {
return rename(file:it, format:'{n} ({y}){" CD$pi"}', db:'TheMovieDB')
}
}