mirror of
https://github.com/TeamNewPipe/NewPipeExtractor
synced 2025-08-22 09:57:38 +00:00
Added support for importing Soundcloud likes.
This commit is contained in:
parent
8b9ccec936
commit
44882b393c
@ -8,7 +8,7 @@ allprojects {
|
||||
sourceCompatibility = JavaVersion.VERSION_11
|
||||
targetCompatibility = JavaVersion.VERSION_11
|
||||
|
||||
version 'v0.24.6'
|
||||
version 'v0.24.7'
|
||||
group 'com.github.TeamNewPipe'
|
||||
|
||||
repositories {
|
||||
|
@ -11,6 +11,7 @@ public final class ChannelTabs {
|
||||
public static final String CHANNELS = "channels";
|
||||
public static final String PLAYLISTS = "playlists";
|
||||
public static final String ALBUMS = "albums";
|
||||
public static final String LIKES = "likes";
|
||||
|
||||
private ChannelTabs() {
|
||||
}
|
||||
|
@ -25,6 +25,7 @@ import org.schabi.newpipe.extractor.exceptions.ParsingException;
|
||||
import org.schabi.newpipe.extractor.exceptions.ReCaptchaException;
|
||||
import org.schabi.newpipe.extractor.services.soundcloud.extractors.SoundcloudChannelInfoItemExtractor;
|
||||
import org.schabi.newpipe.extractor.services.soundcloud.extractors.SoundcloudPlaylistInfoItemExtractor;
|
||||
import org.schabi.newpipe.extractor.services.soundcloud.extractors.SoundcloudLikesInfoItemExtractor;
|
||||
import org.schabi.newpipe.extractor.services.soundcloud.extractors.SoundcloudStreamInfoItemExtractor;
|
||||
import org.schabi.newpipe.extractor.stream.StreamInfoItemsCollector;
|
||||
import org.schabi.newpipe.extractor.utils.ImageSuffix;
|
||||
@ -396,6 +397,9 @@ public final class SoundcloudParsingHelper {
|
||||
case "playlist":
|
||||
collector.commit(new SoundcloudPlaylistInfoItemExtractor(searchResult));
|
||||
break;
|
||||
case "like":
|
||||
collector.commit(new SoundcloudLikesInfoItemExtractor(searchResult));
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -123,6 +123,8 @@ public class SoundcloudChannelExtractor extends ChannelExtractor {
|
||||
+ SoundcloudChannelTabLinkHandlerFactory.getUrlSuffix(ChannelTabs.PLAYLISTS);
|
||||
final String urlAlbums = url
|
||||
+ SoundcloudChannelTabLinkHandlerFactory.getUrlSuffix(ChannelTabs.ALBUMS);
|
||||
final String urlLikes = url
|
||||
+ SoundcloudChannelTabLinkHandlerFactory.getUrlSuffix(ChannelTabs.LIKES);
|
||||
final String id = getId();
|
||||
|
||||
return List.of(
|
||||
@ -131,6 +133,8 @@ public class SoundcloudChannelExtractor extends ChannelExtractor {
|
||||
new ListLinkHandler(urlPlaylists, urlPlaylists, id,
|
||||
List.of(ChannelTabs.PLAYLISTS), ""),
|
||||
new ListLinkHandler(urlAlbums, urlAlbums, id,
|
||||
List.of(ChannelTabs.ALBUMS), ""));
|
||||
List.of(ChannelTabs.ALBUMS), ""),
|
||||
new ListLinkHandler(urlLikes, urlLikes, id,
|
||||
List.of(ChannelTabs.LIKES), ""));
|
||||
}
|
||||
}
|
||||
|
@ -39,6 +39,8 @@ public class SoundcloudChannelTabExtractor extends ChannelTabExtractor {
|
||||
return "/playlists_without_albums";
|
||||
case ChannelTabs.ALBUMS:
|
||||
return "/albums";
|
||||
case ChannelTabs.LIKES:
|
||||
return "/likes";
|
||||
}
|
||||
throw new ParsingException("Unsupported tab: " + getName());
|
||||
}
|
||||
|
@ -0,0 +1,11 @@
|
||||
package org.schabi.newpipe.extractor.services.soundcloud.extractors;
|
||||
|
||||
import com.grack.nanojson.JsonObject;
|
||||
|
||||
public class SoundcloudLikesInfoItemExtractor extends SoundcloudStreamInfoItemExtractor {
|
||||
|
||||
public SoundcloudLikesInfoItemExtractor(final JsonObject itemObject) {
|
||||
super(itemObject.getObject("track"));
|
||||
}
|
||||
|
||||
}
|
@ -28,6 +28,8 @@ public final class SoundcloudChannelTabLinkHandlerFactory extends ListLinkHandle
|
||||
return "/sets";
|
||||
case ChannelTabs.ALBUMS:
|
||||
return "/albums";
|
||||
case ChannelTabs.LIKES:
|
||||
return "/likes";
|
||||
}
|
||||
throw new UnsupportedTabException(tab);
|
||||
}
|
||||
@ -56,6 +58,7 @@ public final class SoundcloudChannelTabLinkHandlerFactory extends ListLinkHandle
|
||||
ChannelTabs.TRACKS,
|
||||
ChannelTabs.PLAYLISTS,
|
||||
ChannelTabs.ALBUMS,
|
||||
ChannelTabs.LIKES,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -99,7 +99,7 @@ public class SoundcloudChannelExtractorTest {
|
||||
@Override
|
||||
public void testTabs() throws Exception {
|
||||
assertTabsContain(extractor.getTabs(), ChannelTabs.TRACKS, ChannelTabs.PLAYLISTS,
|
||||
ChannelTabs.ALBUMS);
|
||||
ChannelTabs.ALBUMS, ChannelTabs.LIKES);
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -187,7 +187,7 @@ public class SoundcloudChannelExtractorTest {
|
||||
@Override
|
||||
public void testTabs() throws Exception {
|
||||
assertTabsContain(extractor.getTabs(), ChannelTabs.TRACKS, ChannelTabs.PLAYLISTS,
|
||||
ChannelTabs.ALBUMS);
|
||||
ChannelTabs.ALBUMS, ChannelTabs.LIKES);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -94,4 +94,32 @@ class SoundcloudChannelTabExtractorTest {
|
||||
@Override public InfoItem.InfoType expectedInfoItemType() { return InfoItem.InfoType.PLAYLIST; }
|
||||
@Override public boolean expectedHasMoreItems() { return true; }
|
||||
}
|
||||
|
||||
static class Likes extends DefaultListExtractorTest<ChannelTabExtractor> {
|
||||
private static SoundcloudChannelTabExtractor extractor;
|
||||
|
||||
@BeforeAll
|
||||
static void setUp() throws IOException, ExtractionException {
|
||||
NewPipe.init(DownloaderTestImpl.getInstance());
|
||||
extractor = (SoundcloudChannelTabExtractor) SoundCloud
|
||||
.getChannelTabExtractorFromId("30854092", 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 "30854092"; }
|
||||
@Override public String expectedUrlContains() throws Exception { return "https://soundcloud.com/lubenitza/likes"; }
|
||||
@Override public String expectedOriginalUrlContains() throws Exception { return "https://soundcloud.com/lubenitza/likes"; }
|
||||
@Override public InfoItem.InfoType expectedInfoItemType() { return InfoItem.InfoType.STREAM; }
|
||||
@Override public boolean expectedHasMoreItems() { return true; }
|
||||
|
||||
@Test
|
||||
void testGetPageInNewExtractor() throws Exception {
|
||||
final ChannelTabExtractor newTabExtractor =
|
||||
SoundCloud.getChannelTabExtractorFromId("30854092", ChannelTabs.LIKES);
|
||||
defaultTestGetPageInNewExtractor(extractor, newTabExtractor);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user