mirror of
https://github.com/TeamNewPipe/NewPipeExtractor.git
synced 2024-12-13 22:00:32 +05:30
[Bandcamp] Update artist page detection
Bandcamp changed the way the footer is rendered. Therefore, we check for a link to the cart page instead.
This commit is contained in:
parent
592f1596e6
commit
de9fb7cb28
@ -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
|
* @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
|
// Accept all bandcamp.com URLs
|
||||||
if (url.toLowerCase().matches("https?://.+\\.bandcamp\\.com(/.*)?")) {
|
if (url.toLowerCase().matches("https?://.+\\.bandcamp\\.com(/.*)?")) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Reject non-artist bandcamp.com URLs
|
||||||
|
if (url.toLowerCase().matches("https?://bandcamp\\.com(/.*)?")) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// Test other URLs for whether they contain a footer that links to bandcamp
|
// Test other URLs for whether they contain a footer that links to bandcamp
|
||||||
return Jsoup.parse(NewPipe.getDownloader().get(url).responseBody())
|
return Jsoup.parse(NewPipe.getDownloader().get(url).responseBody())
|
||||||
.getElementById("pgFt")
|
.getElementsByClass("cart-wrapper")
|
||||||
.getElementById("pgFt-inner")
|
.get(0)
|
||||||
.getElementById("footer-logo-wrapper")
|
.getElementsByTag("a")
|
||||||
.getElementById("footer-logo")
|
.get(0)
|
||||||
.getElementsByClass("hiddenAccess")
|
.attr("href")
|
||||||
.text().equals("Bandcamp");
|
.equals("https://bandcamp.com/cart");
|
||||||
} catch (final NullPointerException e) {
|
} catch (final NullPointerException | IndexOutOfBoundsException e) {
|
||||||
return false;
|
return false;
|
||||||
} catch (final IOException | ReCaptchaException e) {
|
} catch (final IOException | ReCaptchaException e) {
|
||||||
throw new ParsingException("Could not determine whether URL is custom domain "
|
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
|
// 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
|
// Test whether domain is supported
|
||||||
return BandcampExtractorHelper.isSupportedDomain(url);
|
return BandcampExtractorHelper.isArtistDomain(url);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -48,6 +48,6 @@ public final class BandcampPlaylistLinkHandlerFactory extends ListLinkHandlerFac
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Test whether domain is supported
|
// 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
|
// 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("http://ZachBenson.Bandcamp.COM/Track/U-I-Tonite/"));
|
||||||
assertTrue(linkHandler.acceptUrl("https://interovgm.bandcamp.com/track/title"));
|
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://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("https://interovgm.bandcamp.com/track/title"));
|
||||||
assertTrue(linkHandler.acceptUrl("http://bandcamP.com/?show=38"));
|
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://goodgoodblood-tl.bandcamp.com/track/when-it-all-wakes-up"));
|
||||||
assertTrue(linkHandler.acceptUrl("https://lobstertheremin.com/track/unfinished"));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user