diff --git a/youtubeExtractor/src/main/java/at/huber/youtubeExtractor/YouTubeExtractor.java b/youtubeExtractor/src/main/java/at/huber/youtubeExtractor/YouTubeExtractor.java index 8ae9815..3131948 100644 --- a/youtubeExtractor/src/main/java/at/huber/youtubeExtractor/YouTubeExtractor.java +++ b/youtubeExtractor/src/main/java/at/huber/youtubeExtractor/YouTubeExtractor.java @@ -231,6 +231,14 @@ private SparseArray getStreamUrls() throws IOException, InterruptedExcep for (int i = 0; i < formats.length(); i++) { JSONObject format = formats.getJSONObject(i); + + // FORMAT_STREAM_TYPE_OTF(otf=1) requires downloading the init fragment (adding + // `&sq=0` to the URL) and parsing emsg box to determine the number of fragment that + // would subsequently requested with (`&sq=N`) (cf. youtube-dl) + String type = format.optString("type"); + if (type != null && type.equals("FORMAT_STREAM_TYPE_OTF")) + continue; + int itag = format.getInt("itag"); if (FORMAT_MAP.get(itag) != null) { @@ -255,6 +263,11 @@ private SparseArray getStreamUrls() throws IOException, InterruptedExcep for (int i = 0; i < adaptiveFormats.length(); i++) { JSONObject adaptiveFormat = adaptiveFormats.getJSONObject(i); + + String type = adaptiveFormat.optString("type"); + if (type != null && type.equals("FORMAT_STREAM_TYPE_OTF")) + continue; + int itag = adaptiveFormat.getInt("itag"); if (FORMAT_MAP.get(itag) != null) {