diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/ItagItem.java b/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/ItagItem.java index 8a521b9cae..19e3c4a059 100644 --- a/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/ItagItem.java +++ b/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/ItagItem.java @@ -91,12 +91,12 @@ public static ItagItem getItag(int itagId) throws ParsingException { throw new ParsingException("itag=" + itagId + " not supported"); } - public static ItagItem getItag(int itagId, int averageBitrate, int fps, String qualityLabel, String mimeType) throws ParsingException { + public static final ItagItem getItag(final int itagId, final int averageBitrate, final int fps, final String qualityLabel, final String mimeType) throws ParsingException { - String[] split = mimeType.split(";")[0].split("/"); - String streamType = split[0]; - String fileType = split[1]; - String codec = mimeType.split("\"")[1]; + final String[] split = mimeType.split(";")[0].split("/"); + final String streamType = split[0]; + final String fileType = split[1]; + final String codec = mimeType.split("\"")[1]; MediaFormat format = null; ItagType itagType = null; @@ -110,17 +110,10 @@ public static ItagItem getItag(int itagId, int averageBitrate, int fps, String q itagType = AUDIO; } - if (itagType == AUDIO) { - if (fileType.equals("mp4") && (codec.startsWith("m4a") || codec.startsWith("mp4a") )) - format = M4A; - if (fileType.startsWith("webm") && codec.equals("opus")) - format = WEBMA_OPUS; - } - if (itagType == VIDEO) { if (fileType.equals("mp4")) format = MPEG_4; - if(fileType.equals("3gpp")) + if (fileType.equals("3gpp")) format = v3GPP; } @@ -131,6 +124,13 @@ public static ItagItem getItag(int itagId, int averageBitrate, int fps, String q format = WEBM; } + if (itagType == AUDIO) { + if (fileType.equals("mp4") && (codec.startsWith("m4a") || codec.startsWith("mp4a"))) + format = M4A; + if (fileType.startsWith("webm") && codec.equals("opus")) + format = WEBMA_OPUS; + } + if (itagType == null || format == null) throw new ParsingException("Unknown mimeType: " + mimeType);