Search in sources :

Example 1 with DoneFuture

use of org.fagu.fmv.utils.file.DoneFuture in project fmv by f-agu.

the class MovieFinder method flushToMap.

// *****************************************
/**
 * @see org.fagu.fmv.utils.file.FileFinder#flushToMap(java.util.List, java.util.function.Consumer)
 */
@Override
protected Future<Map<FileFound, InfosFile>> flushToMap(List<FileFound> buffer, Consumer<List<FileFound>> consumer) {
    Map<FileFound, InfosFile> outMap = new LinkedHashMap<>(buffer.size());
    for (FileFound fileFound : buffer) {
        File file = fileFound.getFileFound();
        try {
            MovieMetadatas movieMetadatas = FFHelper.videoMetadatas(file);
            Map<FileFound, InfosFile> flushMap = Collections.singletonMap(fileFound, new InfosFile(new Movie(file, movieMetadatas)));
            outMap.putAll(flushMap);
            if (consumer != null) {
                consumer.accept(Collections.singletonList(fileFound));
            }
            afterFlush(flushMap);
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }
    return new DoneFuture<>(outMap);
}
Also used : Movie(org.fagu.fmv.mymedia.classify.movie.Movie) MovieMetadatas(org.fagu.fmv.ffmpeg.metadatas.MovieMetadatas) DoneFuture(org.fagu.fmv.utils.file.DoneFuture) IOException(java.io.IOException) File(java.io.File) LinkedHashMap(java.util.LinkedHashMap)

Aggregations

File (java.io.File)1 IOException (java.io.IOException)1 LinkedHashMap (java.util.LinkedHashMap)1 MovieMetadatas (org.fagu.fmv.ffmpeg.metadatas.MovieMetadatas)1 Movie (org.fagu.fmv.mymedia.classify.movie.Movie)1 DoneFuture (org.fagu.fmv.utils.file.DoneFuture)1