Skip to content

[SoundCloud] Do not call resolveUrlWithEmbedPlayer unless absolutely necessary #1337

@absurdlylongusername

Description

@absurdlylongusername

Checklist

  • I am aware that this issue is being opened for the NewPipe Extractor, NOT the app, and my feature request will be dismissed otherwise.
  • I made sure that there are no existing issues - open or closed - which I could contribute my information to.
  • I have taken the time to fill in all the required details. I understand that the feature request will be dismissed otherwise.
  • This issue contains only one feature request.
  • I have read and understood the contribution guidelines.

Feature description

In many of our extraction flows, we call SoundcloudParsingHelper#resolveUrlWithEmbedPlayer with the id we get from SoundcloudParsingHelper#resolveIdWithWidgetApi, however, the endpoint we call in resolveIdWithWidgetApi already returns the same url we retrieve from resolveUrlWithEmbedPlayer in the returned JSON from permalink_url, so this call seems to be redundant as far as I can see.

We should refactor the code so we don't make requests we don't need to make and use the data from the first resolve. Data returned from SoundCloud API generally is not transient, so we should really only need to make one call and it will have everything we need for that resource unless we delete the data locally.

In some places we use the id for a resource to get it's url via resolveUrlWithEmbedPlayer, and only the url, but I am pretty sure later on we make another web request to get data that is actually useful instead of just the url. I am 99.9999% certain that if we already have the id then we have everything we need to get all related data for the resource, so I am not entirely sure if resolveUrlWithEmbedPlayer is ever needed at all.

If we have the url for a resource (a track, or a channel) then we can use resolveIdWithWidgetApi to get everything we need, and if we have the id then we have just call the relevant api-v2 endpoint, e.g. https://api-v2.soundcloud.com/users/1235977309/tracks.

The only benefit that resolveUrlWithEmbedPlayer has is that it doesn't need a clientId, and it's response is very small; but nothing useful that we do with the extractor can be done without a clientId, so I am not sure if there's any useful use case where we can accomplish anything without a clientId.

Implementing this change would mean we are no longer making two web requests for extraction which would speed up extraction at least by 2x for SoundCloud related stuff.

This would require changes to the SoundCloud link handler factories and the SoundCloud extractors, and also possibly the base class link handler factories as well.

Why do you want this feature?

Code quality + efficiency

Additional information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    codequalityImprovements to the codebase to improve the code qualityenhancementNew feature or requestsoundcloudservice, https://soundcloud.com/

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions