mirror of
https://github.com/RipMeApp/ripme.git
synced 2025-08-16 02:44:10 +02:00
Fix for DribbbleRipper (#2129)
* Fix: now downloads all images from dribbble.com links * Test: allowed DribbbleRipperTests.java to run tests
This commit is contained in:
@@ -55,11 +55,34 @@ public class DribbbleRipper extends AbstractHTMLRipper {
|
||||
@Override
|
||||
public List<String> getURLsFromPage(Document doc) {
|
||||
List<String> imageURLs = new ArrayList<>();
|
||||
for (Element thumb : doc.select("a.dribbble-link > picture > source")) {
|
||||
// nl skips thumbnails
|
||||
if ( thumb.attr("srcset").contains("teaser")) continue;
|
||||
String image = thumb.attr("srcset").replace("_1x", "");
|
||||
imageURLs.add(image);
|
||||
for (Element thumbLink : doc.select("a.dribbble-link")) {
|
||||
// Resolve the absolute shot page URL
|
||||
String shotPage = thumbLink.absUrl("href");
|
||||
if (shotPage.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Fetch the shot page
|
||||
Document shotDoc;
|
||||
try {
|
||||
shotDoc = Http.url(shotPage).get();
|
||||
} catch (IOException e) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Grab the first <img> (the full-size image) on that page
|
||||
Element imageEl = shotDoc.selectFirst("div.shot-page-container img");
|
||||
if (imageEl == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Always use absUrl so you get a complete URI or an empty string
|
||||
String imageURL = imageEl.absUrl("src");
|
||||
if (imageURL.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
imageURLs.add(imageURL);
|
||||
}
|
||||
return imageURLs;
|
||||
}
|
||||
|
@@ -10,7 +10,6 @@ import org.junit.jupiter.api.Test;
|
||||
|
||||
public class DribbbleRipperTest extends RippersTest {
|
||||
@Test
|
||||
@Disabled("test or ripper broken")
|
||||
public void testDribbbleRip() throws IOException, URISyntaxException {
|
||||
DribbbleRipper ripper = new DribbbleRipper(new URI("https://dribbble.com/typogriff").toURL());
|
||||
testRipper(ripper);
|
||||
|
Reference in New Issue
Block a user