Merge pull request #646 from cyian-1756/Aerisdies

Fixed Aerisdies ripper
This commit is contained in:
Kevin Jiang 2018-06-02 15:46:14 -04:00 committed by GitHub
commit 90b2ef7edd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 21 additions and 12 deletions

View File

@ -20,7 +20,6 @@ import java.util.HashMap;
public class AerisdiesRipper extends AbstractHTMLRipper { public class AerisdiesRipper extends AbstractHTMLRipper {
private Document albumDoc = null;
private Map<String,String> cookies = new HashMap<>(); private Map<String,String> cookies = new HashMap<>();
@ -41,17 +40,21 @@ public class AerisdiesRipper extends AbstractHTMLRipper {
public String getGID(URL url) throws MalformedURLException { public String getGID(URL url) throws MalformedURLException {
Pattern p = Pattern.compile("^https?://www.aerisdies.com/html/lb/[a-z]*_(\\d+)_\\d\\.html"); Pattern p = Pattern.compile("^https?://www.aerisdies.com/html/lb/[a-z]*_(\\d+)_\\d\\.html");
Matcher m = p.matcher(url.toExternalForm()); Matcher m = p.matcher(url.toExternalForm());
if (!m.matches()) { if (m.matches()) {
throw new MalformedURLException("Expected URL format: http://www.aerisdies.com/html/lb/albumDIG, got: " + url);
}
return m.group(1); return m.group(1);
} }
throw new MalformedURLException("Expected URL format: http://www.aerisdies.com/html/lb/albumDIG, got: " + url);
}
@Override @Override
public String getAlbumTitle(URL url) throws MalformedURLException { public String getAlbumTitle(URL url) throws MalformedURLException {
try { try {
// Attempt to use album title as GID Element el = getFirstPage().select(".headtext").first();
String title = getFirstPage().select("div > div > span[id=albumname] > a").first().text(); if (el == null) {
throw new IOException("Unable to get album title");
}
String title = el.text();
return getHost() + "_" + getGID(url) + "_" + title.trim(); return getHost() + "_" + getGID(url) + "_" + title.trim();
} catch (IOException e) { } catch (IOException e) {
// Fall back to default album naming convention // Fall back to default album naming convention
@ -62,12 +65,7 @@ public class AerisdiesRipper extends AbstractHTMLRipper {
@Override @Override
public Document getFirstPage() throws IOException { public Document getFirstPage() throws IOException {
if (albumDoc == null) { return Http.url(url).get();
Response resp = Http.url(url).response();
cookies.putAll(resp.cookies());
albumDoc = resp.parse();
}
return albumDoc;
} }
@Override @Override

View File

@ -16,5 +16,16 @@ public class AerisdiesRipperTest extends RippersTest {
testRipper(ripper); 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. // TODO: Add a test for an album with a title.
} }