mirror of
https://github.com/RipMeApp/ripme.git
synced 2025-08-11 00:14:12 +02:00
new URI instead of new URL, mangadex, vk.
This commit is contained in:
@@ -37,7 +37,7 @@ public abstract class AbstractJSONRipper extends AbstractRipper {
|
|||||||
@Override
|
@Override
|
||||||
public abstract String getHost();
|
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 {
|
protected JSONObject getNextPage(JSONObject doc) throws IOException, URISyntaxException {
|
||||||
throw new IOException("getNextPage not implemented");
|
throw new IOException("getNextPage not implemented");
|
||||||
}
|
}
|
||||||
@@ -62,7 +62,7 @@ public abstract class AbstractJSONRipper extends AbstractRipper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void rip() throws IOException {
|
public void rip() throws IOException, URISyntaxException {
|
||||||
int index = 0;
|
int index = 0;
|
||||||
LOGGER.info("Retrieving " + this.url);
|
LOGGER.info("Retrieving " + this.url);
|
||||||
sendUpdate(STATUS.LOADING_RESOURCE, this.url.toExternalForm());
|
sendUpdate(STATUS.LOADING_RESOURCE, this.url.toExternalForm());
|
||||||
|
@@ -8,6 +8,8 @@ import org.json.JSONObject;
|
|||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.MalformedURLException;
|
import java.net.MalformedURLException;
|
||||||
|
import java.net.URI;
|
||||||
|
import java.net.URISyntaxException;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
@@ -79,14 +81,14 @@ public class MangadexRipper extends AbstractJSONRipper {
|
|||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public JSONObject getFirstPage() throws IOException {
|
public JSONObject getFirstPage() throws IOException, URISyntaxException {
|
||||||
// Get the chapter ID
|
// Get the chapter ID
|
||||||
String chapterID = getChapterID(url.toExternalForm());
|
String chapterID = getChapterID(url.toExternalForm());
|
||||||
String mangaID = getMangaID(url.toExternalForm());
|
String mangaID = getMangaID(url.toExternalForm());
|
||||||
if (mangaID != null) {
|
if (mangaID != null) {
|
||||||
return Http.url(new URL(mangaApiEndPoint + mangaID)).getJSON();
|
return Http.url(new URI(mangaApiEndPoint + mangaID).toURL()).getJSON();
|
||||||
} else
|
} else
|
||||||
return Http.url(new URL(chapterApiEndPoint + chapterID)).getJSON();
|
return Http.url(new URI(chapterApiEndPoint + chapterID).toURL()).getJSON();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -129,8 +131,8 @@ public class MangadexRipper extends AbstractJSONRipper {
|
|||||||
for (Double aDouble : treeMap.keySet()) {
|
for (Double aDouble : treeMap.keySet()) {
|
||||||
double key = (double) aDouble;
|
double key = (double) aDouble;
|
||||||
try {
|
try {
|
||||||
chapterJSON = Http.url(new URL(chapterApiEndPoint + treeMap.get(key))).getJSON();
|
chapterJSON = Http.url(new URI(chapterApiEndPoint + treeMap.get(key)).toURL()).getJSON();
|
||||||
} catch (IOException e) {
|
} catch (IOException | URISyntaxException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
sendUpdate(RipStatusMessage.STATUS.LOADING_RESOURCE, "chapter " + key);
|
sendUpdate(RipStatusMessage.STATUS.LOADING_RESOURCE, "chapter " + key);
|
||||||
|
@@ -2,6 +2,8 @@ package com.rarchives.ripme.ripper.rippers;
|
|||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.MalformedURLException;
|
import java.net.MalformedURLException;
|
||||||
|
import java.net.URI;
|
||||||
|
import java.net.URISyntaxException;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
@@ -137,13 +139,13 @@ public class VkRipper extends AbstractJSONRipper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void rip() throws IOException {
|
public void rip() throws IOException, URISyntaxException {
|
||||||
if (this.url.toExternalForm().contains("/videos")) {
|
if (this.url.toExternalForm().contains("/videos")) {
|
||||||
RIP_TYPE = RipType.VIDEO;
|
RIP_TYPE = RipType.VIDEO;
|
||||||
JSONObject json = getFirstPage();
|
JSONObject json = getFirstPage();
|
||||||
List<String> URLs = getURLsFromJSON(json);
|
List<String> URLs = getURLsFromJSON(json);
|
||||||
for (int index = 0; index < URLs.size(); index ++) {
|
for (int index = 0; index < URLs.size(); index ++) {
|
||||||
downloadURL(new URL(URLs.get(index)), index);
|
downloadURL(new URI(URLs.get(index)).toURL(), index);
|
||||||
}
|
}
|
||||||
waitForThreads();
|
waitForThreads();
|
||||||
}
|
}
|
||||||
|
@@ -2,22 +2,26 @@ package com.rarchives.ripme.tst.ripper.rippers;
|
|||||||
|
|
||||||
|
|
||||||
import com.rarchives.ripme.ripper.rippers.MangadexRipper;
|
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.io.IOException;
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
import java.net.URISyntaxException;
|
import java.net.URISyntaxException;
|
||||||
|
|
||||||
public class MangadexRipperTest extends RippersTest{
|
public class MangadexRipperTest extends RippersTest {
|
||||||
|
@Test
|
||||||
|
@Tag("flaky")
|
||||||
public void testRip() throws IOException, URISyntaxException {
|
public void testRip() throws IOException, URISyntaxException {
|
||||||
MangadexRipper ripper = new MangadexRipper(new URI("https://mangadex.org/chapter/467904/").toURL());
|
MangadexRipper ripper = new MangadexRipper(new URI("https://mangadex.org/chapter/467904/").toURL());
|
||||||
testRipper(ripper);
|
testRipper(ripper);
|
||||||
}
|
}
|
||||||
public class testMangaRip extends RippersTest{
|
|
||||||
|
|
||||||
public void testRip() throws IOException, URISyntaxException {
|
@Test
|
||||||
MangadexRipper ripper = new MangadexRipper(new URI("https://mangadex.org/title/44625/this-croc-will-die-in-100-days").toURL());
|
@Tag("flaky")
|
||||||
testRipper(ripper);
|
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user