From 1eb3deb7fd89d60f6e36e016c0c30291a485fb21 Mon Sep 17 00:00:00 2001 From: bopol Date: Sun, 29 Mar 2020 11:13:39 +0200 Subject: [PATCH] add supported countries for soundcloud --- .../services/soundcloud/SoundcloudChartsExtractor.java | 10 +++++----- .../services/soundcloud/SoundcloudService.java | 10 ++++++++++ 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudChartsExtractor.java b/extractor/src/main/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudChartsExtractor.java index a08502d70..9a877faba 100644 --- a/extractor/src/main/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudChartsExtractor.java +++ b/extractor/src/main/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudChartsExtractor.java @@ -11,6 +11,8 @@ import org.schabi.newpipe.extractor.stream.StreamInfoItemsCollector; import javax.annotation.Nonnull; import java.io.IOException; +import static org.schabi.newpipe.extractor.ServiceList.SoundCloud; + public class SoundcloudChartsExtractor extends KioskExtractor { private StreamInfoItemsCollector collector = null; private String nextPageUrl = null; @@ -57,11 +59,9 @@ public class SoundcloudChartsExtractor extends KioskExtractor { apiUrl += "&kind=trending"; } - /*List supportedCountries = Arrays.asList("AU", "CA", "FR", "DE", "IE", "NL", "NZ", "GB", "US"); - String contentCountry = getContentCountry(); - if (supportedCountries.contains(contentCountry)) { - apiUrl += "®ion=soundcloud:regions:" + contentCountry; - }*/ + + String contentCountry = SoundCloud.getContentCountry().getCountryCode(); + apiUrl += "®ion=soundcloud:regions:" + contentCountry; nextPageUrl = SoundcloudParsingHelper.getStreamsFromApi(collector, apiUrl, true); } diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudService.java b/extractor/src/main/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudService.java index 30f2fc87c..1c2998791 100644 --- a/extractor/src/main/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudService.java +++ b/extractor/src/main/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudService.java @@ -7,11 +7,14 @@ import org.schabi.newpipe.extractor.exceptions.ExtractionException; import org.schabi.newpipe.extractor.kiosk.KioskExtractor; import org.schabi.newpipe.extractor.kiosk.KioskList; import org.schabi.newpipe.extractor.linkhandler.*; +import org.schabi.newpipe.extractor.localization.ContentCountry; import org.schabi.newpipe.extractor.playlist.PlaylistExtractor; import org.schabi.newpipe.extractor.search.SearchExtractor; import org.schabi.newpipe.extractor.stream.StreamExtractor; import org.schabi.newpipe.extractor.subscription.SubscriptionExtractor; +import java.util.List; + import static java.util.Collections.singletonList; import static org.schabi.newpipe.extractor.StreamingService.ServiceInfo.MediaCapability.AUDIO; @@ -46,6 +49,13 @@ public class SoundcloudService extends StreamingService { return SoundcloudPlaylistLinkHandlerFactory.getInstance(); } + @Override + public List getSupportedCountries() { + //Country selector here https://soundcloud.com/charts/top?genre=all-music + return ContentCountry.listFrom( + "AU", "CA", "DE", "FR", "GB", "IE", "NL", "NZ", "US" + ); + } @Override public StreamExtractor getStreamExtractor(LinkHandler LinkHandler) {