Skip to content

Commit c9e9953

Browse files
committed
[Bandcamp] Fix channel link handler factory
1 parent 5090373 commit c9e9953

2 files changed

Lines changed: 23 additions & 5 deletions

File tree

extractor/src/main/java/org/schabi/newpipe/extractor/services/bandcamp/linkHandler/BandcampChannelLinkHandlerFactory.java

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,15 +51,31 @@ public String getUrl(final String id, final List<String> contentFilter, final St
5151
}
5252

5353
/**
54-
* Accepts only pages that do not lead to an album or track. Supports external pages.
54+
* Accepts only pages that lead to the root of an artist profile. Supports external pages.
5555
*/
5656
@Override
5757
public boolean onAcceptUrl(final String url) throws ParsingException {
5858

59-
// Exclude URLs that lead to a track or album
60-
if (url.matches(".*/(album|track)/.*")) return false;
59+
// https: | | artist.bandcamp.com | releases
60+
// 0 1 2 3
61+
String[] splitUrl = url.split("/");
6162

62-
// Test whether domain is supported
63-
return BandcampExtractorHelper.isSupportedDomain(url);
63+
// URL is too short
64+
if (splitUrl.length < 3) return false;
65+
66+
// Must have "releases" as segment after url or none at all
67+
if (splitUrl.length > 3 && !splitUrl[3].equals("releases")) {
68+
69+
return false;
70+
71+
} else {
72+
if (splitUrl[2].equals("daily.bandcamp.com")) {
73+
// Refuse links to daily.bandcamp.com as that is not an artist
74+
return false;
75+
}
76+
77+
// Test whether domain is supported
78+
return BandcampExtractorHelper.isSupportedDomain(url);
79+
}
6480
}
6581
}

extractor/src/test/java/org/schabi/newpipe/extractor/services/bandcamp/BandcampChannelLinkHandlerFactoryTest.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ public void testAcceptUrl() throws ParsingException {
3535

3636
assertFalse(linkHandler.acceptUrl("https://bandcamp.com"));
3737
assertFalse(linkHandler.acceptUrl("https://zachbenson.bandcamp.com/track/kitchen"));
38+
assertFalse(linkHandler.acceptUrl("https://daily.bandcamp.com/"));
39+
assertFalse(linkHandler.acceptUrl("https://daily.bandcamp.com/best-of-2020/bandcamp-daily-staffers-on-their-favorite-albums-of-2020"));
3840

3941
// External URLs
4042
assertTrue(linkHandler.acceptUrl("http://interovgm.com/releases/"));

0 commit comments

Comments
 (0)