1
0
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:
Reinhard Pointner 2011-11-02 18:19:09 +00:00
parent 1b942fcd15
commit 38d9903d0f
6 changed files with 41 additions and 4 deletions

View File

@ -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;
}

View File

@ -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));

View File

@ -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;
}

View File

@ -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);

View File

@ -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) }
}
/**

View 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) }