private void computeNextPageAndGetStreams() throws ExtractionException { try { streamInfoItemsCollector = new StreamInfoItemsCollector(getServiceId()); String apiUrl = "https://api-v2.soundcloud.com/users/" + getId() + "/tracks" + "?client_id=" + SoundcloudParsingHelper.clientId() + "&limit=20" + "&linked_partitioning=1"; nextPageUrl = SoundcloudParsingHelper.getStreamsFromApiMinItems(15, streamInfoItemsCollector, apiUrl); } catch (Exception e) { throw new ExtractionException("Could not get next page", e); } }
@Override public ChannelExtractor getChannelExtractor(ListLinkHandler linkHandler, Localization localization) { return new SoundcloudChannelExtractor(this, linkHandler, localization); }
@Nonnull @Override public InfoItemsPage<StreamInfoItem> getInitialPage() throws ExtractionException { if(streamInfoItemsCollector == null) { computeNextPageAndGetStreams(); } return new InfoItemsPage<>(streamInfoItemsCollector, getNextPageUrl()); }
@Override public InfoItemsPage<StreamInfoItem> getPage(final 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.getStreamsFromApiMinItems(15, collector, pageUrl); return new InfoItemsPage<>(collector, nextPageUrl); }
@Test public void testId() { assertEquals("10494998", extractor.getId()); }
@BeforeClass public static void setUp() throws Exception { NewPipe.init(Downloader.getInstance(), new Localization("GB", "en")); extractor = (SoundcloudChannelExtractor) SoundCloud .getChannelExtractor("https://soundcloud.com/dubmatix"); extractor.fetchPage(); }
@Test public void testDescription() { assertNotNull(extractor.getDescription()); }
@Test public void testAvatarUrl() { assertIsSecureUrl(extractor.getAvatarUrl()); }
@Test public void testBannerUrl() { assertIsSecureUrl(extractor.getBannerUrl()); }
@Test public void testFeedUrl() { assertEmpty(extractor.getFeedUrl()); }
@Override public String getNextPageUrl() throws ExtractionException { if(nextPageUrl == null) { computeNextPageAndGetStreams(); } return nextPageUrl; }
@Override public void onFetchPage(@Nonnull Downloader downloader) throws IOException, ExtractionException { userId = getLinkHandler().getId(); String apiUrl = "https://api-v2.soundcloud.com/users/" + userId + "?client_id=" + SoundcloudParsingHelper.clientId(); String response = downloader.download(apiUrl); try { user = JsonParser.object().from(response); } catch (JsonParserException e) { throw new ParsingException("Could not parse json response", e); } }
@Test public void testServiceId() { assertEquals(SoundCloud.getServiceId(), extractor.getServiceId()); }
@Test public void testId() { assertEquals("542134", extractor.getId()); }
@BeforeClass public static void setUp() throws Exception { NewPipe.init(Downloader.getInstance(), new Localization("GB", "en")); extractor = (SoundcloudChannelExtractor) SoundCloud .getChannelExtractor("http://soundcloud.com/liluzivert/sets"); extractor.fetchPage(); }
@Test public void testDescription() { assertNotNull(extractor.getDescription()); }
@Test public void testAvatarUrl() { assertIsSecureUrl(extractor.getAvatarUrl()); }
@Test public void testBannerUrl() { assertIsSecureUrl(extractor.getBannerUrl()); }
@Test public void testFeedUrl() { assertEmpty(extractor.getFeedUrl()); }
@Test public void testServiceId() { assertEquals(SoundCloud.getServiceId(), extractor.getServiceId()); }