Skip to content

Commit a043cbd

Browse files
committed
[SoundCloud]
1 parent f484f20 commit a043cbd

3 files changed

Lines changed: 24 additions & 30 deletions

File tree

extractor/src/main/java/org/schabi/newpipe/extractor/services/soundcloud/extractors/SoundcloudChannelExtractor.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -127,10 +127,10 @@ public List<ListLinkHandler> getTabs() throws ParsingException {
127127

128128
return List.of(
129129
new ListLinkHandler(urlTracks, urlTracks, id,
130-
List.of(ChannelTabs.TRACKS), ""),
130+
List.of(ChannelTabs.TRACKS), List.of()),
131131
new ListLinkHandler(urlPlaylists, urlPlaylists, id,
132-
List.of(ChannelTabs.PLAYLISTS), ""),
132+
List.of(ChannelTabs.PLAYLISTS), List.of()),
133133
new ListLinkHandler(urlAlbums, urlAlbums, id,
134-
List.of(ChannelTabs.ALBUMS), ""));
134+
List.of(ChannelTabs.ALBUMS), List.of()));
135135
}
136136
}

extractor/src/main/java/org/schabi/newpipe/extractor/services/soundcloud/extractors/SoundcloudChannelTabExtractor.java

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import org.schabi.newpipe.extractor.exceptions.ExtractionException;
1111
import org.schabi.newpipe.extractor.exceptions.ParsingException;
1212
import org.schabi.newpipe.extractor.linkhandler.ListLinkHandler;
13+
import org.schabi.newpipe.extractor.search.filter.FilterItem;
1314
import org.schabi.newpipe.extractor.services.soundcloud.SoundcloudParsingHelper;
1415

1516
import javax.annotation.Nonnull;
@@ -32,15 +33,15 @@ public SoundcloudChannelTabExtractor(final StreamingService service,
3233

3334
@Nonnull
3435
private String getEndpoint() throws ParsingException {
35-
switch (getName()) {
36-
case ChannelTabs.TRACKS:
37-
return "/tracks";
38-
case ChannelTabs.PLAYLISTS:
39-
return "/playlists_without_albums";
40-
case ChannelTabs.ALBUMS:
41-
return "/albums";
36+
final FilterItem type = getChannelTabType();
37+
if (type.equals(ChannelTabs.TRACKS)) {
38+
return "/tracks";
39+
} else if (type.equals(ChannelTabs.PLAYLISTS)) {
40+
return "/playlists_without_albums";
41+
} else if (type.equals(ChannelTabs.ALBUMS)) {
42+
return "/albums";
4243
}
43-
throw new ParsingException("Unsupported tab: " + getName());
44+
throw new ParsingException("Unsupported tab: " + type);
4445
}
4546

4647
@Override

extractor/src/main/java/org/schabi/newpipe/extractor/services/soundcloud/linkHandler/SoundcloudChannelTabLinkHandlerFactory.java

Lines changed: 12 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,11 @@
44
import org.schabi.newpipe.extractor.exceptions.ParsingException;
55
import org.schabi.newpipe.extractor.exceptions.UnsupportedTabException;
66
import org.schabi.newpipe.extractor.linkhandler.ListLinkHandlerFactory;
7+
import org.schabi.newpipe.extractor.search.filter.FilterItem;
78

89
import javax.annotation.Nonnull;
10+
import javax.annotation.Nullable;
11+
912
import java.util.List;
1013

1114
public final class SoundcloudChannelTabLinkHandlerFactory extends ListLinkHandlerFactory {
@@ -20,14 +23,13 @@ public static SoundcloudChannelTabLinkHandlerFactory getInstance() {
2023
}
2124

2225
@Nonnull
23-
public static String getUrlSuffix(final String tab) throws UnsupportedOperationException {
24-
switch (tab) {
25-
case ChannelTabs.TRACKS:
26-
return "/tracks";
27-
case ChannelTabs.PLAYLISTS:
28-
return "/sets";
29-
case ChannelTabs.ALBUMS:
30-
return "/albums";
26+
public static String getUrlSuffix(final FilterItem tab) throws UnsupportedOperationException {
27+
if (tab.equals(ChannelTabs.TRACKS)) {
28+
return "/tracks";
29+
} else if (tab.equals(ChannelTabs.PLAYLISTS)) {
30+
return "/sets";
31+
} else if (tab.equals(ChannelTabs.ALBUMS)) {
32+
return "/albums";
3133
}
3234
throw new UnsupportedTabException(tab);
3335
}
@@ -39,8 +41,8 @@ public String getId(final String url) throws ParsingException {
3941

4042
@Override
4143
public String getUrl(final String id,
42-
final List<String> contentFilter,
43-
final String sortFilter) throws ParsingException {
44+
@Nonnull final List<FilterItem> contentFilter,
45+
@Nullable final List<FilterItem> sortFilter) throws ParsingException {
4446
return SoundcloudChannelLinkHandlerFactory.getInstance().getUrl(id)
4547
+ getUrlSuffix(contentFilter.get(0));
4648
}
@@ -49,13 +51,4 @@ public String getUrl(final String id,
4951
public boolean onAcceptUrl(final String url) throws ParsingException {
5052
return SoundcloudChannelLinkHandlerFactory.getInstance().onAcceptUrl(url);
5153
}
52-
53-
@Override
54-
public String[] getAvailableContentFilter() {
55-
return new String[] {
56-
ChannelTabs.TRACKS,
57-
ChannelTabs.PLAYLISTS,
58-
ChannelTabs.ALBUMS,
59-
};
60-
}
6154
}

0 commit comments

Comments
 (0)