Handle liked playlists using the `SoundcloudPlaylistInfoItemExtractor`

pull/1308/head
watermelon42 2025-07-08 18:44:51 +03:00
rodzic 964512741d
commit 5e1a1d51b6
2 zmienionych plików z 38 dodań i 7 usunięć

Wyświetl plik

@ -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;
}
});

Wyświetl plik

@ -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<ChannelTabExtractor> {
static class LikesOnlyTracks extends DefaultListExtractorTest<ChannelTabExtractor> {
private static SoundcloudChannelTabExtractor extractor;
@BeforeAll
@ -122,4 +117,32 @@ class SoundcloudChannelTabExtractorTest {
defaultTestGetPageInNewExtractor(extractor, newTabExtractor);
}
}
static class LikesOnlyPlaylists extends DefaultListExtractorTest<ChannelTabExtractor> {
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);
}
}
}