mirror of
https://github.com/RipMeApp/ripme.git
synced 2025-08-05 13:27:40 +02:00
Fixed luscious ripper.
This commit is contained in:
@@ -19,7 +19,7 @@ import com.rarchives.ripme.utils.Http;
|
|||||||
public class LusciousRipper extends AbstractHTMLRipper {
|
public class LusciousRipper extends AbstractHTMLRipper {
|
||||||
private static final int RETRY_COUNT = 5; // Keeping it high for read timeout exception.
|
private static final int RETRY_COUNT = 5; // Keeping it high for read timeout exception.
|
||||||
|
|
||||||
private Pattern p = Pattern.compile("^https?://(?:members.)?luscious\\.net/albums/([-_.0-9a-zA-Z]+).*$");
|
private static final Pattern P = Pattern.compile("^https?:\\/\\/(?:members\\.|old\\.|www\\.)?luscious.net\\/albums\\/([-_.0-9a-zA-Z]+)\\/?");
|
||||||
private DownloadThreadPool lusciousThreadPool = new DownloadThreadPool("lusciousThreadPool");
|
private DownloadThreadPool lusciousThreadPool = new DownloadThreadPool("lusciousThreadPool");
|
||||||
|
|
||||||
public LusciousRipper(URL url) throws IOException {
|
public LusciousRipper(URL url) throws IOException {
|
||||||
@@ -69,7 +69,7 @@ public class LusciousRipper extends AbstractHTMLRipper {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getGID(URL url) throws MalformedURLException {
|
public String getGID(URL url) throws MalformedURLException {
|
||||||
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);
|
||||||
}
|
}
|
||||||
@@ -87,6 +87,40 @@ public class LusciousRipper extends AbstractHTMLRipper {
|
|||||||
return lusciousThreadPool;
|
return lusciousThreadPool;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public URL sanitizeURL(URL url) throws MalformedURLException {
|
||||||
|
// Sanitizes the url removing GET parameters and convert to old api url.
|
||||||
|
// "https://old.luscious.net/albums/albumname"
|
||||||
|
try {
|
||||||
|
Matcher m = P.matcher(url.toString());
|
||||||
|
if (m.matches()) {
|
||||||
|
String sanitizedUrl = m.group();
|
||||||
|
sanitizedUrl = sanitizedUrl.replaceFirst(
|
||||||
|
"^https?:\\/\\/(?:members\\.|old\\.|www\\.)?luscious.net",
|
||||||
|
"https://old.luscious.net");
|
||||||
|
return new URL(sanitizedUrl);
|
||||||
|
}
|
||||||
|
|
||||||
|
throw new Exception("ERROR: Unable to sanitize url.");
|
||||||
|
} catch (Exception e) {
|
||||||
|
LOGGER.info("Error sanitizing the url.");
|
||||||
|
LOGGER.error(e);
|
||||||
|
return super.sanitizeURL(url);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String normalizeUrl(String url) {
|
||||||
|
try {
|
||||||
|
return url.toString().replaceFirst(
|
||||||
|
"^https?:\\/\\/(?:members\\.|old\\.)?luscious.net", "https://www.luscious.net");
|
||||||
|
} catch (Exception e) {
|
||||||
|
LOGGER.info("Error normalizing the url.");
|
||||||
|
LOGGER.error(e);
|
||||||
|
return super.normalizeUrl(url);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public class LusciousDownloadThread extends Thread {
|
public class LusciousDownloadThread extends Thread {
|
||||||
private URL url;
|
private URL url;
|
||||||
private int index;
|
private int index;
|
||||||
|
@@ -8,7 +8,7 @@ import org.junit.jupiter.api.Disabled;
|
|||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
public class LusciousRipperTest extends RippersTest {
|
public class LusciousRipperTest extends RippersTest {
|
||||||
@Test @Disabled("Flaky in the CI")
|
@Test
|
||||||
public void testPahealRipper() throws IOException {
|
public void testPahealRipper() throws IOException {
|
||||||
// a photo set
|
// a photo set
|
||||||
LusciousRipper ripper = new LusciousRipper(
|
LusciousRipper ripper = new LusciousRipper(
|
||||||
@@ -16,12 +16,14 @@ public class LusciousRipperTest extends RippersTest {
|
|||||||
testRipper(ripper);
|
testRipper(ripper);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
public void testGetGID() throws IOException {
|
public void testGetGID() throws IOException {
|
||||||
URL url = new URL("https://luscious.net/albums/h-na-alice-wa-suki-desu-ka-do-you-like-alice-when_321609/");
|
URL url = new URL("https://luscious.net/albums/h-na-alice-wa-suki-desu-ka-do-you-like-alice-when_321609/");
|
||||||
LusciousRipper ripper = new LusciousRipper(url);
|
LusciousRipper ripper = new LusciousRipper(url);
|
||||||
assertEquals("h-na-alice-wa-suki-desu-ka-do-you-like-alice-when_321609", ripper.getGID(url));
|
assertEquals("h-na-alice-wa-suki-desu-ka-do-you-like-alice-when_321609", ripper.getGID(url));
|
||||||
}
|
}
|
||||||
@Test @Disabled("Flaky in the CI")
|
|
||||||
|
@Test
|
||||||
public void testGetNextPage() throws IOException {
|
public void testGetNextPage() throws IOException {
|
||||||
URL multiPageAlbumUrl = new URL("https://luscious.net/albums/women-of-color_58/");
|
URL multiPageAlbumUrl = new URL("https://luscious.net/albums/women-of-color_58/");
|
||||||
LusciousRipper multiPageRipper = new LusciousRipper(multiPageAlbumUrl);
|
LusciousRipper multiPageRipper = new LusciousRipper(multiPageAlbumUrl);
|
||||||
|
Reference in New Issue
Block a user