mirror of
https://github.com/RipMeApp/ripme.git
synced 2025-04-20 20:01:51 +02:00
Fix BatoRipper: update to new site code (Fix #2095)
This commit is contained in:
parent
f4ea0fee3e
commit
f2c9974265
@ -11,7 +11,7 @@ import java.util.regex.Pattern;
|
||||
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.json.JSONObject;
|
||||
import org.json.JSONArray;
|
||||
import org.jsoup.nodes.Document;
|
||||
import org.jsoup.nodes.Element;
|
||||
|
||||
@ -98,25 +98,34 @@ public class BatoRipper extends AbstractHTMLRipper {
|
||||
return m.matches();
|
||||
}
|
||||
|
||||
public String scanForImageList(Pattern p, String scriptData) {
|
||||
for (String line : scriptData.split("\n")) {
|
||||
Matcher m = p.matcher(line.strip());
|
||||
if (m.matches()) {
|
||||
return m.group(1);
|
||||
}
|
||||
}
|
||||
return "[]";
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getURLsFromPage(Document doc) {
|
||||
List<String> result = new ArrayList<>();
|
||||
for (Element script : doc.select("script")) {
|
||||
if (script.data().contains("var images = ")) {
|
||||
if (script.data().contains("imgHttps")) {
|
||||
String s = script.data();
|
||||
s = s.replaceAll("var seriesId = \\d+;", "");
|
||||
s = s.replaceAll("var chapterId = \\d+;", "");
|
||||
s = s.replaceAll("var pages = \\d+;", "");
|
||||
s = s.replaceAll("var page = \\d+;", "");
|
||||
s = s.replaceAll("var prevCha = null;", "");
|
||||
s = s.replaceAll("var nextCha = \\.*;", "");
|
||||
String json = s.replaceAll("var images = ", "").replaceAll(";", "");
|
||||
JSONObject images = new JSONObject(json);
|
||||
for (int i = 1; i < images.length() +1; i++) {
|
||||
result.add(images.getString(Integer.toString(i)));
|
||||
}
|
||||
logger.info("Script data: " + s);
|
||||
|
||||
Pattern p = Pattern.compile(".*imgHttps = (\\[\"[^\\];]*\"\\]);.*");
|
||||
Matcher m = p.matcher(s);
|
||||
String json = scanForImageList(p, s);
|
||||
|
||||
logger.info("JSON: " + json);
|
||||
|
||||
JSONArray images = new JSONArray(json);
|
||||
for (int i = 0; i < images.length(); i++) {
|
||||
result.add(images.getString(i));
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
@ -124,6 +133,7 @@ public class BatoRipper extends AbstractHTMLRipper {
|
||||
|
||||
@Override
|
||||
public void downloadURL(URL url, int index) {
|
||||
sleep(500);
|
||||
addURLToDownload(url, getPrefix(index));
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user