1
0
mirror of https://github.com/RipMeApp/ripme.git synced 2025-01-17 12:48:24 +01:00

new URI instead of new URL, mangadex, vk.

This commit is contained in:
soloturn 2023-12-09 15:29:56 +01:00
parent 879c322e7b
commit 8f279a68ec
4 changed files with 23 additions and 15 deletions

View File

@ -37,7 +37,7 @@ public abstract class AbstractJSONRipper extends AbstractRipper {
@Override
public abstract String getHost();
protected abstract JSONObject getFirstPage() throws IOException;
protected abstract JSONObject getFirstPage() throws IOException, URISyntaxException;
protected JSONObject getNextPage(JSONObject doc) throws IOException, URISyntaxException {
throw new IOException("getNextPage not implemented");
}
@ -62,7 +62,7 @@ public abstract class AbstractJSONRipper extends AbstractRipper {
}
@Override
public void rip() throws IOException {
public void rip() throws IOException, URISyntaxException {
int index = 0;
LOGGER.info("Retrieving " + this.url);
sendUpdate(STATUS.LOADING_RESOURCE, this.url.toExternalForm());

View File

@ -8,6 +8,8 @@ import org.json.JSONObject;
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
import java.util.ArrayList;
import java.util.HashMap;
@ -79,14 +81,14 @@ public class MangadexRipper extends AbstractJSONRipper {
@Override
public JSONObject getFirstPage() throws IOException {
public JSONObject getFirstPage() throws IOException, URISyntaxException {
// Get the chapter ID
String chapterID = getChapterID(url.toExternalForm());
String mangaID = getMangaID(url.toExternalForm());
if (mangaID != null) {
return Http.url(new URL(mangaApiEndPoint + mangaID)).getJSON();
return Http.url(new URI(mangaApiEndPoint + mangaID).toURL()).getJSON();
} else
return Http.url(new URL(chapterApiEndPoint + chapterID)).getJSON();
return Http.url(new URI(chapterApiEndPoint + chapterID).toURL()).getJSON();
}
@Override
@ -129,8 +131,8 @@ public class MangadexRipper extends AbstractJSONRipper {
for (Double aDouble : treeMap.keySet()) {
double key = (double) aDouble;
try {
chapterJSON = Http.url(new URL(chapterApiEndPoint + treeMap.get(key))).getJSON();
} catch (IOException e) {
chapterJSON = Http.url(new URI(chapterApiEndPoint + treeMap.get(key)).toURL()).getJSON();
} catch (IOException | URISyntaxException e) {
e.printStackTrace();
}
sendUpdate(RipStatusMessage.STATUS.LOADING_RESOURCE, "chapter " + key);

View File

@ -2,6 +2,8 @@ package com.rarchives.ripme.ripper.rippers;
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
import java.util.*;
import java.util.regex.Matcher;
@ -137,13 +139,13 @@ public class VkRipper extends AbstractJSONRipper {
}
@Override
public void rip() throws IOException {
public void rip() throws IOException, URISyntaxException {
if (this.url.toExternalForm().contains("/videos")) {
RIP_TYPE = RipType.VIDEO;
JSONObject json = getFirstPage();
List<String> URLs = getURLsFromJSON(json);
for (int index = 0; index < URLs.size(); index ++) {
downloadURL(new URL(URLs.get(index)), index);
downloadURL(new URI(URLs.get(index)).toURL(), index);
}
waitForThreads();
}

View File

@ -2,22 +2,26 @@ package com.rarchives.ripme.tst.ripper.rippers;
import com.rarchives.ripme.ripper.rippers.MangadexRipper;
import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.Test;
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
public class MangadexRipperTest extends RippersTest{
public class MangadexRipperTest extends RippersTest {
@Test
@Tag("flaky")
public void testRip() throws IOException, URISyntaxException {
MangadexRipper ripper = new MangadexRipper(new URI("https://mangadex.org/chapter/467904/").toURL());
testRipper(ripper);
}
public class testMangaRip extends RippersTest{
public void testRip() throws IOException, URISyntaxException {
MangadexRipper ripper = new MangadexRipper(new URI("https://mangadex.org/title/44625/this-croc-will-die-in-100-days").toURL());
testRipper(ripper);
}
@Test
@Tag("flaky")
public void test2() throws IOException, URISyntaxException {
MangadexRipper ripper = new MangadexRipper(new URI("https://mangadex.org/title/44625/this-croc-will-die-in-100-days").toURL());
testRipper(ripper);
}
}