mirror of
https://github.com/mitb-archive/filebot
synced 2024-11-17 23:05:03 -05:00
* added --conflict option to -extract mode
This commit is contained in:
parent
0b35b1abc1
commit
64f93c991b
@ -63,7 +63,7 @@ public class ArgumentProcessor {
|
|||||||
Collection<File> files = new LinkedHashSet<File>(args.getFiles(true));
|
Collection<File> files = new LinkedHashSet<File>(args.getFiles(true));
|
||||||
|
|
||||||
if (args.extract) {
|
if (args.extract) {
|
||||||
files.addAll(cli.extract(files, args.output));
|
files.addAll(cli.extract(files, args.output, args.conflict));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (args.getSubtitles) {
|
if (args.getSubtitles) {
|
||||||
|
@ -30,6 +30,6 @@ public interface CmdlineInterface {
|
|||||||
String getMediaInfo(File file, String format) throws Exception;
|
String getMediaInfo(File file, String format) throws Exception;
|
||||||
|
|
||||||
|
|
||||||
List<File> extract(Collection<File> files, String output) throws Exception;
|
List<File> extract(Collection<File> files, String output, String conflict) throws Exception;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -928,7 +928,9 @@ public class CmdlineOperations implements CmdlineInterface {
|
|||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<File> extract(Collection<File> files, String output) throws Exception {
|
public List<File> extract(Collection<File> files, String output, String conflict) throws Exception {
|
||||||
|
ConflictAction conflictAction = ConflictAction.forName(conflict);
|
||||||
|
|
||||||
// only keep single-volume archives or first part of multi-volume archives
|
// only keep single-volume archives or first part of multi-volume archives
|
||||||
List<File> archiveFiles = filter(files, Archive.VOLUME_ONE_FILTER);
|
List<File> archiveFiles = filter(files, Archive.VOLUME_ONE_FILTER);
|
||||||
List<File> extractedFiles = new ArrayList<File>();
|
List<File> extractedFiles = new ArrayList<File>();
|
||||||
@ -942,12 +944,19 @@ public class CmdlineOperations implements CmdlineInterface {
|
|||||||
FileMapper outputMapper = new FileMapper(outputFolder, false);
|
FileMapper outputMapper = new FileMapper(outputFolder, false);
|
||||||
|
|
||||||
List<File> entries = archive.listFiles();
|
List<File> entries = archive.listFiles();
|
||||||
|
boolean skip = true;
|
||||||
for (File entry : entries) {
|
for (File entry : entries) {
|
||||||
extractedFiles.add(outputMapper.getOutputFile(entry));
|
File outputFile = outputMapper.getOutputFile(entry);
|
||||||
|
skip &= outputFile.exists();
|
||||||
|
extractedFiles.add(outputFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
CLILogger.finest("Extracting files " + entries);
|
if (!skip || conflictAction == ConflictAction.OVERRIDE) {
|
||||||
archive.extract(outputMapper);
|
CLILogger.finest("Extracting files " + entries);
|
||||||
|
archive.extract(outputMapper);
|
||||||
|
} else {
|
||||||
|
CLILogger.finest("Skipped extracting files " + entries);
|
||||||
|
}
|
||||||
} finally {
|
} finally {
|
||||||
archive.close();
|
archive.close();
|
||||||
}
|
}
|
||||||
|
@ -187,19 +187,19 @@ List.metaClass.sortBySimilarity = { prime, Closure toStringFunction = { obj -> o
|
|||||||
// CLI bindings
|
// CLI bindings
|
||||||
def rename(args) { args = _defaults(args)
|
def rename(args) { args = _defaults(args)
|
||||||
synchronized (_cli) {
|
synchronized (_cli) {
|
||||||
_guarded { _cli.rename(_files(args), args.action, args.conflict, args.output, args.format, args.db, args.query, args.order, args.lang, args.strict) }
|
_guarded { _cli.rename(_files(args), args.action as String, args.conflict as String, args.output as String, args.format as String, args.db as String, args.query as String, args.order as String, args.lang as String, args.strict as Boolean) }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
def getSubtitles(args) { args = _defaults(args)
|
def getSubtitles(args) { args = _defaults(args)
|
||||||
synchronized (_cli) {
|
synchronized (_cli) {
|
||||||
_guarded { _cli.getSubtitles(_files(args), args.query, args.lang, args.output, args.encoding, args.strict) }
|
_guarded { _cli.getSubtitles(_files(args), args.query as String, args.lang as String, args.output as String, args.encoding as String, args.strict as Boolean) }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
def getMissingSubtitles(args) { args = _defaults(args)
|
def getMissingSubtitles(args) { args = _defaults(args)
|
||||||
synchronized (_cli) {
|
synchronized (_cli) {
|
||||||
_guarded { _cli.getMissingSubtitles(_files(args), args.query, args.lang, args.output, args.encoding, args.strict) }
|
_guarded { _cli.getMissingSubtitles(_files(args), args.query as String, args.lang as String, args.output as String, args.encoding as String, args.strict as Boolean) }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -211,25 +211,25 @@ def check(args) {
|
|||||||
|
|
||||||
def compute(args) { args = _defaults(args)
|
def compute(args) { args = _defaults(args)
|
||||||
synchronized (_cli) {
|
synchronized (_cli) {
|
||||||
_guarded { _cli.compute(_files(args), args.output, args.encoding) }
|
_guarded { _cli.compute(_files(args), args.output as String, args.encoding as String) }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
def extract(args) { args = _defaults(args)
|
def extract(args) { args = _defaults(args)
|
||||||
synchronized (_cli) {
|
synchronized (_cli) {
|
||||||
_guarded { _cli.extract(_files(args), args.output) }
|
_guarded { _cli.extract(_files(args), args.output as String, args.conflict as String) }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
def fetchEpisodeList(args) { args = _defaults(args)
|
def fetchEpisodeList(args) { args = _defaults(args)
|
||||||
synchronized (_cli) {
|
synchronized (_cli) {
|
||||||
_guarded { _cli.fetchEpisodeList(args.query, args.format, args.db, args.order, args.lang) }
|
_guarded { _cli.fetchEpisodeList(args.query as String, args.format as String, args.db as String, args.order as String, args.lang as String) }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
def getMediaInfo(args) { args = _defaults(args)
|
def getMediaInfo(args) { args = _defaults(args)
|
||||||
synchronized (_cli) {
|
synchronized (_cli) {
|
||||||
_guarded { _cli.getMediaInfo(args.file, args.format) }
|
_guarded { _cli.getMediaInfo(args.file as File, args.format as String) }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -239,11 +239,16 @@ def getMediaInfo(args) { args = _defaults(args)
|
|||||||
*/
|
*/
|
||||||
def _files(args) {
|
def _files(args) {
|
||||||
def files = [];
|
def files = [];
|
||||||
if (args.folder)
|
if (args.folder) {
|
||||||
args.folder.traverse(type:FILES, maxDepth:0) { files += it }
|
(args.folder as File).traverse(type:FILES, maxDepth:0) { files += it }
|
||||||
if (args.file)
|
}
|
||||||
files += args.file
|
if (args.file) {
|
||||||
|
if (args.file instanceof Iterable || args.file instanceof File[]) {
|
||||||
|
files += args.file as List
|
||||||
|
} else {
|
||||||
|
files += args.file as File
|
||||||
|
}
|
||||||
|
}
|
||||||
return files
|
return files
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -193,6 +193,11 @@
|
|||||||
<td>rename action</td>
|
<td>rename action</td>
|
||||||
<td>move | copy | keeplink | symlink | hardlink</td>
|
<td>move | copy | keeplink | symlink | hardlink</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>--conflict</td>
|
||||||
|
<td>conflict resolution</td>
|
||||||
|
<td>override | skip | fail</td>
|
||||||
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td>-get-subtitles</td>
|
<td>-get-subtitles</td>
|
||||||
<td>fetch subtitles</td>
|
<td>fetch subtitles</td>
|
||||||
|
Loading…
Reference in New Issue
Block a user