@Nonnull @Override public InfoItemsPage<StreamInfoItem> getInitialPage() throws IOException, ExtractionException { if(collector == null) { computNextPageAndStreams(); } return new InfoItemsPage<>(collector, getNextPageUrl()); } }
@Nonnull @Override public String getName() { return getId(); }
private void computNextPageAndStreams() throws IOException, ExtractionException { collector = new StreamInfoItemsCollector(getServiceId()); String apiUrl = "https://api-v2.soundcloud.com/charts" + "?genre=soundcloud:genres:all-music" + "&client_id=" + SoundcloudParsingHelper.clientId(); if (getId().equals("Top 50")) { apiUrl += "&kind=top"; } else { apiUrl += "&kind=trending"; } /*List<String> supportedCountries = Arrays.asList("AU", "CA", "FR", "DE", "IE", "NL", "NZ", "GB", "US"); String contentCountry = getContentCountry(); if (supportedCountries.contains(contentCountry)) { apiUrl += "®ion=soundcloud:regions:" + contentCountry; }*/ nextPageUrl = SoundcloudParsingHelper.getStreamsFromApi(collector, apiUrl, true); }
@Override public String getNextPageUrl() throws IOException, ExtractionException { if(nextPageUrl == null) { computNextPageAndStreams(); } return nextPageUrl; }
@Override public InfoItemsPage<StreamInfoItem> getPage(String pageUrl) throws IOException, ExtractionException { if (pageUrl == null || pageUrl.isEmpty()) { throw new ExtractionException(new IllegalArgumentException("Page url is empty or null")); } StreamInfoItemsCollector collector = new StreamInfoItemsCollector(getServiceId()); String nextPageUrl = SoundcloudParsingHelper.getStreamsFromApi(collector, pageUrl, true); return new InfoItemsPage<>(collector, nextPageUrl); }
@Override public KioskExtractor createNewKiosk(StreamingService streamingService, String url, String id, Localization local) throws ExtractionException { return new SoundcloudChartsExtractor(SoundcloudService.this, new SoundcloudChartsLinkHandlerFactory().fromUrl(url), id, local); } };