Merge pull request #99 from cyian-1756/chan.sankakucomplex
Fixed sankakucomplex ripper
This commit is contained in:
commit
cb55415c28
@ -43,7 +43,7 @@ public class SankakuComplexRipper extends AbstractHTMLRipper {
|
|||||||
Matcher m = p.matcher(url.toExternalForm());
|
Matcher m = p.matcher(url.toExternalForm());
|
||||||
if (m.matches()) {
|
if (m.matches()) {
|
||||||
try {
|
try {
|
||||||
return URLDecoder.decode(m.group(1), "UTF-8");
|
return URLDecoder.decode(m.group(2), "UTF-8");
|
||||||
} catch (UnsupportedEncodingException e) {
|
} catch (UnsupportedEncodingException e) {
|
||||||
throw new MalformedURLException("Cannot decode tag name '" + m.group(1) + "'");
|
throw new MalformedURLException("Cannot decode tag name '" + m.group(1) + "'");
|
||||||
}
|
}
|
||||||
@ -68,31 +68,39 @@ public class SankakuComplexRipper extends AbstractHTMLRipper {
|
|||||||
List<String> imageURLs = new ArrayList<String>();
|
List<String> imageURLs = new ArrayList<String>();
|
||||||
// Image URLs are basically thumbnail URLs with a different domain, a simple
|
// Image URLs are basically thumbnail URLs with a different domain, a simple
|
||||||
// path replacement, and a ?xxxxxx post ID at the end (obtainable from the href)
|
// path replacement, and a ?xxxxxx post ID at the end (obtainable from the href)
|
||||||
for (Element thumbSpan : doc.select("div.content > div > span.thumb")) {
|
for (Element thumbSpan : doc.select("div.content > div > span.thumb > a")) {
|
||||||
String postId = thumbSpan.attr("id").replaceAll("p", "");
|
String postLink = thumbSpan.attr("href");
|
||||||
Element thumb = thumbSpan.getElementsByTag("img").first();
|
try {
|
||||||
String image = thumb.attr("abs:src")
|
// Get the page the full sized image is on
|
||||||
.replace(".sankakucomplex.com/data/preview",
|
Document subPage = Http.url("https://chan.sankakucomplex.com" + postLink).get();
|
||||||
"s.sankakucomplex.com/data") + "?" + postId;
|
logger.info("Checking page " + "https://chan.sankakucomplex.com" + postLink);
|
||||||
imageURLs.add(image);
|
imageURLs.add("https:" + subPage.select("div[id=post-content] > a > img").attr("src"));
|
||||||
|
} catch (IOException e) {
|
||||||
|
logger.warn("Error while loading page " + postLink, e);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return imageURLs;
|
return imageURLs;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void downloadURL(URL url, int index) {
|
public void downloadURL(URL url, int index) {
|
||||||
// Mock up the URL of the post page based on the post ID at the end of the URL.
|
sleep(8000);
|
||||||
String postId = url.toExternalForm().replaceAll(".*\\?", "");
|
addURLToDownload(url, getPrefix(index));
|
||||||
addURLToDownload(url, postId + "_", "", "", null);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Document getNextPage(Document doc) throws IOException {
|
public Document getNextPage(Document doc) throws IOException {
|
||||||
Element pagination = doc.select("div.pagination").first();
|
Element pagination = doc.select("div.pagination").first();
|
||||||
if (pagination.hasAttr("next-page-url")) {
|
if (pagination.hasAttr("next-page-url")) {
|
||||||
return Http.url(pagination.attr("abs:next-page-url")).cookies(cookies).get();
|
String nextPage = pagination.attr("abs:next-page-url");
|
||||||
} else {
|
// Only logged in users can see past page 25
|
||||||
return null;
|
// Trying to rip page 26 will throw a no images found error
|
||||||
|
if (nextPage.contains("page=26") == false) {
|
||||||
|
logger.info("Getting next page: " + pagination.attr("abs:next-page-url"));
|
||||||
|
return Http.url(pagination.attr("abs:next-page-url")).cookies(cookies).get();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
throw new IOException("No more pages");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user