Merge pull request #1031 from petlyh/bandcamp-fix-radio-comments

[Bandcamp] Show comments as disabled on radio streams
This commit is contained in:
fynngodau 2023-02-27 20:50:12 +01:00 committed by GitHub
commit 3fdb6ee476
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 10 additions and 1 deletions

View File

@ -53,4 +53,9 @@ public class BandcampCommentsExtractor extends CommentsExtractor {
throws IOException, ExtractionException {
return null;
}
@Override
public boolean isCommentsDisabled() throws ExtractionException {
return BandcampExtractorHelper.isRadioUrl(getUrl());
}
}

View File

@ -19,6 +19,10 @@ public class BandcampCommentsLinkHandlerFactory extends ListLinkHandlerFactory {
@Override
public boolean onAcceptUrl(final String url) throws ParsingException {
if (BandcampExtractorHelper.isRadioUrl(url)) {
return true;
}
// Don't accept URLs that don't point to a track
if (!url.toLowerCase().matches("https?://.+\\..+/(track|album)/.+")) {
return false;

View File

@ -32,8 +32,8 @@ public class BandcampCommentsLinkHandlerFactoryTest {
assertFalse(linkHandler.acceptUrl("https://bandcamp.com"));
assertFalse(linkHandler.acceptUrl("https://zachbenson.bandcamp.com/"));
assertFalse(linkHandler.acceptUrl("https://example.com/track/sampletrack"));
assertFalse(linkHandler.acceptUrl("http://bandcamP.com/?show=38"));
assertTrue(linkHandler.acceptUrl("http://bandcamP.com/?show=38"));
assertTrue(linkHandler.acceptUrl("https://powertothequeerkids.bandcamp.com/album/power-to-the-queer-kids"));
assertTrue(linkHandler.acceptUrl("https://zachbenson.bandcamp.com/track/kitchen"));
assertTrue(linkHandler.acceptUrl("http://ZachBenson.Bandcamp.COM/Track/U-I-Tonite/"));