@@ -159,11 +159,11 @@ public List<AudioStream> getAudioStreams() throws IOException, ExtractionExcepti
159159 return getStreams ("audio" ,
160160 dto -> {
161161 final AudioStream .Builder builder = new AudioStream .Builder ()
162- .setId (dto .getUrlValue () .getString ("tech" , ID_UNKNOWN ))
163- .setContent (dto .getUrlValue () .getString (URL ), true )
162+ .setId (dto .urlValue .getString ("tech" , ID_UNKNOWN ))
163+ .setContent (dto .urlValue .getString (URL ), true )
164164 .setAverageBitrate (UNKNOWN_BITRATE );
165165
166- if ("hls" .equals (dto .getUrlKey () )) {
166+ if ("hls" .equals (dto .urlKey )) {
167167 // We don't know with the type string what media format will
168168 // have HLS streams.
169169 // However, the tech string may contain some information
@@ -172,7 +172,7 @@ public List<AudioStream> getAudioStreams() throws IOException, ExtractionExcepti
172172 .build ();
173173 }
174174
175- return builder .setMediaFormat (MediaFormat .getFromSuffix (dto .getUrlKey () ))
175+ return builder .setMediaFormat (MediaFormat .getFromSuffix (dto .urlKey ))
176176 .build ();
177177 });
178178 }
@@ -181,15 +181,15 @@ public List<AudioStream> getAudioStreams() throws IOException, ExtractionExcepti
181181 public List <VideoStream > getVideoStreams () throws IOException , ExtractionException {
182182 return getStreams ("video" ,
183183 dto -> {
184- final JsonArray videoSize = dto .getStreamJsonObj () .getArray ("videoSize" );
184+ final JsonArray videoSize = dto .streamJsonObj .getArray ("videoSize" );
185185
186186 final VideoStream .Builder builder = new VideoStream .Builder ()
187- .setId (dto .getUrlValue () .getString ("tech" , ID_UNKNOWN ))
188- .setContent (dto .getUrlValue () .getString (URL ), true )
187+ .setId (dto .urlValue .getString ("tech" , ID_UNKNOWN ))
188+ .setContent (dto .urlValue .getString (URL ), true )
189189 .setIsVideoOnly (false )
190190 .setResolution (videoSize .getInt (0 ) + "x" + videoSize .getInt (1 ));
191191
192- if ("hls" .equals (dto .getUrlKey () )) {
192+ if ("hls" .equals (dto .urlKey )) {
193193 // We don't know with the type string what media format will
194194 // have HLS streams.
195195 // However, the tech string may contain some information
@@ -198,11 +198,32 @@ public List<VideoStream> getVideoStreams() throws IOException, ExtractionExcepti
198198 .build ();
199199 }
200200
201- return builder .setMediaFormat (MediaFormat .getFromSuffix (dto .getUrlKey () ))
201+ return builder .setMediaFormat (MediaFormat .getFromSuffix (dto .urlKey ))
202202 .build ();
203203 });
204204 }
205205
206+
207+ /**
208+ * This is just an internal class used in {@link #getStreams(String, Function)} to tie together
209+ * the stream json object, its URL key and its URL value. An object of this class would be
210+ * temporary and the three values it holds would be <b>convert</b>ed to a proper {@link Stream}
211+ * object based on the wanted stream type.
212+ */
213+ private static final class MediaCCCLiveStreamMapperDTO {
214+ final JsonObject streamJsonObj ;
215+ final String urlKey ;
216+ final JsonObject urlValue ;
217+
218+ MediaCCCLiveStreamMapperDTO (final JsonObject streamJsonObj ,
219+ final String urlKey ,
220+ final JsonObject urlValue ) {
221+ this .streamJsonObj = streamJsonObj ;
222+ this .urlKey = urlKey ;
223+ this .urlValue = urlValue ;
224+ }
225+ }
226+
206227 private <T extends Stream > List <T > getStreams (
207228 @ Nonnull final String streamType ,
208229 @ Nonnull final Function <MediaCCCLiveStreamMapperDTO , T > converter ) {
@@ -220,7 +241,7 @@ private <T extends Stream> List<T> getStreams(
220241 e .getKey (),
221242 (JsonObject ) e .getValue ())))
222243 // The DASH manifest will be extracted with getDashMpdUrl
223- .filter (dto -> !"dash" .equals (dto .getUrlKey () ))
244+ .filter (dto -> !"dash" .equals (dto .urlKey ))
224245 // Convert
225246 .map (converter )
226247 .collect (Collectors .toList ());
0 commit comments