1
0
mirror of https://github.com/RipMeApp/ripme.git synced 2025-08-21 05:01:30 +02:00

Fix not downloading if numOfImgs were on 2nd row

Also change website regex like I mentioned in a comment in #1360
This commit is contained in:
Edvin Boul
2019-07-02 09:31:23 +03:00
parent ddc331d022
commit a296ad4831

View File

@@ -35,11 +35,11 @@ public class MeituriRipper extends AbstractHTMLRipper {
@Override @Override
public String getGID(URL url) throws MalformedURLException { public String getGID(URL url) throws MalformedURLException {
// without escape // without escape
// ^https?://[w.]*meituri\.com/a/([0-9]+)/([0-9\.html]+)*$ // ^https?://[w.]*meituri\.com/a/([0-9]+)/([0-9]+\.html)*$
// https://www.meituri.com/a/14449/ // https://www.meituri.com/a/14449/
// also matches https://www.meituri.com/a/14449/3.html etc. // also matches https://www.meituri.com/a/14449/3.html etc.
// group 1 is 14449 // group 1 is 14449
Pattern p = Pattern.compile("^https?://[w.]*meituri\\.com/a/([0-9]+)/([0-9\\.html]+)*$"); Pattern p = Pattern.compile("^https?://[w.]*meituri\\.com/a/([0-9]+)/([0-9]+\\.html)*$");
Matcher m = p.matcher(url.toExternalForm()); Matcher m = p.matcher(url.toExternalForm());
if (m.matches()) { if (m.matches()) {
albumID = m.group(1); albumID = m.group(1);
@@ -59,27 +59,22 @@ public class MeituriRipper extends AbstractHTMLRipper {
List<String> imageURLs = new ArrayList<>(); List<String> imageURLs = new ArrayList<>();
// Get number of images from the page // Get number of images from the page
// Then generate links according to that // Then generate links according to that
String numOfImages = ""; int numOfImages = 1;
// A very ugly way of getting "图片数量: 55P" from paragraphs Pattern p = Pattern.compile("^<p>图片数量: ([0-9]+)P</p>$");
// 3rd p in div.tuji
int n = 0;
for (Element para : doc.select("div.tuji > p")) { for (Element para : doc.select("div.tuji > p")) {
// 图片数量: 55P // <p>图片数量: 55P</p>
if (n == 2) { Matcher m = p.matcher(para.toString());
numOfImages = para.toString(); if (m.matches()) {
// 55
numOfImages = Integer.parseInt(m.group(1));
} }
n++;
} }
// ["<p>图片数量:", "55P</p>"]
String[] splitNumOfImages = numOfImages.split(" ");
// "55P</p>" -> "55" -> 55
int actualNumOfImages = Integer.parseInt(splitNumOfImages[1].replace("P</p>", ""));
// Base URL: http://ii.hywly.com/a/1/albumid/imgnum.jpg // Base URL: http://ii.hywly.com/a/1/albumid/imgnum.jpg
String baseURL = "http://ii.hywly.com/a/1/" + albumID + "/"; String baseURL = "http://ii.hywly.com/a/1/" + albumID + "/";
// Loop through and add images to the URL list // Loop through and add images to the URL list
for (int i = 1; i <= actualNumOfImages; i++) { for (int i = 1; i <= numOfImages; i++) {
imageURLs.add(baseURL + i + ".jpg"); imageURLs.add(baseURL + i + ".jpg");
} }
return imageURLs; return imageURLs;