@@ -511,14 +511,13 @@ public List<AudioStream> getAudioStreams() throws ExtractionException {
511511
512512 if (audioStreams == null ) {
513513 audioStreams = new ArrayList <>();
514- final StreamType streamType = getStreamType ();
515514
516515 try {
517- for (final ContentAndItagItemAndIsUrl entry
518- : getItags ( ADAPTIVE_FORMATS , ItagItem .ItagType .AUDIO )) {
519- final ItagItem itag = entry .itagItem ;
520- final String content = entry .content ;
521- final boolean isUrl = entry .isUrl ;
516+ for (final ItagInfo itagInfo : getItags ( ADAPTIVE_FORMATS ,
517+ ItagItem .ItagType .AUDIO )) {
518+ final ItagItem itag = itagInfo .itagItem ;
519+ final String content = itagInfo .content ;
520+ final boolean isUrl = itagInfo .isUrl ;
522521 final AudioStream audioStream ;
523522
524523 if (streamType == StreamType .VIDEO_STREAM ) {
@@ -558,14 +557,12 @@ public List<VideoStream> getVideoStreams() throws ExtractionException {
558557
559558 if (videoStreams == null ) {
560559 videoStreams = new ArrayList <>();
561- final StreamType streamType = getStreamType ();
562560
563561 try {
564- for (final ContentAndItagItemAndIsUrl entry
565- : getItags (FORMATS , ItagItem .ItagType .VIDEO )) {
566- final ItagItem itag = entry .itagItem ;
567- final String content = entry .content ;
568- final boolean isUrl = entry .isUrl ;
562+ for (final ItagInfo itagInfo : getItags (FORMATS , ItagItem .ItagType .VIDEO )) {
563+ final ItagItem itag = itagInfo .itagItem ;
564+ final String content = itagInfo .content ;
565+ final boolean isUrl = itagInfo .isUrl ;
569566 final VideoStream videoStream ;
570567
571568 if (streamType == StreamType .VIDEO_STREAM ) {
@@ -604,14 +601,13 @@ public List<VideoStream> getVideoOnlyStreams() throws ExtractionException {
604601
605602 if (videoOnlyStreams == null ) {
606603 videoOnlyStreams = new ArrayList <>();
607- final StreamType streamType = getStreamType ();
608604
609605 try {
610- for (final ContentAndItagItemAndIsUrl entry
611- : getItags ( ADAPTIVE_FORMATS , ItagItem .ItagType .VIDEO_ONLY )) {
612- final ItagItem itag = entry .itagItem ;
613- final String content = entry .content ;
614- final boolean isUrl = entry .isUrl ;
606+ for (final ItagInfo itagInfo : getItags ( ADAPTIVE_FORMATS ,
607+ ItagItem .ItagType .VIDEO_ONLY )) {
608+ final ItagItem itag = itagInfo .itagItem ;
609+ final String content = itagInfo .content ;
610+ final boolean isUrl = itagInfo .isUrl ;
615611 final VideoStream videoOnlyStream ;
616612
617613 if (streamType == StreamType .VIDEO_STREAM ) {
@@ -1176,31 +1172,30 @@ private JsonObject getVideoSecondaryInfoRenderer() throws ParsingException {
11761172 }
11771173
11781174 @ Nonnull
1179- private List <ContentAndItagItemAndIsUrl > getItags (final String streamingDataKey ,
1180- final ItagItem .ItagType itagTypeWanted )
1175+ private List <ItagInfo > getItags (final String streamingDataKey ,
1176+ final ItagItem .ItagType itagTypeWanted )
11811177 throws ParsingException {
1182- final List <ContentAndItagItemAndIsUrl > contentsAndItagItems = new ArrayList <>();
1178+ final List <ItagInfo > itagInfos = new ArrayList <>();
11831179 if (mobileStreamingData != null || desktopStreamingData != null ) {
1184- final StreamType streamType = getStreamType ();
11851180 // Use the desktopStreamingData JSON object first because there are fewer redirects
11861181 // from the desktop endpoint for OTF and post live streams
1187- contentsAndItagItems .addAll (getStreamsFromStreamingDataKey (desktopStreamingData ,
1188- streamingDataKey , itagTypeWanted , streamType ));
1189- contentsAndItagItems .addAll (getStreamsFromStreamingDataKey (mobileStreamingData ,
1190- streamingDataKey , itagTypeWanted , streamType ));
1182+ itagInfos .addAll (getStreamsFromStreamingDataKey (desktopStreamingData , streamingDataKey ,
1183+ itagTypeWanted , streamType ));
1184+ itagInfos .addAll (getStreamsFromStreamingDataKey (mobileStreamingData , streamingDataKey ,
1185+ itagTypeWanted , streamType ));
11911186 }
11921187
1193- return contentsAndItagItems ;
1188+ return itagInfos ;
11941189 }
11951190
11961191 @ Nonnull
1197- private List <ContentAndItagItemAndIsUrl > getStreamsFromStreamingDataKey (
1192+ private List <ItagInfo > getStreamsFromStreamingDataKey (
11981193 final JsonObject streamingData ,
11991194 final String streamingDataKey ,
12001195 final ItagItem .ItagType itagTypeWanted ,
12011196 final StreamType streamType ) throws ParsingException {
12021197
1203- final List <ContentAndItagItemAndIsUrl > contentsAndItagItemsAndAreUrls = new ArrayList <>();
1198+ final List <ItagInfo > itagInfos = new ArrayList <>();
12041199 if (streamingData != null && streamingData .has (streamingDataKey )) {
12051200 final YoutubeThrottlingDecrypter throttlingDecrypter = new YoutubeThrottlingDecrypter (
12061201 getId ());
@@ -1249,23 +1244,21 @@ private List<ContentAndItagItemAndIsUrl> getStreamsFromStreamingDataKey(
12491244 itagItem .setQuality (formatData .getString ("quality" ));
12501245 itagItem .setCodec (codec );
12511246
1252- if (itagType == ItagItem .ItagType .VIDEO || itagType == ItagItem .ItagType .VIDEO_ONLY ) {
1247+ if (itagType == ItagItem .ItagType .VIDEO
1248+ || itagType == ItagItem .ItagType .VIDEO_ONLY ) {
12531249 itagItem .fps = formatData .getInt ("fps" );
12541250 }
12551251 if (itagType == ItagItem .ItagType .AUDIO ) {
1256- itagItem .sampleRate = Integer .parseInt (formatData .getString ("audioSampleRate" ));
1252+ itagItem .sampleRate = Integer .parseInt (formatData .getString (
1253+ "audioSampleRate" ));
12571254 }
12581255
12591256 if (streamType == StreamType .VIDEO_STREAM ) {
12601257 if (formatData .getString ("type" , EMPTY_STRING )
12611258 .equalsIgnoreCase ("FORMAT_STREAM_TYPE_OTF" )) {
1262- contentsAndItagItemsAndAreUrls .add (
1263- new ContentAndItagItemAndIsUrl (streamUrl , itagItem ,
1264- false ));
1259+ itagInfos .add (new ItagInfo (streamUrl , itagItem , false ));
12651260 } else {
1266- contentsAndItagItemsAndAreUrls .add (
1267- new ContentAndItagItemAndIsUrl (streamUrl , itagItem ,
1268- true ));
1261+ itagInfos .add (new ItagInfo (streamUrl , itagItem , true ));
12691262 }
12701263 } else if (streamType == StreamType .POST_LIVE_STREAM ) {
12711264 // Even if it increases the content loading, we need to generate
@@ -1276,9 +1269,7 @@ private List<ContentAndItagItemAndIsUrl> getStreamsFromStreamingDataKey(
12761269 createDashManifestFromPostLiveStreamDvrStreamingUrl (
12771270 streamUrl , itagItem , formatData
12781271 .getInt ("targetDurationSec" ));
1279- contentsAndItagItemsAndAreUrls .add (
1280- new ContentAndItagItemAndIsUrl (content , itagItem ,
1281- false ));
1272+ itagInfos .add (new ItagInfo (content , itagItem , false ));
12821273 } catch (final YoutubeDashManifestCreator
12831274 .YoutubeDashManifestCreationException ignored ) {
12841275 // Something went wrong when generating the DASH manifest
@@ -1289,9 +1280,7 @@ private List<ContentAndItagItemAndIsUrl> getStreamsFromStreamingDataKey(
12891280 // livestreams, so because of the requirements of StreamInfo
12901281 // objects, return these streams as DASH streams
12911282 // (even if they are not playable).
1292- contentsAndItagItemsAndAreUrls .add (
1293- new ContentAndItagItemAndIsUrl (streamUrl , itagItem ,
1294- true ));
1283+ itagInfos .add (new ItagInfo (streamUrl , itagItem , true ));
12951284 }
12961285 }
12971286 } catch (final UnsupportedEncodingException | ParsingException ignored ) {
@@ -1300,7 +1289,7 @@ private List<ContentAndItagItemAndIsUrl> getStreamsFromStreamingDataKey(
13001289 }
13011290 }
13021291
1303- return contentsAndItagItemsAndAreUrls ;
1292+ return itagInfos ;
13041293 }
13051294
13061295 @ Nonnull
0 commit comments