Merge pull request #486 from cyian-1756/eroshare

eroshare ripper now grabs album name

Fixes #460
This commit is contained in:
metaprime 2017-03-23 01:17:38 -07:00 committed by GitHub
commit a3d8e87639

View File

@ -29,11 +29,11 @@ import com.rarchives.ripme.utils.Http;
* @author losipher * @author losipher
*/ */
public class EroShareRipper extends AbstractHTMLRipper { public class EroShareRipper extends AbstractHTMLRipper {
public EroShareRipper (URL url) throws IOException { public EroShareRipper (URL url) throws IOException {
super(url); super(url);
} }
@Override @Override
public String getDomain() { public String getDomain() {
return "eroshare.com"; return "eroshare.com";
@ -43,12 +43,28 @@ public class EroShareRipper extends AbstractHTMLRipper {
public String getHost() { public String getHost() {
return "eroshare"; return "eroshare";
} }
@Override @Override
public void downloadURL(URL url, int index){ public void downloadURL(URL url, int index){
addURLToDownload(url); 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 @Override
public List<String> getURLsFromPage(Document doc){ public List<String> getURLsFromPage(Document doc){
List<String> URLs = new ArrayList<String>(); List<String> URLs = new ArrayList<String>();
@ -70,10 +86,10 @@ public class EroShareRipper extends AbstractHTMLRipper {
URLs.add(videoURL); URLs.add(videoURL);
} }
} }
return URLs; return URLs;
} }
@Override @Override
public Document getFirstPage() throws IOException { public Document getFirstPage() throws IOException {
Response resp = Http.url(this.url) Response resp = Http.url(this.url)
@ -81,10 +97,10 @@ public class EroShareRipper extends AbstractHTMLRipper {
.response(); .response();
Document doc = resp.parse(); Document doc = resp.parse();
return doc; return doc;
} }
@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?://[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"); throw new MalformedURLException("eroshare album not found in " + url + ", expected https://eroshare.com/album");
} }
public static List<URL> getURLs(URL url) throws IOException{ public static List<URL> getURLs(URL url) throws IOException{
Response resp = Http.url(url) Response resp = Http.url(url)
.ignoreContentType() .ignoreContentType()
.response(); .response();
@ -122,7 +138,7 @@ public class EroShareRipper extends AbstractHTMLRipper {
URLs.add(new URL(videoURL)); URLs.add(new URL(videoURL));
} }
} }
return URLs; return URLs;
} }
} }