mirror of
https://github.com/RipMeApp/ripme.git
synced 2025-08-17 19:26:34 +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
|
@Override
|
||||||
public List<String> getURLsFromPage(Document doc) {
|
public List<String> getURLsFromPage(Document doc) {
|
||||||
List<String> imageURLs = new ArrayList<>();
|
List<String> imageURLs = new ArrayList<>();
|
||||||
for (Element thumb : doc.select("a.dribbble-link > picture > source")) {
|
for (Element thumbLink : doc.select("a.dribbble-link")) {
|
||||||
// nl skips thumbnails
|
// Resolve the absolute shot page URL
|
||||||
if ( thumb.attr("srcset").contains("teaser")) continue;
|
String shotPage = thumbLink.absUrl("href");
|
||||||
String image = thumb.attr("srcset").replace("_1x", "");
|
if (shotPage.isEmpty()) {
|
||||||
imageURLs.add(image);
|
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;
|
return imageURLs;
|
||||||
}
|
}
|
||||||
|
@@ -10,7 +10,6 @@ import org.junit.jupiter.api.Test;
|
|||||||
|
|
||||||
public class DribbbleRipperTest extends RippersTest {
|
public class DribbbleRipperTest extends RippersTest {
|
||||||
@Test
|
@Test
|
||||||
@Disabled("test or ripper broken")
|
|
||||||
public void testDribbbleRip() throws IOException, URISyntaxException {
|
public void testDribbbleRip() throws IOException, URISyntaxException {
|
||||||
DribbbleRipper ripper = new DribbbleRipper(new URI("https://dribbble.com/typogriff").toURL());
|
DribbbleRipper ripper = new DribbbleRipper(new URI("https://dribbble.com/typogriff").toURL());
|
||||||
testRipper(ripper);
|
testRipper(ripper);
|
||||||
|
Reference in New Issue
Block a user