From e08256ebc6ac71f3d1b3d94db1f81359e3e69cb9 Mon Sep 17 00:00:00 2001 From: Fynn Godau Date: Mon, 25 May 2020 19:17:27 +0200 Subject: [PATCH] Remove "url cleanup" in Bandcamp link handlers --- .../linkHandler/BandcampPlaylistLinkHandlerFactory.java | 7 ++----- .../linkHandler/BandcampStreamLinkHandlerFactory.java | 9 +++------ .../bandcamp/BandcampPlaylistLinkHandlerFactoryTest.java | 1 + .../bandcamp/BandcampStreamLinkHandlerFactoryTest.java | 5 ----- 4 files changed, 6 insertions(+), 16 deletions(-) diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/services/bandcamp/linkHandler/BandcampPlaylistLinkHandlerFactory.java b/extractor/src/main/java/org/schabi/newpipe/extractor/services/bandcamp/linkHandler/BandcampPlaylistLinkHandlerFactory.java index e7aac43e2..9a736b30f 100644 --- a/extractor/src/main/java/org/schabi/newpipe/extractor/services/bandcamp/linkHandler/BandcampPlaylistLinkHandlerFactory.java +++ b/extractor/src/main/java/org/schabi/newpipe/extractor/services/bandcamp/linkHandler/BandcampPlaylistLinkHandlerFactory.java @@ -18,14 +18,11 @@ public class BandcampPlaylistLinkHandlerFactory extends ListLinkHandlerFactory { @Override public String getUrl(String url, List contentFilter, String sortFilter) throws ParsingException { - if (url.endsWith("/")) - url = url.substring(0, url.length() - 1); - url = url.replace("http://", "https://").toLowerCase(); return url; } @Override - public boolean onAcceptUrl(String url) throws ParsingException { - return getUrl(url).matches("https?://.+\\..+/album/.+"); + public boolean onAcceptUrl(String url) { + return url.toLowerCase().matches("https?://.+\\..+/album/.+"); } } diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/services/bandcamp/linkHandler/BandcampStreamLinkHandlerFactory.java b/extractor/src/main/java/org/schabi/newpipe/extractor/services/bandcamp/linkHandler/BandcampStreamLinkHandlerFactory.java index 2d7495b97..176c2e2ba 100644 --- a/extractor/src/main/java/org/schabi/newpipe/extractor/services/bandcamp/linkHandler/BandcampStreamLinkHandlerFactory.java +++ b/extractor/src/main/java/org/schabi/newpipe/extractor/services/bandcamp/linkHandler/BandcampStreamLinkHandlerFactory.java @@ -7,7 +7,7 @@ import org.schabi.newpipe.extractor.linkhandler.LinkHandlerFactory; /** *

Tracks don't have standalone ids, they are always in combination with the band id. - * That's why id = url. Instead, URLs are cleaned up so that they always look the same.

+ * That's why id = url.

* *

Radio (bandcamp weekly) shows do have ids.

*/ @@ -33,10 +33,7 @@ public class BandcampStreamLinkHandlerFactory extends LinkHandlerFactory { public String getUrl(String input) { if (input.matches("\\d+")) return "https://bandcamp.com/?show=" + input; - if (input.endsWith("/")) - input = input.substring(0, input.length() - 1); - input = input.replace("http://", "https://").toLowerCase(); - return input; + else return input; } /** @@ -49,6 +46,6 @@ public class BandcampStreamLinkHandlerFactory extends LinkHandlerFactory { */ @Override public boolean onAcceptUrl(String url) { - return getUrl(url).matches("https?://.+\\..+/track/.+") || getUrl(url).matches("https?://bandcamp\\.com/\\?show=\\d+"); + return url.toLowerCase().matches("https?://.+\\..+/track/.+") || url.toLowerCase().matches("https?://bandcamp\\.com/\\?show=\\d+"); } } diff --git a/extractor/src/test/java/org/schabi/newpipe/extractor/services/bandcamp/BandcampPlaylistLinkHandlerFactoryTest.java b/extractor/src/test/java/org/schabi/newpipe/extractor/services/bandcamp/BandcampPlaylistLinkHandlerFactoryTest.java index 1da3069c9..f9cf9b1a7 100644 --- a/extractor/src/test/java/org/schabi/newpipe/extractor/services/bandcamp/BandcampPlaylistLinkHandlerFactoryTest.java +++ b/extractor/src/test/java/org/schabi/newpipe/extractor/services/bandcamp/BandcampPlaylistLinkHandlerFactoryTest.java @@ -40,6 +40,7 @@ public class BandcampPlaylistLinkHandlerFactoryTest { // Tests expecting true assertTrue(linkHandler.acceptUrl("https://powertothequeerkids.bandcamp.com/album/power-to-the-queer-kids")); assertTrue(linkHandler.acceptUrl("https://zachbenson.bandcamp.com/album/prom")); + assertTrue(linkHandler.acceptUrl("https://MACBENSON.BANDCAMP.COM/ALBUM/COMING-OF-AGE")); } } diff --git a/extractor/src/test/java/org/schabi/newpipe/extractor/services/bandcamp/BandcampStreamLinkHandlerFactoryTest.java b/extractor/src/test/java/org/schabi/newpipe/extractor/services/bandcamp/BandcampStreamLinkHandlerFactoryTest.java index 9cbd03295..3942fb1f1 100644 --- a/extractor/src/test/java/org/schabi/newpipe/extractor/services/bandcamp/BandcampStreamLinkHandlerFactoryTest.java +++ b/extractor/src/test/java/org/schabi/newpipe/extractor/services/bandcamp/BandcampStreamLinkHandlerFactoryTest.java @@ -25,11 +25,6 @@ public class BandcampStreamLinkHandlerFactoryTest { NewPipe.init(DownloaderTestImpl.getInstance()); } - @Test - public void testUrlCleanup() { - assertEquals("https://zachbenson.bandcamp.com/track/u-i-tonite", linkHandler.getUrl("http://ZachBenson.Bandcamp.COM/Track/U-I-Tonite/")); - } - @Test public void testGetRadioUrl() { assertEquals("https://bandcamp.com/?show=1", linkHandler.getUrl("1"));