mirror of
https://github.com/RipMeApp/ripme.git
synced 2025-04-22 12:42:02 +02:00
Fixed luscious ripper.
This commit is contained in:
parent
7a4f3b06b2
commit
273f698ad4
@ -19,7 +19,7 @@ import com.rarchives.ripme.utils.Http;
|
||||
public class LusciousRipper extends AbstractHTMLRipper {
|
||||
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");
|
||||
|
||||
public LusciousRipper(URL url) throws IOException {
|
||||
@ -69,7 +69,7 @@ public class LusciousRipper extends AbstractHTMLRipper {
|
||||
|
||||
@Override
|
||||
public String getGID(URL url) throws MalformedURLException {
|
||||
Matcher m = p.matcher(url.toExternalForm());
|
||||
Matcher m = P.matcher(url.toExternalForm());
|
||||
if (m.matches()) {
|
||||
return m.group(1);
|
||||
}
|
||||
@ -87,6 +87,40 @@ public class LusciousRipper extends AbstractHTMLRipper {
|
||||
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 {
|
||||
private URL url;
|
||||
private int index;
|
||||
|
@ -8,7 +8,7 @@ import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
public class LusciousRipperTest extends RippersTest {
|
||||
@Test @Disabled("Flaky in the CI")
|
||||
@Test
|
||||
public void testPahealRipper() throws IOException {
|
||||
// a photo set
|
||||
LusciousRipper ripper = new LusciousRipper(
|
||||
@ -16,12 +16,14 @@ public class LusciousRipperTest extends RippersTest {
|
||||
testRipper(ripper);
|
||||
}
|
||||
|
||||
@Test
|
||||
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/");
|
||||
LusciousRipper ripper = new LusciousRipper(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 {
|
||||
URL multiPageAlbumUrl = new URL("https://luscious.net/albums/women-of-color_58/");
|
||||
LusciousRipper multiPageRipper = new LusciousRipper(multiPageAlbumUrl);
|
||||
|
Loading…
x
Reference in New Issue
Block a user