Skip to content

Commit 3901ffc

Browse files
authored
Merge pull request #8153 from AudricV/delivery-methods-v2
Support delivery methods other than progressive HTTP
2 parents a59660f + cbd3308 commit 3901ffc

30 files changed

+2535
-630
lines changed

app/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ dependencies {
190190
// name and the commit hash with the commit hash of the (pushed) commit you want to test
191191
// This works thanks to JitPack: https://jitpack.io/
192192
implementation 'com.github.TeamNewPipe:nanojson:1d9e1aea9049fc9f85e68b43ba39fe7be1c1f751'
193-
implementation 'com.github.TeamNewPipe:NewPipeExtractor:ac1c22d81c65b7b0c5427f4e1989f5256d617f32'
193+
implementation 'com.github.TeamNewPipe:NewPipeExtractor:1b51eab664ec7cbd2295c96d8b43000379cd1b7b'
194194

195195
/** Checkstyle **/
196196
checkstyle "com.puppycrawl.tools:checkstyle:${checkstyleVersion}"

app/src/androidTest/java/org/schabi/newpipe/util/StreamItemAdapterTest.kt

Lines changed: 31 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,12 @@ class StreamItemAdapterTest {
9191
context,
9292
StreamItemAdapter.StreamSizeWrapper(
9393
(0 until 5).map {
94-
SubtitlesStream(MediaFormat.SRT, "pt-BR", "https://example.com", false)
94+
SubtitlesStream.Builder()
95+
.setContent("https://example.com", true)
96+
.setMediaFormat(MediaFormat.SRT)
97+
.setLanguageCode("pt-BR")
98+
.setAutoGenerated(false)
99+
.build()
95100
},
96101
context
97102
),
@@ -108,7 +113,14 @@ class StreamItemAdapterTest {
108113
val adapter = StreamItemAdapter<AudioStream, Stream>(
109114
context,
110115
StreamItemAdapter.StreamSizeWrapper(
111-
(0 until 5).map { AudioStream("https://example.com/$it", MediaFormat.OPUS, 192) },
116+
(0 until 5).map {
117+
AudioStream.Builder()
118+
.setId(Stream.ID_UNKNOWN)
119+
.setContent("https://example.com/$it", true)
120+
.setMediaFormat(MediaFormat.OPUS)
121+
.setAverageBitrate(192)
122+
.build()
123+
},
112124
context
113125
),
114126
null
@@ -126,7 +138,13 @@ class StreamItemAdapterTest {
126138
private fun getVideoStreams(vararg videoOnly: Boolean) =
127139
StreamItemAdapter.StreamSizeWrapper(
128140
videoOnly.map {
129-
VideoStream("https://example.com", MediaFormat.MPEG_4, "720p", it)
141+
VideoStream.Builder()
142+
.setId(Stream.ID_UNKNOWN)
143+
.setContent("https://example.com", true)
144+
.setMediaFormat(MediaFormat.MPEG_4)
145+
.setResolution("720p")
146+
.setIsVideoOnly(it)
147+
.build()
130148
},
131149
context
132150
)
@@ -138,8 +156,16 @@ class StreamItemAdapterTest {
138156
private fun getAudioStreams(vararg shouldBeValid: Boolean) =
139157
getSecondaryStreamsFromList(
140158
shouldBeValid.map {
141-
if (it) AudioStream("https://example.com", MediaFormat.OPUS, 192)
142-
else null
159+
if (it) {
160+
AudioStream.Builder()
161+
.setId(Stream.ID_UNKNOWN)
162+
.setContent("https://example.com", true)
163+
.setMediaFormat(MediaFormat.OPUS)
164+
.setAverageBitrate(192)
165+
.build()
166+
} else {
167+
null
168+
}
143169
}
144170
)
145171

app/src/main/java/org/schabi/newpipe/RouterActivity.java

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@
5858
import org.schabi.newpipe.extractor.exceptions.YoutubeMusicPremiumContentException;
5959
import org.schabi.newpipe.extractor.playlist.PlaylistInfo;
6060
import org.schabi.newpipe.extractor.stream.StreamInfo;
61-
import org.schabi.newpipe.extractor.stream.VideoStream;
6261
import org.schabi.newpipe.ktx.ExceptionUtils;
6362
import org.schabi.newpipe.local.dialog.PlaylistDialog;
6463
import org.schabi.newpipe.player.MainPlayer;
@@ -71,7 +70,6 @@
7170
import org.schabi.newpipe.util.Constants;
7271
import org.schabi.newpipe.util.DeviceUtils;
7372
import org.schabi.newpipe.util.ExtractorHelper;
74-
import org.schabi.newpipe.util.ListHelper;
7573
import org.schabi.newpipe.util.Localization;
7674
import org.schabi.newpipe.util.NavigationHelper;
7775
import org.schabi.newpipe.util.PermissionHelper;
@@ -677,22 +675,13 @@ private void openDownloadDialog() {
677675
.subscribeOn(Schedulers.io())
678676
.observeOn(AndroidSchedulers.mainThread())
679677
.subscribe(result -> {
680-
final List<VideoStream> sortedVideoStreams = ListHelper
681-
.getSortedStreamVideosList(this, result.getVideoStreams(),
682-
result.getVideoOnlyStreams(), false, false);
683-
final int selectedVideoStreamIndex = ListHelper
684-
.getDefaultResolutionIndex(this, sortedVideoStreams);
678+
final DownloadDialog downloadDialog = new DownloadDialog(this, result);
679+
downloadDialog.setOnDismissListener(dialog -> finish());
685680

686681
final FragmentManager fm = getSupportFragmentManager();
687-
final DownloadDialog downloadDialog = DownloadDialog.newInstance(result);
688-
downloadDialog.setVideoStreams(sortedVideoStreams);
689-
downloadDialog.setAudioStreams(result.getAudioStreams());
690-
downloadDialog.setSelectedVideoStream(selectedVideoStreamIndex);
691-
downloadDialog.setOnDismissListener(dialog -> finish());
692682
downloadDialog.show(fm, "downloadDialog");
693683
fm.executePendingTransactions();
694-
}, throwable ->
695-
showUnsupportedUrlDialog(currentUrl)));
684+
}, throwable -> showUnsupportedUrlDialog(currentUrl)));
696685
}
697686

698687
@Override

app/src/main/java/org/schabi/newpipe/database/stream/dao/StreamDAO.kt

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@ import org.schabi.newpipe.database.BasicDAO
1212
import org.schabi.newpipe.database.stream.model.StreamEntity
1313
import org.schabi.newpipe.database.stream.model.StreamEntity.Companion.STREAM_ID
1414
import org.schabi.newpipe.extractor.stream.StreamType
15-
import org.schabi.newpipe.extractor.stream.StreamType.AUDIO_LIVE_STREAM
16-
import org.schabi.newpipe.extractor.stream.StreamType.LIVE_STREAM
15+
import org.schabi.newpipe.util.StreamTypeUtil
1716
import java.time.OffsetDateTime
1817

1918
@Dao
@@ -91,8 +90,7 @@ abstract class StreamDAO : BasicDAO<StreamEntity> {
9190
?: throw IllegalStateException("Stream cannot be null just after insertion.")
9291
newerStream.uid = existentMinimalStream.uid
9392

94-
val isNewerStreamLive = newerStream.streamType == AUDIO_LIVE_STREAM || newerStream.streamType == LIVE_STREAM
95-
if (!isNewerStreamLive) {
93+
if (!StreamTypeUtil.isLiveStream(newerStream.streamType)) {
9694

9795
// Use the existent upload date if the newer stream does not have a better precision
9896
// (i.e. is an approximation). This is done to prevent unnecessary changes.

0 commit comments

Comments
 (0)