Skip to content

Commit 210834f

Browse files
committed
Add support of other delivery methods than progressive HTTP (in the player only)
Detailed changes: - External players: - Add a message instruction about stream selection; - Add a message when there is no stream available for external players; - Return now HLS, DASH and SmoothStreaming URL contents, in addition to progressive HTTP ones. - Player: - Support DASH, HLS and SmoothStreaming streams for videos, whether they are content URLs or the manifests themselves, in addition to progressive HTTP ones; - Use a custom HttpDataSource to play YouTube contents, based of ExoPlayer's default one, which allows better spoofing of official clients (custom user-agent and headers (depending of the client used), use of range and rn (set dynamically by the DataSource) parameters); - Fetch YouTube progressive contents as DASH streams, like official clients, support fully playback of livestreams which have ended recently and OTF streams; - Use ExoPlayer's default retries count for contents on non-fatal errors (instead of Integer.MAX_VALUE for non-live contents and 5 for live contents). - Download dialog: - Add message about support of progressive HTTP streams only for downloading; - Remove several duplicated code and update relevant usages; - Support downloading of contents with an unknown media format. - ListHelper: - Catch NumberFormatException when trying to compare two video streams between them. - Tests: - Update ListHelperTest and StreamItemAdapterTest to fix breaking changes in the extractor. - Other places: - Fixes deprecation of changes made in the extractor; - Improve some code related to the files changed. - Issues fixed and/or improved with the changes: - Seeking of PeerTube HLS streams (the duration shown was the one from the stream duration and not the one parsed, incomplete because HLS streams are fragmented MP4s with multiple sidx boxes, for which seeking is not supported by ExoPlayer) (the app now uses the HLS manifest returned for each quality, in the master playlist (not fetched and computed by the extractor)); - Crash when loading PeerTube streams with a separated audio; - Lack of some streams on some YouTube videos (OTF streams); - Loading times of YouTube streams, after a quality change or a playback start; - View count of YouTube ended livestreams interpreted as watching count (this type of streams is not interpreted anymore as livestreams); - Watchable time of YouTube ended livestreams; - Playback of SoundCloud HLS-only tracks (which cannot be downloaded anymore because the workaround which was used is being removed by SoundCloud, so it has been removed from the extractor).
1 parent a59660f commit 210834f

27 files changed

Lines changed: 2411 additions & 533 deletions

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: 5 additions & 13 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;
@@ -677,22 +676,15 @@ private void openDownloadDialog() {
677676
.subscribeOn(Schedulers.io())
678677
.observeOn(AndroidSchedulers.mainThread())
679678
.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);
679+
final DownloadDialog downloadDialog = DownloadDialog.newInstance(this, result);
680+
downloadDialog.setSelectedVideoStream(ListHelper.getDefaultResolutionIndex(
681+
this, downloadDialog.wrappedVideoStreams.getStreamsList()));
682+
downloadDialog.setOnDismissListener(dialog -> finish());
685683

686684
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());
692685
downloadDialog.show(fm, "downloadDialog");
693686
fm.executePendingTransactions();
694-
}, throwable ->
695-
showUnsupportedUrlDialog(currentUrl)));
687+
}, throwable -> showUnsupportedUrlDialog(currentUrl)));
696688
}
697689

698690
@Override

0 commit comments

Comments
 (0)