{textLanguages} binding

This commit is contained in:
Reinhard Pointner 2016-10-29 01:16:50 +08:00
parent 98466424e7
commit 1854bc9f51
3 changed files with 17 additions and 2 deletions

View File

@ -443,7 +443,7 @@ public abstract class ScriptShellBaseClass extends Script {
try {
return formatter.format(new MediaBindingBean(o, f));
} catch (SuppressedThrowables e) {
debug.warning(format("Failed to read media info: %s: %s: %s", e.getMessage(), format, f));
debug.warning(format("Failed to read media info: %s: %s => %s", e.getMessage(), format, f));
}
return null;

View File

@ -35,6 +35,8 @@ import java.util.Map.Entry;
import java.util.Objects;
import java.util.Optional;
import java.util.regex.Pattern;
import java.util.stream.IntStream;
import java.util.stream.Stream;
import net.filebot.ApplicationFolder;
import net.filebot.Cache;
@ -776,6 +778,11 @@ public class MediaBindingBean {
return getMediaInfo(StreamKind.General, 0, "Title", "Movie");
}
@Define("textLanguages")
public List<String> getTextLanguageList() {
return getMediaInfo(StreamKind.Text, "Language/String").filter(Objects::nonNull).distinct().collect(toList());
}
@Define("bitrate")
public Long getOverallBitRate() {
return new Double(getMediaInfo(StreamKind.General, 0, "OverallBitRate")).longValue();
@ -1084,6 +1091,14 @@ public class MediaBindingBean {
return undefined(String.format("%s[%d][%s]", streamKind, streamNumber, join(keys, ", ")));
}
private Stream<String> getMediaInfo(StreamKind streamKind, String... keys) {
return IntStream.range(0, getMediaInfo().streamCount(streamKind)).mapToObj(streamNumber -> {
return stream(keys).map(key -> {
return getMediaInfo().get(streamKind, streamNumber, key);
}).filter(s -> s.length() > 0).findFirst().orElse(null);
});
}
private AssociativeScriptObject createBindingObject(File file, Object info, Map<File, ?> context) {
MediaBindingBean mediaBindingBean = new MediaBindingBean(info, file, context) {

View File

@ -2,4 +2,4 @@
parameter.exclude: ^StreamKind|^UniqueID|^StreamOrder|^ID|Count$
# preview expressions (keys are tagged so they can be sorted alphabetically)
expressions: n, y, s, e, sxe, s00e00, t, d, startdate, absolute, es, e00, sy, sc, age, special, episode, series, primaryTitle, alias, movie, tmdbid, imdbid, pi, pn, lang, subt, plex, az, type, anime, regular, music, album, artist, albumArtist, actors, director, collection, genre, genres, languages, runtime, certification, rating, vc, ac, cf, vf, hpi, af, channels, resolution, dim, bitdepth, ws, sdhd, source, tags, s3d, group, original, info, info.network, info.status, info.productionCompanies, info.productionCountries, info.certifications, info.certifications.DE, omdb.rating, omdb.votes, localize.German.name, localize.German.title, fn, ext, mediaType, mediaPath, file, file.name, folder, folder.name, mediaTitle, duration, seconds, minutes, bytes, megabytes, gigabytes, crc32, media, media.overallBitRateString, video[0], video[0].codecID, video[0].frameRate, video[0].displayAspectRatioString, video[0].scanType, audio[0], audio[0].bitRateString, audio[0].language, audio, audio.language, text[0], text[0].codecInfo, text[0].language, text, text.language
expressions: n, y, s, e, sxe, s00e00, t, d, startdate, absolute, es, e00, sy, sc, age, special, episode, series, primaryTitle, alias, movie, tmdbid, imdbid, pi, pn, lang, subt, plex, az, type, anime, regular, music, album, artist, albumArtist, actors, director, collection, genre, genres, languages, runtime, certification, rating, vc, ac, cf, vf, hpi, af, channels, resolution, dim, bitdepth, ws, sdhd, source, tags, s3d, group, original, info, info.network, info.status, info.productionCompanies, info.productionCountries, info.certifications, info.certifications.DE, omdb.rating, omdb.votes, localize.German.name, localize.German.title, fn, ext, mediaType, mediaPath, file, file.name, folder, folder.name, mediaTitle, textLanguages, duration, seconds, minutes, bytes, megabytes, gigabytes, crc32, media, media.overallBitRateString, video[0], video[0].codecID, video[0].frameRate, video[0].displayAspectRatioString, video[0].scanType, audio[0], audio[0].bitRateString, audio[0].language, audio, audio.language, text[0], text[0].codecInfo, text[0].language, text, text.language