diff --git a/src/main/java/com/rarchives/ripme/ripper/rippers/AerisdiesRipper.java b/src/main/java/com/rarchives/ripme/ripper/rippers/AerisdiesRipper.java index 8e43aab0..74504b12 100644 --- a/src/main/java/com/rarchives/ripme/ripper/rippers/AerisdiesRipper.java +++ b/src/main/java/com/rarchives/ripme/ripper/rippers/AerisdiesRipper.java @@ -20,7 +20,6 @@ import java.util.HashMap; public class AerisdiesRipper extends AbstractHTMLRipper { - private Document albumDoc = null; private Map cookies = new HashMap<>(); @@ -41,17 +40,21 @@ public class AerisdiesRipper extends AbstractHTMLRipper { public String getGID(URL url) throws MalformedURLException { Pattern p = Pattern.compile("^https?://www.aerisdies.com/html/lb/[a-z]*_(\\d+)_\\d\\.html"); Matcher m = p.matcher(url.toExternalForm()); - if (!m.matches()) { - throw new MalformedURLException("Expected URL format: http://www.aerisdies.com/html/lb/albumDIG, got: " + url); + if (m.matches()) { + return m.group(1); } - return m.group(1); + throw new MalformedURLException("Expected URL format: http://www.aerisdies.com/html/lb/albumDIG, got: " + url); + } @Override public String getAlbumTitle(URL url) throws MalformedURLException { try { - // Attempt to use album title as GID - String title = getFirstPage().select("div > div > span[id=albumname] > a").first().text(); + Element el = getFirstPage().select(".headtext").first(); + if (el == null) { + throw new IOException("Unable to get album title"); + } + String title = el.text(); return getHost() + "_" + getGID(url) + "_" + title.trim(); } catch (IOException e) { // Fall back to default album naming convention @@ -62,12 +65,7 @@ public class AerisdiesRipper extends AbstractHTMLRipper { @Override public Document getFirstPage() throws IOException { - if (albumDoc == null) { - Response resp = Http.url(url).response(); - cookies.putAll(resp.cookies()); - albumDoc = resp.parse(); - } - return albumDoc; + return Http.url(url).get(); } @Override diff --git a/src/test/java/com/rarchives/ripme/tst/ripper/rippers/AerisdiesRipperTest.java b/src/test/java/com/rarchives/ripme/tst/ripper/rippers/AerisdiesRipperTest.java index 503db2c3..2e667787 100644 --- a/src/test/java/com/rarchives/ripme/tst/ripper/rippers/AerisdiesRipperTest.java +++ b/src/test/java/com/rarchives/ripme/tst/ripper/rippers/AerisdiesRipperTest.java @@ -16,5 +16,16 @@ public class AerisdiesRipperTest extends RippersTest { testRipper(ripper); } + public void testDjAlbum() throws IOException { + AerisdiesRipper ripper = new AerisdiesRipper(new URL("http://www.aerisdies.com/html/lb/douj_5230_1.html")); + testRipper(ripper); + } + + public void testGetGID() throws IOException { + URL url = new URL("http://www.aerisdies.com/html/lb/douj_5230_1.html"); + AerisdiesRipper ripper = new AerisdiesRipper(url); + assertEquals("5230", ripper.getGID(url)); + } + // TODO: Add a test for an album with a title. }