From 227c6894a70f878dff193e964d53069fe4de2d98 Mon Sep 17 00:00:00 2001 From: Fynn Godau Date: Sun, 21 Jul 2024 23:59:10 +0200 Subject: [PATCH] [Bandcamp] Show additional info in radio kiosk A newer version of the radio list API delivers additional fields. Thanks @crisp5. --- .../bandcamp/extractors/BandcampRadioExtractor.java | 2 +- .../extractors/BandcampRadioInfoItemExtractor.java | 10 ++++++++-- .../BandcampFeaturedLinkHandlerFactoryTest.java | 6 +++--- .../services/bandcamp/BandcampRadioExtractorTest.java | 10 +++++----- 4 files changed, 17 insertions(+), 11 deletions(-) diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/services/bandcamp/extractors/BandcampRadioExtractor.java b/extractor/src/main/java/org/schabi/newpipe/extractor/services/bandcamp/extractors/BandcampRadioExtractor.java index a90eb3cc4..8a8c97a8c 100644 --- a/extractor/src/main/java/org/schabi/newpipe/extractor/services/bandcamp/extractors/BandcampRadioExtractor.java +++ b/extractor/src/main/java/org/schabi/newpipe/extractor/services/bandcamp/extractors/BandcampRadioExtractor.java @@ -24,7 +24,7 @@ import static org.schabi.newpipe.extractor.services.bandcamp.extractors.Bandcamp public class BandcampRadioExtractor extends KioskExtractor { public static final String KIOSK_RADIO = "Radio"; - public static final String RADIO_API_URL = BASE_API_URL + "/bcweekly/1/list"; + public static final String RADIO_API_URL = BASE_API_URL + "/bcweekly/3/list"; private JsonObject json = null; diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/services/bandcamp/extractors/BandcampRadioInfoItemExtractor.java b/extractor/src/main/java/org/schabi/newpipe/extractor/services/bandcamp/extractors/BandcampRadioInfoItemExtractor.java index 023234aa3..30fa72069 100644 --- a/extractor/src/main/java/org/schabi/newpipe/extractor/services/bandcamp/extractors/BandcampRadioInfoItemExtractor.java +++ b/extractor/src/main/java/org/schabi/newpipe/extractor/services/bandcamp/extractors/BandcampRadioInfoItemExtractor.java @@ -35,6 +35,12 @@ public class BandcampRadioInfoItemExtractor implements StreamInfoItemExtractor { return 0; } + @Nullable + @Override + public String getShortDescription() { + return show.getString("desc"); + } + @Nullable @Override public String getTextualUploadDate() { @@ -75,8 +81,8 @@ public class BandcampRadioInfoItemExtractor implements StreamInfoItemExtractor { @Override public String getUploaderName() { - // JSON does not contain uploader name - return ""; + // The "title" field contains the title of the series, e.g. "Bandcamp Weekly". + return show.getString("title"); } @Override diff --git a/extractor/src/test/java/org/schabi/newpipe/extractor/services/bandcamp/BandcampFeaturedLinkHandlerFactoryTest.java b/extractor/src/test/java/org/schabi/newpipe/extractor/services/bandcamp/BandcampFeaturedLinkHandlerFactoryTest.java index 16d5fabca..583d78c34 100644 --- a/extractor/src/test/java/org/schabi/newpipe/extractor/services/bandcamp/BandcampFeaturedLinkHandlerFactoryTest.java +++ b/extractor/src/test/java/org/schabi/newpipe/extractor/services/bandcamp/BandcampFeaturedLinkHandlerFactoryTest.java @@ -28,7 +28,7 @@ public class BandcampFeaturedLinkHandlerFactoryTest { assertTrue(linkHandler.acceptUrl("https://bandcamp.com/?show=1")); assertTrue(linkHandler.acceptUrl("http://bandcamp.com/?show=2")); assertTrue(linkHandler.acceptUrl("https://bandcamp.com/api/mobile/24/bootstrap_data")); - assertTrue(linkHandler.acceptUrl("https://bandcamp.com/api/bcweekly/1/list")); + assertTrue(linkHandler.acceptUrl("https://bandcamp.com/api/bcweekly/3/list")); assertFalse(linkHandler.acceptUrl("https://bandcamp.com/?show=")); assertFalse(linkHandler.acceptUrl("https://bandcamp.com/?show=a")); @@ -38,7 +38,7 @@ public class BandcampFeaturedLinkHandlerFactoryTest { @Test public void testGetUrl() throws ParsingException { assertEquals("https://bandcamp.com/api/mobile/24/bootstrap_data", linkHandler.getUrl("Featured")); - assertEquals("https://bandcamp.com/api/bcweekly/1/list", linkHandler.getUrl("Radio")); + assertEquals("https://bandcamp.com/api/bcweekly/3/list", linkHandler.getUrl("Radio")); } @Test @@ -46,7 +46,7 @@ public class BandcampFeaturedLinkHandlerFactoryTest { assertEquals("Featured", linkHandler.getId("http://bandcamp.com/api/mobile/24/bootstrap_data")); assertEquals("Featured", linkHandler.getId("https://bandcamp.com/api/mobile/24/bootstrap_data")); assertEquals("Radio", linkHandler.getId("http://bandcamp.com/?show=1")); - assertEquals("Radio", linkHandler.getId("https://bandcamp.com/api/bcweekly/1/list")); + assertEquals("Radio", linkHandler.getId("https://bandcamp.com/api/bcweekly/3/list")); } } diff --git a/extractor/src/test/java/org/schabi/newpipe/extractor/services/bandcamp/BandcampRadioExtractorTest.java b/extractor/src/test/java/org/schabi/newpipe/extractor/services/bandcamp/BandcampRadioExtractorTest.java index 9b3f3cedd..b08ff002a 100644 --- a/extractor/src/test/java/org/schabi/newpipe/extractor/services/bandcamp/BandcampRadioExtractorTest.java +++ b/extractor/src/test/java/org/schabi/newpipe/extractor/services/bandcamp/BandcampRadioExtractorTest.java @@ -8,6 +8,7 @@ import org.schabi.newpipe.downloader.DownloaderTestImpl; import org.schabi.newpipe.extractor.NewPipe; import org.schabi.newpipe.extractor.exceptions.ExtractionException; import org.schabi.newpipe.extractor.services.BaseListExtractorTest; +import org.schabi.newpipe.extractor.services.DefaultTests; import org.schabi.newpipe.extractor.services.bandcamp.extractors.BandcampRadioExtractor; import org.schabi.newpipe.extractor.stream.StreamInfoItem; @@ -35,15 +36,14 @@ public class BandcampRadioExtractorTest implements BaseListExtractorTest { } @Test - public void testRadioCount() throws ExtractionException, IOException { + public void testRadioCount() { final List list = extractor.getInitialPage().getItems(); assertTrue(list.size() > 300); } @Test public void testRelatedItems() throws Exception { - // DefaultTests.defaultTestRelatedItems(extractor); - // Would fail because BandcampRadioInfoItemExtractor.getUploaderName() returns an empty String + DefaultTests.defaultTestRelatedItems(extractor); } @Test @@ -68,11 +68,11 @@ public class BandcampRadioExtractorTest implements BaseListExtractorTest { @Test public void testUrl() throws Exception { - assertEquals("https://bandcamp.com/api/bcweekly/1/list", extractor.getUrl()); + assertEquals("https://bandcamp.com/api/bcweekly/3/list", extractor.getUrl()); } @Test public void testOriginalUrl() throws Exception { - assertEquals("https://bandcamp.com/api/bcweekly/1/list", extractor.getOriginalUrl()); + assertEquals("https://bandcamp.com/api/bcweekly/3/list", extractor.getOriginalUrl()); } }