diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudParsingHelper.java b/extractor/src/main/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudParsingHelper.java index a03501b51..60c1e3f1e 100644 --- a/extractor/src/main/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudParsingHelper.java +++ b/extractor/src/main/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudParsingHelper.java @@ -398,7 +398,15 @@ public final class SoundcloudParsingHelper { collector.commit(new SoundcloudPlaylistInfoItemExtractor(searchResult)); break; case "like": - collector.commit(new SoundcloudLikesInfoItemExtractor(searchResult)); + // Soundcloud users can like tracks or playlists and all end up in the + // `Likes` feed, so they should be handled by the correct extractor. + final JsonObject likedPlaylist = + searchResult.getObject("playlist", null); + collector.commit( + null == likedPlaylist + ? new SoundcloudLikesInfoItemExtractor(searchResult) + : new SoundcloudPlaylistInfoItemExtractor(likedPlaylist) + ); break; } }); diff --git a/extractor/src/test/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudChannelTabExtractorTest.java b/extractor/src/test/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudChannelTabExtractorTest.java index 1c4f86f8c..495545cd6 100644 --- a/extractor/src/test/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudChannelTabExtractorTest.java +++ b/extractor/src/test/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudChannelTabExtractorTest.java @@ -9,19 +9,14 @@ import org.schabi.newpipe.extractor.StreamingService; import org.schabi.newpipe.extractor.channel.tabs.ChannelTabExtractor; import org.schabi.newpipe.extractor.channel.tabs.ChannelTabs; import org.schabi.newpipe.extractor.exceptions.ExtractionException; -import org.schabi.newpipe.extractor.exceptions.ParsingException; -import org.schabi.newpipe.extractor.services.BaseListExtractorTest; import org.schabi.newpipe.extractor.services.DefaultListExtractorTest; import org.schabi.newpipe.extractor.services.soundcloud.extractors.SoundcloudChannelTabExtractor; import java.io.IOException; import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.schabi.newpipe.extractor.ServiceList.PeerTube; import static org.schabi.newpipe.extractor.ServiceList.SoundCloud; import static org.schabi.newpipe.extractor.services.DefaultTests.defaultTestGetPageInNewExtractor; -import static org.schabi.newpipe.extractor.services.DefaultTests.defaultTestMoreItems; -import static org.schabi.newpipe.extractor.services.DefaultTests.defaultTestRelatedItems; class SoundcloudChannelTabExtractorTest { @@ -95,7 +90,7 @@ class SoundcloudChannelTabExtractorTest { @Override public boolean expectedHasMoreItems() { return true; } } - static class Likes extends DefaultListExtractorTest { + static class LikesOnlyTracks extends DefaultListExtractorTest { private static SoundcloudChannelTabExtractor extractor; @BeforeAll @@ -122,4 +117,32 @@ class SoundcloudChannelTabExtractorTest { defaultTestGetPageInNewExtractor(extractor, newTabExtractor); } } + + static class LikesOnlyPlaylists extends DefaultListExtractorTest { + private static SoundcloudChannelTabExtractor extractor; + + @BeforeAll + static void setUp() throws IOException, ExtractionException { + NewPipe.init(DownloaderTestImpl.getInstance()); + extractor = (SoundcloudChannelTabExtractor) SoundCloud + .getChannelTabExtractorFromId("1280839267", ChannelTabs.LIKES); + extractor.fetchPage(); + } + + @Override public ChannelTabExtractor extractor() throws Exception { return extractor; } + @Override public StreamingService expectedService() throws Exception { return SoundCloud; } + @Override public String expectedName() throws Exception { return ChannelTabs.LIKES; } + @Override public String expectedId() throws Exception { return "1280839267"; } + @Override public String expectedUrlContains() throws Exception { return "https://soundcloud.com/soreen-735855039/likes"; } + @Override public String expectedOriginalUrlContains() throws Exception { return "https://soundcloud.com/soreen-735855039/likes"; } + @Override public InfoItem.InfoType expectedInfoItemType() { return InfoItem.InfoType.PLAYLIST; } + @Override public boolean expectedHasMoreItems() { return true; } + + @Test + void testGetPageInNewExtractor() throws Exception { + final ChannelTabExtractor newTabExtractor = + SoundCloud.getChannelTabExtractorFromId("1280839267", ChannelTabs.LIKES); + defaultTestGetPageInNewExtractor(extractor, newTabExtractor); + } + } }