From 141478213cef1e645d486035eadb19fbd3fcfb29 Mon Sep 17 00:00:00 2001 From: cyian-1756 Date: Sun, 19 Mar 2017 19:50:29 -0400 Subject: [PATCH] eroshare ripper now grabs album name --- .../ripme/ripper/rippers/EroShareRipper.java | 38 +++++++++++++------ 1 file changed, 27 insertions(+), 11 deletions(-) diff --git a/src/main/java/com/rarchives/ripme/ripper/rippers/EroShareRipper.java b/src/main/java/com/rarchives/ripme/ripper/rippers/EroShareRipper.java index 058a368c..97ab2815 100644 --- a/src/main/java/com/rarchives/ripme/ripper/rippers/EroShareRipper.java +++ b/src/main/java/com/rarchives/ripme/ripper/rippers/EroShareRipper.java @@ -29,11 +29,11 @@ import com.rarchives.ripme.utils.Http; * @author losipher */ public class EroShareRipper extends AbstractHTMLRipper { - + public EroShareRipper (URL url) throws IOException { super(url); } - + @Override public String getDomain() { return "eroshare.com"; @@ -43,12 +43,28 @@ public class EroShareRipper extends AbstractHTMLRipper { public String getHost() { return "eroshare"; } - + @Override public void downloadURL(URL url, int index){ addURLToDownload(url); } - + + @Override + public String getAlbumTitle(URL url) throws MalformedURLException { + try { + // Attempt to use album title as GID + Element titleElement = getFirstPage().select("meta[property=og:title]").first(); + String title = titleElement.attr("content"); + title = title.substring(title.lastIndexOf('/') + 1); + return getHost() + "_" + getGID(url) + "_" + title.trim(); + } catch (IOException e) { + // Fall back to default album naming convention + logger.info("Unable to find title at " + url); + } + return super.getAlbumTitle(url); + } + + @Override public List getURLsFromPage(Document doc){ List URLs = new ArrayList(); @@ -70,10 +86,10 @@ public class EroShareRipper extends AbstractHTMLRipper { URLs.add(videoURL); } } - + return URLs; } - + @Override public Document getFirstPage() throws IOException { Response resp = Http.url(this.url) @@ -81,10 +97,10 @@ public class EroShareRipper extends AbstractHTMLRipper { .response(); Document doc = resp.parse(); - + return doc; } - + @Override public String getGID(URL url) throws MalformedURLException { Pattern p = Pattern.compile("^https?://[w.]*eroshare.com/([a-zA-Z0-9\\-_]+)/?$"); @@ -94,9 +110,9 @@ public class EroShareRipper extends AbstractHTMLRipper { } throw new MalformedURLException("eroshare album not found in " + url + ", expected https://eroshare.com/album"); } - + public static List getURLs(URL url) throws IOException{ - + Response resp = Http.url(url) .ignoreContentType() .response(); @@ -122,7 +138,7 @@ public class EroShareRipper extends AbstractHTMLRipper { URLs.add(new URL(videoURL)); } } - + return URLs; } }