Skip to content

Commit

Permalink
Filter out videos using FORMAT_STREAM_TYPE_OTF (HaarigerHarald#205)
Browse files Browse the repository at this point in the history
* Filter out videos using FORMAT_STREAM_TYPE_OTF

* Fix a wrong usage of JSON getString
  • Loading branch information
Minos authored Oct 6, 2021
1 parent cd42f6c commit 09716d0
Showing 1 changed file with 13 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,14 @@ private SparseArray<YtFile> 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) {
Expand All @@ -255,6 +263,11 @@ private SparseArray<YtFile> 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) {
Expand Down

0 comments on commit 09716d0

Please sign in to comment.