@@ -59,10 +59,23 @@ public static class ParserResult {
5959 private final List <AudioStream > audioStreams ;
6060 private final List <VideoStream > videoOnlyStreams ;
6161
62- public ParserResult (List <VideoStream > videoStreams , List <AudioStream > audioStreams , List <VideoStream > videoOnlyStreams ) {
62+ private final List <VideoStream > segmentedVideoStreams ;
63+ private final List <AudioStream > segmentedAudioStreams ;
64+ private final List <VideoStream > segmentedVideoOnlyStreams ;
65+
66+
67+ public ParserResult (List <VideoStream > videoStreams ,
68+ List <AudioStream > audioStreams ,
69+ List <VideoStream > videoOnlyStreams ,
70+ List <VideoStream > segmentedVideoStreams ,
71+ List <AudioStream > segmentedAudioStreams ,
72+ List <VideoStream > segmentedVideoOnlyStreams ) {
6373 this .videoStreams = videoStreams ;
6474 this .audioStreams = audioStreams ;
6575 this .videoOnlyStreams = videoOnlyStreams ;
76+ this .segmentedVideoStreams = segmentedVideoStreams ;
77+ this .segmentedAudioStreams = segmentedAudioStreams ;
78+ this .segmentedVideoOnlyStreams = segmentedVideoOnlyStreams ;
6679 }
6780
6881 public List <VideoStream > getVideoStreams () {
@@ -76,10 +89,22 @@ public List<AudioStream> getAudioStreams() {
7689 public List <VideoStream > getVideoOnlyStreams () {
7790 return videoOnlyStreams ;
7891 }
92+
93+ public List <VideoStream > getSegmentedVideoStreams () {
94+ return segmentedVideoStreams ;
95+ }
96+
97+ public List <AudioStream > getSegmentedAudioStreams () {
98+ return segmentedAudioStreams ;
99+ }
100+
101+ public List <VideoStream > getSegmentedVideoOnlyStreams () {
102+ return segmentedVideoOnlyStreams ;
103+ }
79104 }
80105
81106 /**
82- * Will try to download (using {@link StreamInfo#dashMpdUrl }) and parse the dash manifest,
107+ * Will try to download (using {@link StreamInfo#getDashMpdUrl() }) and parse the dash manifest,
83108 * then it will search for any stream that the ItagItem has (by the id).
84109 * <p>
85110 * It has video, video only and audio streams and will only add to the list if it don't
@@ -90,7 +115,8 @@ public List<VideoStream> getVideoOnlyStreams() {
90115 *
91116 * @param streamInfo where the parsed streams will be added
92117 */
93- public static ParserResult getStreams (final StreamInfo streamInfo ) throws DashMpdParsingException , ReCaptchaException {
118+ public static ParserResult getStreams (final StreamInfo streamInfo )
119+ throws DashMpdParsingException , ReCaptchaException {
94120 String dashDoc ;
95121 Downloader downloader = NewPipe .getDownloader ();
96122 try {
@@ -113,6 +139,10 @@ public static ParserResult getStreams(final StreamInfo streamInfo) throws DashMp
113139 final List <AudioStream > audioStreams = new ArrayList <>();
114140 final List <VideoStream > videoOnlyStreams = new ArrayList <>();
115141
142+ final List <VideoStream > segmentedVideoStreams = new ArrayList <>();
143+ final List <AudioStream > segmentedAudioStreams = new ArrayList <>();
144+ final List <VideoStream > segmentedVideoOnlyStreams = new ArrayList <>();
145+
116146 for (int i = 0 ; i < representationList .getLength (); i ++) {
117147 final Element representation = (Element ) representationList .item (i );
118148 try {
@@ -126,34 +156,61 @@ public static ParserResult getStreams(final StreamInfo streamInfo) throws DashMp
126156 // instead we need to add the "media=" value from the <SegementURL/> tags inside the <SegmentList/>
127157 // tag in order to get a full working url. However each of these is just pointing to a part of the
128158 // video, so we can not return a URL with a working stream here.
129- // We decided not to ignore such streams for the moment.
130- if (itag != null && segmentationList == null ) {
159+ // Instead of putting those streams into the list of regular stream urls wie put them in a
160+ // for example "segmentedVideoStreams" list.
161+ if (itag != null ) {
131162 final MediaFormat mediaFormat = MediaFormat .getFromMimeType (mimeType );
132163
133164 if (itag .itagType .equals (ItagItem .ItagType .AUDIO )) {
134- final AudioStream audioStream = new AudioStream (url , mediaFormat , itag .avgBitrate );
135-
136- if (!Stream .containSimilarStream (audioStream , streamInfo .getAudioStreams ())) {
137- audioStreams .add (audioStream );
165+ if (segmentationList == null ) {
166+ final AudioStream audioStream = new AudioStream (url , mediaFormat , itag .avgBitrate );
167+ if (!Stream .containSimilarStream (audioStream , streamInfo .getAudioStreams ())) {
168+ audioStreams .add (audioStream );
169+ }
170+ } else {
171+ segmentedAudioStreams .add (
172+ new AudioStream (id , mediaFormat , itag .avgBitrate ));
138173 }
139174 } else {
140175 boolean isVideoOnly = itag .itagType .equals (ItagItem .ItagType .VIDEO_ONLY );
141- final VideoStream videoStream = new VideoStream (url , mediaFormat , itag .resolutionString , isVideoOnly );
142176
143- if (isVideoOnly ) {
144- if (!Stream .containSimilarStream (videoStream , streamInfo .getVideoOnlyStreams ())) {
145- streamInfo .getVideoOnlyStreams ().add (videoStream );
146- videoOnlyStreams .add (videoStream );
177+ if (segmentationList == null ) {
178+ final VideoStream videoStream = new VideoStream (url ,
179+ mediaFormat ,
180+ itag .resolutionString ,
181+ isVideoOnly );
182+
183+ if (isVideoOnly ) {
184+ if (!Stream .containSimilarStream (videoStream , streamInfo .getVideoOnlyStreams ())) {
185+ videoOnlyStreams .add (videoStream );
186+ }
187+ } else if (!Stream .containSimilarStream (videoStream , streamInfo .getVideoStreams ())) {
188+ videoStreams .add (videoStream );
189+ }
190+ } else {
191+ final VideoStream videoStream = new VideoStream (id ,
192+ mediaFormat ,
193+ itag .resolutionString ,
194+ isVideoOnly );
195+
196+ if (isVideoOnly ) {
197+ segmentedVideoOnlyStreams .add (videoStream );
198+ } else {
199+ segmentedVideoStreams .add (videoStream );
147200 }
148- } else if (!Stream .containSimilarStream (videoStream , streamInfo .getVideoStreams ())) {
149- videoStreams .add (videoStream );
150201 }
151202 }
152203 }
153204 } catch (Exception ignored ) {
154205 }
155206 }
156- return new ParserResult (videoStreams , audioStreams , videoOnlyStreams );
207+ return new ParserResult (
208+ videoStreams ,
209+ audioStreams ,
210+ videoOnlyStreams ,
211+ segmentedVideoStreams ,
212+ segmentedAudioStreams ,
213+ segmentedVideoOnlyStreams );
157214 } catch (Exception e ) {
158215 throw new DashMpdParsingException ("Could not parse Dash mpd" , e );
159216 }
0 commit comments