diff --git a/src/main/java/com/rarchives/ripme/ripper/rippers/DeviantartRipper.java b/src/main/java/com/rarchives/ripme/ripper/rippers/DeviantartRipper.java index a3428ae6..8d9f3da2 100644 --- a/src/main/java/com/rarchives/ripme/ripper/rippers/DeviantartRipper.java +++ b/src/main/java/com/rarchives/ripme/ripper/rippers/DeviantartRipper.java @@ -190,13 +190,11 @@ public class DeviantartRipper extends AbstractJSONRipper { return null; } - private String getGalleryID(Document doc) { + public String getGalleryID(Document doc) { for (Element el : doc.select("input[name=set]")) { try { String galleryID = el.attr("value"); - if (galleryID.length() == 8) { - return galleryID; - } + return galleryID; } catch (NullPointerException e) { continue; } @@ -205,7 +203,7 @@ public class DeviantartRipper extends AbstractJSONRipper { return null; } - private String getUsername(Document doc) { + public String getUsername(Document doc) { return doc.select("meta[property=og:title]").attr("content").replaceAll("'s DeviantArt gallery", ""); } diff --git a/src/test/java/com/rarchives/ripme/tst/ripper/rippers/DeviantartRipperTest.java b/src/test/java/com/rarchives/ripme/tst/ripper/rippers/DeviantartRipperTest.java index f68d1db5..52b6bc59 100644 --- a/src/test/java/com/rarchives/ripme/tst/ripper/rippers/DeviantartRipperTest.java +++ b/src/test/java/com/rarchives/ripme/tst/ripper/rippers/DeviantartRipperTest.java @@ -4,6 +4,8 @@ import java.io.IOException; import java.net.URL; import com.rarchives.ripme.ripper.rippers.DeviantartRipper; +import com.rarchives.ripme.utils.Http; +import org.jsoup.nodes.Document; public class DeviantartRipperTest extends RippersTest { public void testDeviantartAlbum() throws IOException { @@ -22,4 +24,12 @@ public class DeviantartRipperTest extends RippersTest { DeviantartRipper ripper = new DeviantartRipper(url); assertEquals("airgee", ripper.getGID(url)); } + + public void testGetGalleryIDAndUsername() throws IOException { + URL url = new URL("https://www.deviantart.com/airgee/gallery/"); + DeviantartRipper ripper = new DeviantartRipper(url); + Document doc = Http.url(url).get(); + assertEquals("airgee", ripper.getUsername(doc)); + assertEquals("714589", ripper.getGalleryID(doc)); + } }