Skip to content

Conversation

absurdlylongusername
Copy link
Member

@absurdlylongusername absurdlylongusername commented Jul 8, 2025

  • I carefully read the contribution guidelines and agree to them.
  • I have tested the API against NewPipe.
  • I agree to create a pull request for NewPipe as soon as possible to make it compatible with the changed API.

Fix SoundCloud HLS stream urls expiring

This PR implements extractor side changes to facilitate refreshing expires HLS stream URLs for SoundCloud streams.

Add Extractor Logging

Added extractor logging, which helped a lot to fix this issue.

In a future PR I will add a proper logging framework that will only print logs if running in debug mode, but for now since the logs are not in high-traffic code then it should be fine.

Please Note

Includes changes from:

So those PRs must be merged before this.

See TeamNewPipe/NewPipe#12418 for the full writeup for the fix

@absurdlylongusername absurdlylongusername changed the title [SoundCloud] Fix soundcloud hls expiry and add extractor logging [SoundCloud] Fix SoundCloud HLS expiry and add extractor logging Jul 8, 2025
@ShareASmile ShareASmile added bug Issue is related to a bug soundcloud service, https://soundcloud.com/ labels Jul 8, 2025
@Stypox Stypox force-pushed the fix-soundcloud-hls-expiry branch from 45df3cd to 578f4f0 Compare October 2, 2025 12:58
logger.error(tag, msg, t);
}

// default logger that prints to stdout
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// default logger that prints to stdout
/**
* Default logger that prints to stdout.
*/

Copy link
Member

@Stypox Stypox left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you! My review gives some thoughts that we should decide on before continuing. There definitely needs to be a way to refresh streams in the extractor, which will come in handy not only for SoundCloud but also for YouTube.

I think it is a good idea to store refresh information in the streams themselves, and to make them expose methods that allow refreshing the stream. I guess this would also play well with #858 (comment). What do you think @AudricV?

Regarding logging, if I understand correctly the commit structure, it should be possible to extract it in a separate PR, that we can merge much faster. Could you put the logging in a separate PR? Also the

Comment on lines +13 to +19
public static void d(final String tag, final String msg) {
logger.debug(tag, msg);
}

public static void w(final String tag, final String msg) {
logger.warn(tag, msg);
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These should also optionally take a Throwable (that's how they work in Android, and it's often useful)

Comment on lines +8 to +9
@SuppressWarnings("checkstyle:LeftCurly")
public interface RefreshableStream {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
@SuppressWarnings("checkstyle:LeftCurly")
public interface RefreshableStream {
public interface RefreshableStream {

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this file used anywhere? Also, the reason why services are not implemented as an enum is also because it should be possible to dynamically add service implementations (think e.g. of plugins). Obviously this has never happened yet, but iirc that's why the API is like that.

}

// default logger that prints to stdout
private static final class ConsoleLogger implements Logger {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be only set by users of the library and should default to a logger that logs nothing. In each extractor test then you would set this ConsoleLogger as the logger (i.e. you just add this in the common tests initialization methods).


import javax.annotation.Nonnull;

public class HlsAudioStream extends AudioStream implements RefreshableStream {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think it's a property of all HLS streams that they are refreshable. I think we have two alternative ways we can handle this instead:

  • RefreshableStream could just be an interface that some Streams can implement, then each Service would override VideoStream/AudioStream and also implement RefreshableStream if needed, and the player could check for refreshable streams using instanceof. This would require a lot of boilerplate though.
  • Add a (Audio/Video)Stream refresh() {} method to the base Stream class which builds a new refreshed stream, and make it return null if refreshing is not available.

import java.io.IOException;

@SuppressWarnings("checkstyle:LeftCurly")
public interface RefreshableStream {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this also somehow store the expiry time? So that the player can prepare in advance if the stream is about to expire

*
* @return the resolved id
*/
// TODO: what makes this method different from the others? Don' they all return the same?
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe you can get an answer by git blaming?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issue is related to a bug soundcloud service, https://soundcloud.com/
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants