-
-
Notifications
You must be signed in to change notification settings - Fork 3.4k
[SoundCloud] Fix soundcloud regression of expiring HLS streams after 5mins (APK DL in description) #12418
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
absurdlylongusername
wants to merge
11
commits into
TeamNewPipe:dev
Choose a base branch
from
absurdlylongusername:fix-soundcloud-hls-expiry
base: dev
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+537
−52
Open
[SoundCloud] Fix soundcloud regression of expiring HLS streams after 5mins (APK DL in description) #12418
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
af75521
ListHelper.getFilteredAudioStreams short circuit on empty list
absurdlylongusername 53057d9
Allow comment suppression in checkstyle.xml
absurdlylongusername cfaa55d
Bump exoplayer to latest version 2.19.1
absurdlylongusername b9c5a79
Setup ExtractorLogger in MainActivity
absurdlylongusername 3e3aa9e
Add LoggingHttpDataSource to log http requests sent by ExoPlayer for …
absurdlylongusername c2bdead
[SoundCloud] Refactor Soundcloud audio stream extraction code to sepa…
absurdlylongusername 3df38da
Add DEBUG guards for logging
absurdlylongusername a8bc331
settings.gradle use correct module path for includeBuild
absurdlylongusername 98b47aa
Use extractor from commit
absurdlylongusername 552c1b0
Rename baseUrl to removeQueryParameters
absurdlylongusername 6850a27
Merge branch 'dev' into fix-soundcloud-hls-expiry
absurdlylongusername File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
124 changes: 124 additions & 0 deletions
124
app/src/main/java/org/schabi/newpipe/player/datasource/LoggingHttpDataSource.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,124 @@ | ||
| package org.schabi.newpipe.player.datasource; | ||
|
|
||
| import static org.schabi.newpipe.MainActivity.DEBUG; | ||
|
|
||
| import android.util.Log; | ||
|
|
||
| import androidx.annotation.NonNull; | ||
| import androidx.annotation.Nullable; | ||
|
|
||
| import com.google.android.exoplayer2.upstream.DataSpec; | ||
| import com.google.android.exoplayer2.upstream.DefaultHttpDataSource; | ||
| import com.google.android.exoplayer2.upstream.HttpDataSource; | ||
| import com.google.android.exoplayer2.upstream.TransferListener; | ||
|
|
||
| import org.schabi.newpipe.DownloaderImpl; | ||
|
|
||
| import java.nio.charset.StandardCharsets; | ||
| import java.util.Map; | ||
|
|
||
| public class LoggingHttpDataSource extends DefaultHttpDataSource { | ||
|
|
||
| public final String TAG = getClass().getSimpleName() + "@" + hashCode(); | ||
|
|
||
| public LoggingHttpDataSource() { } | ||
|
|
||
| public LoggingHttpDataSource(@Nullable final String userAgent, | ||
| final int connectTimeoutMillis, | ||
| final int readTimeoutMillis, | ||
| final boolean allowCrossProtocolRedirects, | ||
| @Nullable final RequestProperties defaultRequestProperties) { | ||
| super(userAgent, | ||
| connectTimeoutMillis, | ||
| readTimeoutMillis, | ||
| allowCrossProtocolRedirects, | ||
| defaultRequestProperties); | ||
| } | ||
|
|
||
|
|
||
| @Override | ||
| public long open(final DataSpec dataSpec) throws HttpDataSourceException { | ||
| if (!DEBUG) { | ||
| return super.open(dataSpec); | ||
| } | ||
|
|
||
| Log.d(TAG, "Request URL: " + dataSpec.uri); | ||
| try { | ||
| return super.open(dataSpec); | ||
| } catch (final HttpDataSource.InvalidResponseCodeException e) { | ||
| Log.e(TAG, "HTTP error for URL: " + dataSpec.uri); | ||
| Log.e(TAG, "Response code: " + e.responseCode); | ||
| Log.e(TAG, "Headers: " + e.headerFields); | ||
| Log.e(TAG, "Body: " + new String(e.responseBody, StandardCharsets.UTF_8)); | ||
| throw e; | ||
| } | ||
| } | ||
|
|
||
| @SuppressWarnings("checkstyle:hiddenField") | ||
| public static class Factory implements HttpDataSource.Factory { | ||
|
|
||
| final RequestProperties defaultRequestProperties; | ||
|
|
||
| @Nullable | ||
| TransferListener transferListener; | ||
| @Nullable | ||
| String userAgent; | ||
| int connectTimeoutMs; | ||
| int readTimeoutMs; | ||
| boolean allowCrossProtocolRedirects; | ||
|
|
||
| public Factory() { | ||
| defaultRequestProperties = new RequestProperties(); | ||
| connectTimeoutMs = DEFAULT_CONNECT_TIMEOUT_MILLIS; | ||
| readTimeoutMs = DEFAULT_READ_TIMEOUT_MILLIS; | ||
| userAgent = DownloaderImpl.USER_AGENT; | ||
| } | ||
|
|
||
| @NonNull | ||
| @Override | ||
| public HttpDataSource createDataSource() { | ||
| final var dataSource = new LoggingHttpDataSource(userAgent, | ||
| connectTimeoutMs, | ||
| readTimeoutMs, | ||
| allowCrossProtocolRedirects, | ||
| defaultRequestProperties); | ||
| if (transferListener != null) { | ||
| dataSource.addTransferListener(transferListener); | ||
| } | ||
| return dataSource; | ||
| } | ||
|
|
||
| @NonNull | ||
| @Override | ||
| public Factory setDefaultRequestProperties( | ||
| @NonNull final Map<String, String> defaultRequestProperties) { | ||
| this.defaultRequestProperties.clearAndSet(defaultRequestProperties); | ||
| return this; | ||
| } | ||
|
|
||
| public Factory setUserAgent(@Nullable final String userAgent) { | ||
| this.userAgent = userAgent; | ||
| return this; | ||
| } | ||
|
|
||
| public Factory setConnectTimeoutMs(final int connectTimeoutMs) { | ||
| this.connectTimeoutMs = connectTimeoutMs; | ||
| return this; | ||
| } | ||
|
|
||
| public Factory setReadTimeoutMs(final int readTimeoutMs) { | ||
| this.readTimeoutMs = readTimeoutMs; | ||
| return this; | ||
| } | ||
|
|
||
| public Factory setAllowCrossProtocolRedirects(final boolean allowCrossProtocolRedirects) { | ||
| this.allowCrossProtocolRedirects = allowCrossProtocolRedirects; | ||
| return this; | ||
| } | ||
|
|
||
| public Factory setTransferListener(@Nullable final TransferListener transferListener) { | ||
| this.transferListener = transferListener; | ||
| return this; | ||
| } | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add JDoc here to highlight that data is only logged when DEBUG is true.