mirror of
https://github.com/mitb-archive/filebot
synced 2024-12-24 08:48:51 -05:00
* added PrintMediaInfo command in CLI and scripting interface
This commit is contained in:
parent
1b942fcd15
commit
38d9903d0f
@ -28,6 +28,9 @@ public class ArgumentBean {
|
||||
@Option(name = "-list", usage = "Fetch episode list")
|
||||
public boolean list = false;
|
||||
|
||||
@Option(name = "-mediainfo", usage = "Get media info")
|
||||
public boolean mediaInfo = false;
|
||||
|
||||
@Option(name = "--db", usage = "Episode/Movie database", metaVar = "[TVRage, AniDB, TheTVDB] or [OpenSubtitles, TheMovieDB]")
|
||||
public String db;
|
||||
|
||||
@ -78,7 +81,7 @@ public class ArgumentBean {
|
||||
|
||||
|
||||
public boolean runCLI() {
|
||||
return rename || getSubtitles || check || list || script != null;
|
||||
return rename || getSubtitles || check || list || mediaInfo || script != null;
|
||||
}
|
||||
|
||||
|
||||
|
@ -41,7 +41,7 @@ public class ArgumentProcessor {
|
||||
CLILogger.setLevel(args.getLogLevel());
|
||||
|
||||
try {
|
||||
// print operations
|
||||
// print episode info
|
||||
if (args.list) {
|
||||
for (String eps : cli.fetchEpisodeList(args.query, args.format, args.db, args.lang)) {
|
||||
System.out.println(eps);
|
||||
@ -49,6 +49,15 @@ public class ArgumentProcessor {
|
||||
return 0;
|
||||
}
|
||||
|
||||
// print media info
|
||||
if (args.mediaInfo) {
|
||||
for (File file : args.getFiles(true)) {
|
||||
System.out.println(cli.getMediaInfo(file, args.format));
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
// execute CLI operations
|
||||
if (args.script == null) {
|
||||
// file operations
|
||||
Set<File> files = new LinkedHashSet<File>(args.getFiles(true));
|
||||
|
@ -24,4 +24,7 @@ public interface CmdlineInterface {
|
||||
|
||||
List<String> fetchEpisodeList(String query, String format, String db, String lang) throws Exception;
|
||||
|
||||
|
||||
String getMediaInfo(File file, String format) throws Exception;
|
||||
|
||||
}
|
||||
|
@ -637,8 +637,6 @@ public class CmdlineOperations implements CmdlineInterface {
|
||||
Locale locale = getLanguage(languageName).toLocale();
|
||||
|
||||
SearchResult hit = selectSearchResult(query, service.search(query, locale), false);
|
||||
|
||||
Analytics.trackEvent("CLI", "PrintEpisodeList", hit.getName());
|
||||
List<String> episodes = new ArrayList<String>();
|
||||
|
||||
for (Episode it : service.getEpisodeList(hit, locale)) {
|
||||
@ -650,6 +648,13 @@ public class CmdlineOperations implements CmdlineInterface {
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getMediaInfo(File file, String expression) throws Exception {
|
||||
ExpressionFormat format = new ExpressionFormat(expression != null ? expression : "{fn} [{resolution} {af} {vc} {ac}]");
|
||||
return format.format(new MediaBindingBean(file, file));
|
||||
}
|
||||
|
||||
|
||||
private Language getLanguage(String lang) {
|
||||
// try to look up by language code
|
||||
Language language = Language.getLanguage(lang);
|
||||
|
@ -3,6 +3,7 @@ import static groovy.io.FileType.*
|
||||
|
||||
|
||||
File.metaClass.isVideo = { _types.getFilter("video").accept(delegate) }
|
||||
File.metaClass.isAudio = { _types.getFilter("audio").accept(delegate) }
|
||||
File.metaClass.isSubtitle = { _types.getFilter("subtitle").accept(delegate) }
|
||||
File.metaClass.isVerification = { _types.getFilter("verification").accept(delegate) }
|
||||
|
||||
@ -35,6 +36,13 @@ def compute(args) { args = _defaults(args)
|
||||
_guarded { _cli.compute(_files(args), args.output, args.encoding) }
|
||||
}
|
||||
|
||||
def fetchEpisodeList(args) { args = _defaults(args)
|
||||
_guarded { _cli.fetchEpisodeList(args.query, args.format, args.db, args.lang) }
|
||||
}
|
||||
|
||||
def getMediaInfo(args) { args = _defaults(args)
|
||||
_guarded { _cli.getMediaInfo(args.file, args.format) }
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
|
9
website/data/shell/mi.groovy
Normal file
9
website/data/shell/mi.groovy
Normal file
@ -0,0 +1,9 @@
|
||||
// filebot -script "http://filebot.sourceforge.net/data/shell/mi.groovy" --format "{fn} [{resolution} {af} {vc} {ac}]" <folder>
|
||||
|
||||
/*
|
||||
* Print media info for all video files using given or default format pattern
|
||||
*/
|
||||
args.getFiles()
|
||||
.findAll { it.isVideo() }
|
||||
.sort { a, b -> a.name.compareTo(b.name) }
|
||||
.each { println getMediaInfo(file:it) }
|
Loading…
Reference in New Issue
Block a user