Merge pull request #1199 from TeamNewPipe/bandcamp-update-artist-detection
[Bandcamp] Update artist page detection
This commit is contained in:
commit
4aaab63c12
|
@ -155,25 +155,30 @@ public final class BandcampExtractorHelper {
|
|||
|
||||
/**
|
||||
* @return <code>true</code> if the given URL looks like it comes from a bandcamp custom domain
|
||||
* or if it comes from <code>bandcamp.com</code> itself
|
||||
* or a <code>*.bandcamp.com</code> subdomain
|
||||
*/
|
||||
public static boolean isSupportedDomain(final String url) throws ParsingException {
|
||||
public static boolean isArtistDomain(final String url) throws ParsingException {
|
||||
|
||||
// Accept all bandcamp.com URLs
|
||||
if (url.toLowerCase().matches("https?://.+\\.bandcamp\\.com(/.*)?")) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Reject non-artist bandcamp.com URLs
|
||||
if (url.toLowerCase().matches("https?://bandcamp\\.com(/.*)?")) {
|
||||
return false;
|
||||
}
|
||||
|
||||
try {
|
||||
// Test other URLs for whether they contain a footer that links to bandcamp
|
||||
return Jsoup.parse(NewPipe.getDownloader().get(url).responseBody())
|
||||
.getElementById("pgFt")
|
||||
.getElementById("pgFt-inner")
|
||||
.getElementById("footer-logo-wrapper")
|
||||
.getElementById("footer-logo")
|
||||
.getElementsByClass("hiddenAccess")
|
||||
.text().equals("Bandcamp");
|
||||
} catch (final NullPointerException e) {
|
||||
.getElementsByClass("cart-wrapper")
|
||||
.get(0)
|
||||
.getElementsByTag("a")
|
||||
.get(0)
|
||||
.attr("href")
|
||||
.equals("https://bandcamp.com/cart");
|
||||
} catch (final NullPointerException | IndexOutOfBoundsException e) {
|
||||
return false;
|
||||
} catch (final IOException | ReCaptchaException e) {
|
||||
throw new ParsingException("Could not determine whether URL is custom domain "
|
||||
|
|
|
@ -90,7 +90,7 @@ public final class BandcampChannelLinkHandlerFactory extends ListLinkHandlerFact
|
|||
}
|
||||
|
||||
// Test whether domain is supported
|
||||
return BandcampExtractorHelper.isSupportedDomain(lowercaseUrl);
|
||||
return BandcampExtractorHelper.isArtistDomain(lowercaseUrl);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -39,7 +39,7 @@ public final class BandcampCommentsLinkHandlerFactory extends ListLinkHandlerFac
|
|||
}
|
||||
|
||||
// Test whether domain is supported
|
||||
return BandcampExtractorHelper.isSupportedDomain(url);
|
||||
return BandcampExtractorHelper.isArtistDomain(url);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -48,6 +48,6 @@ public final class BandcampPlaylistLinkHandlerFactory extends ListLinkHandlerFac
|
|||
}
|
||||
|
||||
// Test whether domain is supported
|
||||
return BandcampExtractorHelper.isSupportedDomain(url);
|
||||
return BandcampExtractorHelper.isArtistDomain(url);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -71,6 +71,6 @@ public final class BandcampStreamLinkHandlerFactory extends LinkHandlerFactory {
|
|||
}
|
||||
|
||||
// Test whether domain is supported
|
||||
return BandcampExtractorHelper.isSupportedDomain(url);
|
||||
return BandcampExtractorHelper.isArtistDomain(url);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -39,6 +39,5 @@ public class BandcampCommentsLinkHandlerFactoryTest {
|
|||
assertTrue(linkHandler.acceptUrl("http://ZachBenson.Bandcamp.COM/Track/U-I-Tonite/"));
|
||||
assertTrue(linkHandler.acceptUrl("https://interovgm.bandcamp.com/track/title"));
|
||||
assertTrue(linkHandler.acceptUrl("https://goodgoodblood-tl.bandcamp.com/track/when-it-all-wakes-up"));
|
||||
assertTrue(linkHandler.acceptUrl("https://lobstertheremin.com/track/unfinished"));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -49,6 +49,5 @@ public class BandcampStreamLinkHandlerFactoryTest {
|
|||
assertTrue(linkHandler.acceptUrl("https://interovgm.bandcamp.com/track/title"));
|
||||
assertTrue(linkHandler.acceptUrl("http://bandcamP.com/?show=38"));
|
||||
assertTrue(linkHandler.acceptUrl("https://goodgoodblood-tl.bandcamp.com/track/when-it-all-wakes-up"));
|
||||
assertTrue(linkHandler.acceptUrl("https://lobstertheremin.com/track/unfinished"));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue