mirror of
https://github.com/RipMeApp/ripme.git
synced 2025-08-22 05:23:06 +02:00
Fix #1830
+ add config option "erome.laravel_session" for EromeRipper to avoid JS-Browser-Check
This commit is contained in:
@@ -4,10 +4,12 @@ import java.io.IOException;
|
|||||||
import java.net.MalformedURLException;
|
import java.net.MalformedURLException;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
|
import com.rarchives.ripme.utils.Utils;
|
||||||
import org.jsoup.Connection.Response;
|
import org.jsoup.Connection.Response;
|
||||||
import org.jsoup.nodes.Document;
|
import org.jsoup.nodes.Document;
|
||||||
import org.jsoup.nodes.Element;
|
import org.jsoup.nodes.Element;
|
||||||
@@ -23,7 +25,7 @@ import com.rarchives.ripme.utils.Http;
|
|||||||
public class EromeRipper extends AbstractHTMLRipper {
|
public class EromeRipper extends AbstractHTMLRipper {
|
||||||
|
|
||||||
boolean rippingProfile;
|
boolean rippingProfile;
|
||||||
|
private HashMap<String, String> cookies = new HashMap<>();
|
||||||
|
|
||||||
public EromeRipper (URL url) throws IOException {
|
public EromeRipper (URL url) throws IOException {
|
||||||
super(url);
|
super(url);
|
||||||
@@ -31,12 +33,12 @@ public class EromeRipper extends AbstractHTMLRipper {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getDomain() {
|
public String getDomain() {
|
||||||
return "erome.com";
|
return "erome.com";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getHost() {
|
public String getHost() {
|
||||||
return "erome";
|
return "erome";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -67,19 +69,19 @@ public class EromeRipper extends AbstractHTMLRipper {
|
|||||||
|
|
||||||
@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
|
// Attempt to use album title as GID
|
||||||
Element titleElement = getFirstPage().select("meta[property=og:title]").first();
|
Element titleElement = getFirstPage().select("meta[property=og:title]").first();
|
||||||
String title = titleElement.attr("content");
|
String title = titleElement.attr("content");
|
||||||
title = title.substring(title.lastIndexOf('/') + 1);
|
title = title.substring(title.lastIndexOf('/') + 1);
|
||||||
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
|
||||||
LOGGER.info("Unable to find title at " + url);
|
LOGGER.info("Unable to find title at " + url);
|
||||||
} catch (NullPointerException e) {
|
} catch (NullPointerException e) {
|
||||||
return getHost() + "_" + getGID(url);
|
return getHost() + "_" + getGID(url);
|
||||||
}
|
}
|
||||||
return super.getAlbumTitle(url);
|
return super.getAlbumTitle(url);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -96,9 +98,11 @@ public class EromeRipper extends AbstractHTMLRipper {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Document getFirstPage() throws IOException {
|
public Document getFirstPage() throws IOException {
|
||||||
|
this.setAuthCookie();
|
||||||
Response resp = Http.url(this.url)
|
Response resp = Http.url(this.url)
|
||||||
.ignoreContentType()
|
.cookies(cookies)
|
||||||
.response();
|
.ignoreContentType()
|
||||||
|
.response();
|
||||||
|
|
||||||
return resp.parse();
|
return resp.parse();
|
||||||
}
|
}
|
||||||
@@ -124,18 +128,18 @@ public class EromeRipper extends AbstractHTMLRipper {
|
|||||||
private List<String> getMediaFromPage(Document doc) {
|
private List<String> getMediaFromPage(Document doc) {
|
||||||
List<String> results = new ArrayList<>();
|
List<String> results = new ArrayList<>();
|
||||||
for (Element el : doc.select("img.img-front")) {
|
for (Element el : doc.select("img.img-front")) {
|
||||||
if (el.hasAttr("src")) {
|
if (el.hasAttr("src")) {
|
||||||
if (el.attr("src").startsWith("https:")) {
|
if (el.attr("src").startsWith("https:")) {
|
||||||
results.add(el.attr("src"));
|
results.add(el.attr("src"));
|
||||||
} else {
|
} else {
|
||||||
results.add("https:" + el.attr("src"));
|
results.add("https:" + el.attr("src"));
|
||||||
}
|
}
|
||||||
} else if (el.hasAttr("data-src")) {
|
} else if (el.hasAttr("data-src")) {
|
||||||
//to add images that are not loaded( as all images are lasyloaded as we scroll).
|
//to add images that are not loaded( as all images are lasyloaded as we scroll).
|
||||||
results.add(el.attr("data-src"));
|
results.add(el.attr("data-src"));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
for (Element el : doc.select("source[label=HD]")) {
|
for (Element el : doc.select("source[label=HD]")) {
|
||||||
if (el.attr("src").startsWith("https:")) {
|
if (el.attr("src").startsWith("https:")) {
|
||||||
results.add(el.attr("src"));
|
results.add(el.attr("src"));
|
||||||
@@ -152,7 +156,22 @@ public class EromeRipper extends AbstractHTMLRipper {
|
|||||||
results.add("https:" + el.attr("src"));
|
results.add("https:" + el.attr("src"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (results.size() == 0) {
|
||||||
|
if (cookies.isEmpty()) {
|
||||||
|
LOGGER.warn("You might try setting erome.laravel_session manually " +
|
||||||
|
"if you think this page definitely contains media.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return results;
|
return results;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void setAuthCookie() {
|
||||||
|
String sessionId = Utils.getConfigString("erome.laravel_session", null);
|
||||||
|
if (sessionId != null) {
|
||||||
|
cookies.put("laravel_session", sessionId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user