Remove "url cleanup" in Bandcamp link handlers

This commit is contained in:
Fynn Godau 2020-05-25 19:17:27 +02:00
parent 692b2d06f4
commit e08256ebc6
4 changed files with 6 additions and 16 deletions

View File

@ -18,14 +18,11 @@ public class BandcampPlaylistLinkHandlerFactory extends ListLinkHandlerFactory {
@Override @Override
public String getUrl(String url, List<String> contentFilter, String sortFilter) throws ParsingException { public String getUrl(String url, List<String> contentFilter, String sortFilter) throws ParsingException {
if (url.endsWith("/"))
url = url.substring(0, url.length() - 1);
url = url.replace("http://", "https://").toLowerCase();
return url; return url;
} }
@Override @Override
public boolean onAcceptUrl(String url) throws ParsingException { public boolean onAcceptUrl(String url) {
return getUrl(url).matches("https?://.+\\..+/album/.+"); return url.toLowerCase().matches("https?://.+\\..+/album/.+");
} }
} }

View File

@ -7,7 +7,7 @@ import org.schabi.newpipe.extractor.linkhandler.LinkHandlerFactory;
/** /**
* <p>Tracks don't have standalone ids, they are always in combination with the band id. * <p>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.</p> * That's why id = url.</p>
* *
* <p>Radio (bandcamp weekly) shows do have ids.</p> * <p>Radio (bandcamp weekly) shows do have ids.</p>
*/ */
@ -33,10 +33,7 @@ public class BandcampStreamLinkHandlerFactory extends LinkHandlerFactory {
public String getUrl(String input) { public String getUrl(String input) {
if (input.matches("\\d+")) if (input.matches("\\d+"))
return "https://bandcamp.com/?show=" + input; return "https://bandcamp.com/?show=" + input;
if (input.endsWith("/")) else return input;
input = input.substring(0, input.length() - 1);
input = input.replace("http://", "https://").toLowerCase();
return input;
} }
/** /**
@ -49,6 +46,6 @@ public class BandcampStreamLinkHandlerFactory extends LinkHandlerFactory {
*/ */
@Override @Override
public boolean onAcceptUrl(String url) { 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+");
} }
} }

View File

@ -40,6 +40,7 @@ public class BandcampPlaylistLinkHandlerFactoryTest {
// Tests expecting true // Tests expecting true
assertTrue(linkHandler.acceptUrl("https://powertothequeerkids.bandcamp.com/album/power-to-the-queer-kids")); 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://zachbenson.bandcamp.com/album/prom"));
assertTrue(linkHandler.acceptUrl("https://MACBENSON.BANDCAMP.COM/ALBUM/COMING-OF-AGE"));
} }
} }

View File

@ -25,11 +25,6 @@ public class BandcampStreamLinkHandlerFactoryTest {
NewPipe.init(DownloaderTestImpl.getInstance()); 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 @Test
public void testGetRadioUrl() { public void testGetRadioUrl() {
assertEquals("https://bandcamp.com/?show=1", linkHandler.getUrl("1")); assertEquals("https://bandcamp.com/?show=1", linkHandler.getUrl("1"));