Merge pull request #744 from cyian-1756/eromeFix
Fixed erome ripper and added quickQueue support
This commit is contained in:
commit
f8652ceaf7
@ -22,6 +22,8 @@ import com.rarchives.ripme.utils.Http;
|
|||||||
*/
|
*/
|
||||||
public class EromeRipper extends AbstractHTMLRipper {
|
public class EromeRipper extends AbstractHTMLRipper {
|
||||||
|
|
||||||
|
boolean rippingProfile;
|
||||||
|
|
||||||
|
|
||||||
public EromeRipper (URL url) throws IOException {
|
public EromeRipper (URL url) throws IOException {
|
||||||
super(url);
|
super(url);
|
||||||
@ -42,6 +44,27 @@ public class EromeRipper extends AbstractHTMLRipper {
|
|||||||
addURLToDownload(url, getPrefix(index));
|
addURLToDownload(url, getPrefix(index));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean hasQueueSupport() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean pageContainsAlbums(URL url) {
|
||||||
|
Pattern pa = Pattern.compile("https?://www.erome.com/([a-zA-Z0-9_-]*)/?");
|
||||||
|
Matcher ma = pa.matcher(url.toExternalForm());
|
||||||
|
return ma.matches();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<String> getAlbumsToQueue(Document doc) {
|
||||||
|
List<String> urlsToAddToQueue = new ArrayList<>();
|
||||||
|
for (Element elem : doc.select("div#albums > div.album > a")) {
|
||||||
|
urlsToAddToQueue.add(elem.attr("href"));
|
||||||
|
}
|
||||||
|
return urlsToAddToQueue;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getAlbumTitle(URL url) throws MalformedURLException {
|
public String getAlbumTitle(URL url) throws MalformedURLException {
|
||||||
try {
|
try {
|
||||||
@ -53,6 +76,8 @@ public class EromeRipper extends AbstractHTMLRipper {
|
|||||||
} 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) {
|
||||||
|
return getHost() + "_" + getGID(url);
|
||||||
}
|
}
|
||||||
return super.getAlbumTitle(url);
|
return super.getAlbumTitle(url);
|
||||||
}
|
}
|
||||||
@ -66,21 +91,7 @@ public class EromeRipper extends AbstractHTMLRipper {
|
|||||||
@Override
|
@Override
|
||||||
public List<String> getURLsFromPage(Document doc) {
|
public List<String> getURLsFromPage(Document doc) {
|
||||||
List<String> URLs = new ArrayList<>();
|
List<String> URLs = new ArrayList<>();
|
||||||
//Pictures
|
return getMediaFromPage(doc);
|
||||||
Elements imgs = doc.select("div.img > img.img-front");
|
|
||||||
for (Element img : imgs) {
|
|
||||||
String imageURL = img.attr("src");
|
|
||||||
imageURL = "https:" + imageURL;
|
|
||||||
URLs.add(imageURL);
|
|
||||||
}
|
|
||||||
//Videos
|
|
||||||
Elements vids = doc.select("div.video > video > source");
|
|
||||||
for (Element vid : vids) {
|
|
||||||
String videoURL = vid.attr("src");
|
|
||||||
URLs.add("https:" + videoURL);
|
|
||||||
}
|
|
||||||
|
|
||||||
return URLs;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -100,7 +111,7 @@ public class EromeRipper extends AbstractHTMLRipper {
|
|||||||
return m.group(1);
|
return m.group(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
p = Pattern.compile("^https?://erome.com/a/([a-zA-Z0-9]*)/?$");
|
p = Pattern.compile("^https?://www.erome.com/([a-zA-Z0-9_-]+)/?$");
|
||||||
m = p.matcher(url.toExternalForm());
|
m = p.matcher(url.toExternalForm());
|
||||||
|
|
||||||
if (m.matches()) {
|
if (m.matches()) {
|
||||||
@ -110,34 +121,15 @@ public class EromeRipper extends AbstractHTMLRipper {
|
|||||||
throw new MalformedURLException("erome album not found in " + url + ", expected https://www.erome.com/album");
|
throw new MalformedURLException("erome album not found in " + url + ", expected https://www.erome.com/album");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static List<URL> getURLs(URL url) throws IOException{
|
private List<String> getMediaFromPage(Document doc) {
|
||||||
|
List<String> results = new ArrayList<>();
|
||||||
Response resp = Http.url(url)
|
for (Element el : doc.select("img.img-front")) {
|
||||||
.ignoreContentType()
|
results.add("https:" + el.attr("src"));
|
||||||
.response();
|
|
||||||
|
|
||||||
Document doc = resp.parse();
|
|
||||||
|
|
||||||
List<URL> URLs = new ArrayList<>();
|
|
||||||
//Pictures
|
|
||||||
Elements imgs = doc.getElementsByTag("img");
|
|
||||||
for (Element img : imgs) {
|
|
||||||
if (img.hasClass("album-image")) {
|
|
||||||
String imageURL = img.attr("src");
|
|
||||||
imageURL = "https:" + imageURL;
|
|
||||||
URLs.add(new URL(imageURL));
|
|
||||||
}
|
}
|
||||||
|
for (Element el : doc.select("source[label=HD]")) {
|
||||||
|
results.add("https:" + el.attr("src"));
|
||||||
}
|
}
|
||||||
//Videos
|
return results;
|
||||||
Elements vids = doc.getElementsByTag("video");
|
|
||||||
for (Element vid : vids) {
|
|
||||||
if (vid.hasClass("album-video")) {
|
|
||||||
Elements source = vid.getElementsByTag("source");
|
|
||||||
String videoURL = source.first().attr("src");
|
|
||||||
URLs.add(new URL(videoURL));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return URLs;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,40 @@
|
|||||||
|
package com.rarchives.ripme.tst.ripper.rippers;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.net.URL;
|
||||||
|
|
||||||
|
import com.rarchives.ripme.ripper.rippers.EromeRipper;
|
||||||
|
|
||||||
|
public class EromeRipperTest extends RippersTest {
|
||||||
|
|
||||||
|
public void testGetGIDProfilePage() throws IOException {
|
||||||
|
URL url = new URL("https://www.erome.com/Jay-Jenna");
|
||||||
|
EromeRipper ripper = new EromeRipper(url);
|
||||||
|
assertEquals("Jay-Jenna", ripper.getGID(url));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testGetGIDAlbum() throws IOException {
|
||||||
|
URL url = new URL("https://www.erome.com/a/KbDAM1XT");
|
||||||
|
EromeRipper ripper = new EromeRipper(url);
|
||||||
|
assertEquals("KbDAM1XT", ripper.getGID(url));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testGetAlbumsToQueue() throws IOException {
|
||||||
|
URL url = new URL("https://www.erome.com/Jay-Jenna");
|
||||||
|
EromeRipper ripper = new EromeRipper(url);
|
||||||
|
assert(2 >= ripper.getAlbumsToQueue(ripper.getFirstPage()).size());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testPageContainsAlbums() throws IOException {
|
||||||
|
URL url = new URL("https://www.erome.com/Jay-Jenna");
|
||||||
|
EromeRipper ripper = new EromeRipper(url);
|
||||||
|
assert(ripper.pageContainsAlbums(url));
|
||||||
|
assert(!ripper.pageContainsAlbums(new URL("https://www.erome.com/a/KbDAM1XT")));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testRip() throws IOException {
|
||||||
|
URL url = new URL("https://www.erome.com/a/4FqeUxil");
|
||||||
|
EromeRipper ripper = new EromeRipper(url);
|
||||||
|
testRipper(ripper);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user