Search in sources :

Example 1 with FileSource

use of org.fagu.fmv.core.project.FileSource in project fmv by f-agu.

the class Info method run.

/**
 * @see org.fagu.fmv.cli.Command#run(java.lang.String[])
 */
@Override
public void run(String[] args) {
    if (args.length == 0) {
        help();
        return;
    }
    for (String arg : args) {
        int num = NumberUtils.toInt(arg, -1);
        if (num < 0) {
            println("Source error: " + arg);
        }
        FileSource source = project.getSource(num);
        File file = source.getFile();
        println(file.getPath());
        if (source.isImage()) {
            display(source.getImageMetadatas(), DEFAULT_PADDING);
        } else if (source.isAudioOrVideo()) {
            display(source.getVideoMetadatas());
        } else {
            println("  undefined...");
        }
    }
}
Also used : FileSource(org.fagu.fmv.core.project.FileSource) File(java.io.File)

Example 2 with FileSource

use of org.fagu.fmv.core.project.FileSource in project fmv by f-agu.

the class ViewShift method view.

/**
 */
public void view() {
    Integer lastView = project.getProperty(Properties.VIEW_LAST_MEDIA);
    if (lastView == null) {
        // getPrinter().println("last view not defined");
        // return;
        lastView = Integer.valueOf(0);
    }
    FileSource source = project.getSource(lastView);
    getPrinter().println("Last view n°" + lastView + ": " + source.getFile().getName());
    lastView = operator.applyAsInt(lastView);
    super.run(new String[] { lastView.toString() });
}
Also used : FileSource(org.fagu.fmv.core.project.FileSource)

Example 3 with FileSource

use of org.fagu.fmv.core.project.FileSource in project fmv by f-agu.

the class Append method run.

/**
 * @see org.fagu.fmv.cli.Command#run(java.lang.String[])
 */
@Override
public void run(String[] args) {
    if (args.length == 0) {
        getPrinter().println("usage: append <num-source> ...");
        return;
    }
    int sourceNum = Integer.parseInt(args[0]);
    FileSource source = project.getSource(sourceNum);
    if (source.isAudioOrVideo()) {
        appendAudioOrVideo(sourceNum, args);
    } else if (source.isImage()) {
        appendImage(sourceNum, args);
    } else {
        throw new IllegalStateException("Unknown file type: " + source.getFileType());
    }
}
Also used : FileSource(org.fagu.fmv.core.project.FileSource)

Example 4 with FileSource

use of org.fagu.fmv.core.project.FileSource in project fmv by f-agu.

the class AppendLastView method run.

/**
 * @see org.fagu.fmv.cli.Command#run(java.lang.String[])
 */
@Override
public void run(String[] args) {
    if (args.length == 0) {
        getPrinter().println("usage: appendlastview ...");
        return;
    }
    Integer lastView = project.getProperty(Properties.VIEW_LAST_MEDIA);
    if (lastView == null) {
        getPrinter().println("last view not defined");
        return;
    }
    FileSource source = project.getSource(lastView);
    getPrinter().println("Last view n°" + lastView + ": " + source.getFile().getName());
    String[] strs = new String[args.length + 1];
    strs[0] = lastView.toString();
    System.arraycopy(args, 0, strs, 1, args.length);
    super.run(strs);
}
Also used : FileSource(org.fagu.fmv.core.project.FileSource)

Example 5 with FileSource

use of org.fagu.fmv.core.project.FileSource in project fmv by f-agu.

the class List method getFilter.

// *************************************************
/**
 * @param args
 * @return
 */
private Predicate<FileSource> getFilter(String[] args) {
    CommandLine cmdLine = parse(args);
    Predicate<FileSource> predicate = null;
    for (final FileType fileType : FileType.values()) {
        String name = fileType.name().toLowerCase();
        if (cmdLine.hasOption(name)) {
            Predicate<FileSource> tmp = fs -> fileType == fs.getFileType();
            predicate = predicate == null ? tmp : predicate.or(tmp);
        }
    }
    if (predicate == null) {
        return s -> true;
    }
    return predicate;
}
Also used : Command(org.fagu.fmv.cli.annotation.Command) Alias(org.fagu.fmv.cli.annotation.Alias) Predicate(java.util.function.Predicate) FileSource(org.fagu.fmv.core.project.FileSource) Options(org.apache.commons.cli.Options) CommandLine(org.apache.commons.cli.CommandLine) ConsoleOutput(org.fagu.fmv.cli.ConsoleOutput) Aliases(org.fagu.fmv.cli.annotation.Aliases) FileType(org.fagu.fmv.media.FileType) CommandLine(org.apache.commons.cli.CommandLine) FileType(org.fagu.fmv.media.FileType) FileSource(org.fagu.fmv.core.project.FileSource)

Aggregations

FileSource (org.fagu.fmv.core.project.FileSource)6 File (java.io.File)1 Predicate (java.util.function.Predicate)1 CommandLine (org.apache.commons.cli.CommandLine)1 Options (org.apache.commons.cli.Options)1 ConsoleOutput (org.fagu.fmv.cli.ConsoleOutput)1 Alias (org.fagu.fmv.cli.annotation.Alias)1 Aliases (org.fagu.fmv.cli.annotation.Aliases)1 Command (org.fagu.fmv.cli.annotation.Command)1 FileType (org.fagu.fmv.media.FileType)1