-
Notifications
You must be signed in to change notification settings - Fork 425
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
Fix parsing Soundcloud tracks that contain the term 'sets' #410
Conversation
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.
This is OK-ish, to ideally we would parse it through URL
.
Edit: I think the !url.endsWith("sets")
isn't needed anymore then though.
I could look into altering the solution to use this method when I wake up in the morning. I'm unfamiliar with the larger scale of the codebase, so I just kept it to it's current behaviour. Should not be a hassle to change |
Feels a bit strange jumping between two issues, but if we were under the task that the tailing slash were to be removed, a simple check for the existence of the term |
@@ -153,7 +153,7 @@ public static String resolveIdWithEmbedPlayer(String url) throws IOException, Re | |||
String response = NewPipe.getDownloader().get("https://w.soundcloud.com/player/?url=" | |||
+ URLEncoder.encode(url, "UTF-8"), SoundCloud.getLocalization()).responseBody(); | |||
// handle playlists / sets different and get playlist id via uir field in JSON | |||
if (url.contains("sets") && !url.endsWith("sets") && !url.endsWith("sets/")) | |||
if (url.contains("/sets/") && !url.endsWith("sets") && !url.endsWith("sets/")) |
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.
Actually I think I was wrong above and that this should be changed to url.contains("/sets/") && !url.endsWith("/sets") && !url.endsWith("/sets/")
so that it only doesn't get soundcloud.com/artist/sets URLs, while e.g. soundcloud.com/artist/track-ending-with-sets still works.
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.
so that it only doesn't get soundcloud.com/artist/sets
Yeah, this seems to be working, but it will still error out on a widget-related issue, similar to that of #412 (comment) in where it lacks data. Otherwise it seems to be detecting it as a channel type request just fine
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.
With changes in f803558, as URLs need to have their tailing slash removed, it is now impossible for a URL to end in sets/. However I am having a decent struggle determining if ending with sets
should be checked if /sets/
is our primary check. This has genuinely caused quite a headache. I have left it in there for safety reasons, but if you think that this would be adequate to be removed, then it shall not be a hassle
313720f
to
ba8eaaf
Compare
I have made changes based on #410 (review) to parse the URL as a Java URL and return a malformed URL exception as per actions used elsewhere in the application |
ba8eaaf
to
f803558
Compare
Much like changes made in #414, these also need to apply to elements related to this PR which I caught when returning back to this issue. With some extra time I would hopefully be able to test this on a greater scale within the extractor, but this is already getting a bit exhausting. |
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.
Thank you! Is this ready?
@@ -21,6 +21,8 @@ public static SoundcloudChannelLinkHandlerFactory getInstance() { | |||
@Override | |||
public String getId(String url) throws ParsingException { | |||
Utils.checkUrl(URL_PATTERN, url); | |||
// Remove the tailing slash from URLs due to issues with the SoundCloud API | |||
if (url.charAt(url.length() -1) == '/') url = url.substring(0, url.length()-1); |
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.
Why not moving this inside resolveIdWithEmbedPlayer
?
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.
I think I was just mimicking what I did in 6a70cb9
but I think I can move everything to that instead
I don't really remember my branches that well anymore, but I think I got it
f803558
to
687d321
Compare
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.
Could you add some tests for this in soundcloud link handler tests?
687d321
to
56a6b7c
Compare
Testing of adding a slash to the end of the url Line 56 in 56a6b7c
Tests for sets in the track url, this also benefits from not relying on some other artist as a source Line 64 in 56a6b7c
|
Wait, that's not going to test the sets URL correctly at all, I remembered why that URL parses, but it only does so since the parameters are dropped, I think I'm going to need another artist source for that one |
Would the sample used in the OP be acceptable for the repo? I couldn't find anything suitable on users such as |
https://soundcloud.com/kechuspider-sets-1 |
56a6b7c
to
947ce3e
Compare
Thanks, 947ce3e should be final |
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.
Thank you! Looks good
In the current builds of newpipe, if a track contained the term sets in their url, regardless of position, it would be treated as a playlist, causing a ParsingException.
On the assumption that all sets on the soundcloud URL scheme that playlist sets are always within slashes, this should provide an adequate solution
Before the change, the following Exception would be displayed
Exception
Crash log
and now the given URL is parsed correctly