public static long getCacheExpirationMillis(final int serviceId) { if (serviceId == SoundCloud.getServiceId()) { return TimeUnit.MILLISECONDS.convert(5, TimeUnit.MINUTES); } else { return TimeUnit.MILLISECONDS.convert(1, TimeUnit.HOURS); } }
@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); } };
@Override public SuggestionExtractor getSuggestionExtractor(Localization localization) { return new SoundcloudSuggestionExtractor(getServiceId(), localization); }
private void computeStreamsAndNextPageUrl() throws ExtractionException, IOException { streamInfoItemsCollector = new StreamInfoItemsCollector(getServiceId()); // Note the "api", NOT "api-v2" String apiUrl = "https://api.soundcloud.com/playlists/" + getId() + "/tracks" + "?client_id=" + SoundcloudParsingHelper.clientId() + "&limit=20" + "&linked_partitioning=1"; nextPageUrl = SoundcloudParsingHelper.getStreamsFromApiMinItems(15, streamInfoItemsCollector, apiUrl); }
@Override public StreamInfoItemsCollector getRelatedStreams() throws IOException, ExtractionException { StreamInfoItemsCollector collector = new StreamInfoItemsCollector(getServiceId()); String apiUrl = "https://api-v2.soundcloud.com/tracks/" + urlEncode(getId()) + "/related" + "?client_id=" + urlEncode(SoundcloudParsingHelper.clientId()); SoundcloudParsingHelper.getStreamsFromApi(collector, apiUrl); return collector; }
@Override public String getNextPageUrl() throws IOException, ExtractionException { return getNextPageUrlFromCurrentUrl(getUrl()); }
@Override public SubscriptionExtractor getSubscriptionExtractor() { return new SoundcloudSubscriptionExtractor(this); } }
@Test public void testFromChannelUrl() throws Exception { testList(subscriptionExtractor.fromChannelUrl("https://soundcloud.com/monstercat")); testList(subscriptionExtractor.fromChannelUrl("http://soundcloud.com/monstercat")); testList(subscriptionExtractor.fromChannelUrl("soundcloud.com/monstercat")); testList(subscriptionExtractor.fromChannelUrl("monstercat")); //Empty followings user testList(subscriptionExtractor.fromChannelUrl("some-random-user-184047028")); }
@Override public String getNextPageUrl() throws ExtractionException { if(nextPageUrl == null) { computeNextPageAndGetStreams(); } return nextPageUrl; }
@Override public String getNextPageUrl() throws IOException, ExtractionException { if(nextPageUrl == null) { computNextPageAndStreams(); } return nextPageUrl; }
@Override public String getNextPageUrl() throws IOException, ExtractionException { if (nextPageUrl == null) { computeStreamsAndNextPageUrl(); } return nextPageUrl; }
@Override public SearchExtractor getSearchExtractor(SearchQueryHandler queryHandler, Localization localization) { return new SoundcloudSearchExtractor(this, queryHandler, localization); }
@Override public StreamExtractor getStreamExtractor(LinkHandler LinkHandler, Localization localization) { return new SoundcloudStreamExtractor(this, LinkHandler, localization); }
@Override public ChannelExtractor getChannelExtractor(ListLinkHandler linkHandler, Localization localization) { return new SoundcloudChannelExtractor(this, linkHandler, localization); }
@Override public SearchQueryHandlerFactory getSearchQHFactory() { return new SoundcloudSearchQueryHandlerFactory(); }
@Override public String getUploaderUrl() { return SoundcloudParsingHelper.getUploaderUrl(playlist); }
@Override public String getUploaderName() { return SoundcloudParsingHelper.getUploaderName(playlist); }
@Override public long getTimeStamp() throws ParsingException { return getTimestampSeconds("(#t=\\d{0,3}h?\\d{0,3}m?\\d{1,3}s?)"); }
@Override public ListLinkHandlerFactory getPlaylistLHFactory() { return SoundcloudPlaylistLinkHandlerFactory.getInstance(); }
@Override public String getUploaderAvatarUrl() { return SoundcloudParsingHelper.getAvatarUrl(playlist); }