Skip to content

Commit c1c2a7c

Browse files
authored
Fix for DribbbleRipper (#2129)
* Fix: now downloads all images from dribbble.com links * Test: allowed DribbbleRipperTests.java to run tests
1 parent 531f235 commit c1c2a7c

File tree

2 files changed

+28
-6
lines changed

2 files changed

+28
-6
lines changed

src/main/java/com/rarchives/ripme/ripper/rippers/DribbbleRipper.java

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,34 @@ public Document getNextPage(Document doc) throws IOException {
5555
@Override
5656
public List<String> getURLsFromPage(Document doc) {
5757
List<String> imageURLs = new ArrayList<>();
58-
for (Element thumb : doc.select("a.dribbble-link > picture > source")) {
59-
// nl skips thumbnails
60-
if ( thumb.attr("srcset").contains("teaser")) continue;
61-
String image = thumb.attr("srcset").replace("_1x", "");
62-
imageURLs.add(image);
58+
for (Element thumbLink : doc.select("a.dribbble-link")) {
59+
// Resolve the absolute shot page URL
60+
String shotPage = thumbLink.absUrl("href");
61+
if (shotPage.isEmpty()) {
62+
continue;
63+
}
64+
65+
// Fetch the shot page
66+
Document shotDoc;
67+
try {
68+
shotDoc = Http.url(shotPage).get();
69+
} catch (IOException e) {
70+
continue;
71+
}
72+
73+
// Grab the first <img> (the full-size image) on that page
74+
Element imageEl = shotDoc.selectFirst("div.shot-page-container img");
75+
if (imageEl == null) {
76+
continue;
77+
}
78+
79+
// Always use absUrl so you get a complete URI or an empty string
80+
String imageURL = imageEl.absUrl("src");
81+
if (imageURL.isEmpty()) {
82+
continue;
83+
}
84+
85+
imageURLs.add(imageURL);
6386
}
6487
return imageURLs;
6588
}

src/test/java/com/rarchives/ripme/tst/ripper/rippers/DribbbleRipperTest.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010

1111
public class DribbbleRipperTest extends RippersTest {
1212
@Test
13-
@Disabled("test or ripper broken")
1413
public void testDribbbleRip() throws IOException, URISyntaxException {
1514
DribbbleRipper ripper = new DribbbleRipper(new URI("https://dribbble.com/typogriff").toURL());
1615
testRipper(ripper);

0 commit comments

Comments
 (0)