Merge pull request #646 from cyian-1756/Aerisdies
Fixed Aerisdies ripper
This commit is contained in:
commit
90b2ef7edd
@ -20,7 +20,6 @@ import java.util.HashMap;
|
||||
|
||||
public class AerisdiesRipper extends AbstractHTMLRipper {
|
||||
|
||||
private Document albumDoc = null;
|
||||
private Map<String,String> 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
|
||||
|
@ -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.
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user