Merge pull request #29 from cyian-1756/eroshare_mirror

Eroshareripper now uses mirror for data
This commit is contained in:
metaprime 2017-08-10 03:10:12 -07:00 committed by GitHub
commit e07d60a4ce

View File

@ -51,22 +51,34 @@ public class EroShareRipper extends AbstractHTMLRipper {
} }
@Override @Override
public boolean canRip(URL url) { public boolean canRip(URL url) {
Pattern p = Pattern.compile("^https?://[w.]*eroshare.com/([a-zA-Z0-9\\-_]+)/?$"); Pattern p = Pattern.compile("^https?://eroshae.com/([a-zA-Z0-9\\-_]+)/?$");
Matcher m = p.matcher(url.toExternalForm()); Matcher m = p.matcher(url.toExternalForm());
if (m.matches()) { if (m.matches()) {
return true; return true;
} }
Pattern pa = Pattern.compile("^https?://[w.]*eroshare.com/u/([a-zA-Z0-9\\-_]+)/?$"); Pattern pa = Pattern.compile("^https?://eroshae.com/u/([a-zA-Z0-9\\-_]+)/?$");
Matcher ma = pa.matcher(url.toExternalForm()); Matcher ma = pa.matcher(url.toExternalForm());
if (ma.matches()) { if (ma.matches()) {
return true; return true;
} }
Pattern p_eroshare = Pattern.compile("^https?://eroshare.com/([a-zA-Z0-9\\-_]+)/?$");
Matcher m_eroshare = p_eroshare.matcher(url.toExternalForm());
if (m_eroshare.matches()) {
return true;
}
Pattern p_eroshare_profile = Pattern.compile("^https?://eroshare.com/u/([a-zA-Z0-9\\-_]+)/?$");
Matcher m_eroshare_profile = p_eroshare_profile.matcher(url.toExternalForm());
if (m_eroshare_profile.matches()) {
return true;
}
return false; return false;
} }
public boolean is_profile(URL url) { public boolean is_profile(URL url) {
Pattern pa = Pattern.compile("^https?://[w.]*eroshare.com/u/([a-zA-Z0-9\\-_]+)/?$"); Pattern pa = Pattern.compile("^https?://eroshae.com/u/([a-zA-Z0-9\\-_]+)/?$");
Matcher ma = pa.matcher(url.toExternalForm()); Matcher ma = pa.matcher(url.toExternalForm());
if (ma.matches()) { if (ma.matches()) {
return true; return true;
@ -79,12 +91,14 @@ public class EroShareRipper extends AbstractHTMLRipper {
// Find next page // Find next page
String nextUrl = ""; String nextUrl = "";
Element elem = doc.select("li.next > a").first(); Element elem = doc.select("li.next > a").first();
logger.info(elem); if (elem == null) {
throw new IOException("No more pages");
}
nextUrl = elem.attr("href"); nextUrl = elem.attr("href");
if (nextUrl == "") { if (nextUrl == "") {
throw new IOException("No more pages"); throw new IOException("No more pages");
} }
return Http.url("https://eroshare.com" + nextUrl).get(); return Http.url("eroshae.com" + nextUrl).get();
} }
@Override @Override
@ -124,7 +138,7 @@ public class EroShareRipper extends AbstractHTMLRipper {
if (vid.hasClass("album-video")) { if (vid.hasClass("album-video")) {
Elements source = vid.getElementsByTag("source"); Elements source = vid.getElementsByTag("source");
String videoURL = source.first().attr("src"); String videoURL = source.first().attr("src");
URLs.add(videoURL); URLs.add("https:" + videoURL);
} }
} }
// Profile videos // Profile videos
@ -132,7 +146,7 @@ public class EroShareRipper extends AbstractHTMLRipper {
for (Element link : links) { for (Element link : links) {
Document video_page; Document video_page;
try { try {
video_page = Http.url("https://eroshare.com" + link.attr("href")).get(); video_page = Http.url("eroshae.com" + link.attr("href")).get();
} catch (IOException e) { } catch (IOException e) {
logger.warn("Failed to log link in Jsoup"); logger.warn("Failed to log link in Jsoup");
video_page = null; video_page = null;
@ -143,7 +157,7 @@ public class EroShareRipper extends AbstractHTMLRipper {
if (vid.hasClass("album-video")) { if (vid.hasClass("album-video")) {
Elements source = vid.getElementsByTag("source"); Elements source = vid.getElementsByTag("source");
String videoURL = source.first().attr("src"); String videoURL = source.first().attr("src");
URLs.add(videoURL); URLs.add("https:" + videoURL);
} }
} }
} }
@ -153,7 +167,8 @@ public class EroShareRipper extends AbstractHTMLRipper {
@Override @Override
public Document getFirstPage() throws IOException { public Document getFirstPage() throws IOException {
Response resp = Http.url(this.url) String urlToDownload = this.url.toExternalForm();
Response resp = Http.url(urlToDownload.replace("eroshare.com", "eroshae.com"))
.ignoreContentType() .ignoreContentType()
.response(); .response();
@ -164,19 +179,31 @@ public class EroShareRipper extends AbstractHTMLRipper {
@Override @Override
public String getGID(URL url) throws MalformedURLException { public String getGID(URL url) throws MalformedURLException {
Pattern p = Pattern.compile("^https?://[w.]*eroshare.com/([a-zA-Z0-9\\-_]+)/?$"); Pattern p = Pattern.compile("^https?://eroshae.com/([a-zA-Z0-9\\-_]+)/?$");
Matcher m = p.matcher(url.toExternalForm()); Matcher m = p.matcher(url.toExternalForm());
if (m.matches()) { if (m.matches()) {
return m.group(1); return m.group(1);
} }
Pattern pa = Pattern.compile("^https?://[w.]*eroshare.com/u/([a-zA-Z0-9\\-_]+)/?$"); Pattern p_eroshare = Pattern.compile("^https?://eroshare.com/([a-zA-Z0-9\\-_]+)/?$");
Matcher m_eroshare = p_eroshare.matcher(url.toExternalForm());
if (m_eroshare.matches()) {
return m_eroshare.group(1);
}
Pattern p_eroshare_profile = Pattern.compile("^https?://eroshare.com/u/([a-zA-Z0-9\\-_]+)/?$");
Matcher m_eroshare_profile = p_eroshare_profile.matcher(url.toExternalForm());
if (m_eroshare_profile.matches()) {
return m_eroshare_profile.group(1) + "_profile";
}
Pattern pa = Pattern.compile("^https?://eroshae.com/u/([a-zA-Z0-9\\-_]+)/?$");
Matcher ma = pa.matcher(url.toExternalForm()); Matcher ma = pa.matcher(url.toExternalForm());
if (ma.matches()) { if (ma.matches()) {
return m.group(1) + "_profile"; return m.group(1) + "_profile";
} }
throw new MalformedURLException("eroshare album not found in " + url + ", expected https://eroshare.com/album"); throw new MalformedURLException("eroshare album not found in " + url + ", expected https://eroshare.com/album or eroshae.com/album");
} }
public static List<URL> getURLs(URL url) throws IOException{ public static List<URL> getURLs(URL url) throws IOException{
@ -203,11 +230,10 @@ public class EroShareRipper extends AbstractHTMLRipper {
if (vid.hasClass("album-video")) { if (vid.hasClass("album-video")) {
Elements source = vid.getElementsByTag("source"); Elements source = vid.getElementsByTag("source");
String videoURL = source.first().attr("src"); String videoURL = source.first().attr("src");
URLs.add(new URL(videoURL)); URLs.add(new URL("https:" + videoURL));
} }
} }
return URLs; return URLs;
} }
} }