Support corner-case with unusual MediaInfo Channel(s) values

This commit is contained in:
Reinhard Pointner 2016-01-25 11:10:56 +00:00
parent cd9d55d8a5
commit b0977a7b2c
2 changed files with 4 additions and 3 deletions

View File

@ -313,7 +313,7 @@ public class MediaBindingBean {
String extensions = getMediaInfo(StreamKind.General, 0, "Codec/Extensions", "Format"); String extensions = getMediaInfo(StreamKind.General, 0, "Codec/Extensions", "Format");
// get first extension // get first extension
return new Scanner(extensions).next().toLowerCase(); return SPACE.splitAsStream(extensions).findFirst().get().toLowerCase();
} }
@Define("vf") @Define("vf")
@ -350,8 +350,8 @@ public class MediaBindingBean {
public String getAudioChannels() { public String getAudioChannels() {
String channels = getMediaInfo(StreamKind.Audio, 0, "Channel(s)_Original", "Channel(s)"); String channels = getMediaInfo(StreamKind.Audio, 0, "Channel(s)_Original", "Channel(s)");
// e.g. 6ch // get first number, e.g. 6ch
return channels + "ch"; return SPACE.splitAsStream(channels).findFirst().get() + "ch";
} }
@Define("resolution") @Define("resolution")

View File

@ -11,6 +11,7 @@ import java.util.regex.Pattern;
public final class StringUtilities { public final class StringUtilities {
public static final Pattern SPACE = Pattern.compile("\\s+");
public static final Pattern DIGIT = Pattern.compile("\\d+"); public static final Pattern DIGIT = Pattern.compile("\\d+");
public static final Pattern NON_DIGIT = Pattern.compile("\\D+"); public static final Pattern NON_DIGIT = Pattern.compile("\\D+");