Skip to content

Commit

Permalink
new URI instead of new URL, mangadex.
Browse files Browse the repository at this point in the history
  • Loading branch information
soloturn committed Dec 9, 2023
1 parent 879c322 commit 7aa7989
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ protected AbstractJSONRipper(URL url) throws IOException {
@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");
}
Expand All @@ -62,7 +62,7 @@ public URL sanitizeURL(URL url) throws MalformedURLException, URISyntaxException
}

@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());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

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;
Expand Down Expand Up @@ -79,14 +81,14 @@ private String getMangaID(String url) {


@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
Expand Down Expand Up @@ -129,8 +131,8 @@ protected List<String> getURLsFromJSON(JSONObject json) {
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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URISyntaxException;
import java.net.URL;
import java.util.*;
import java.util.regex.Matcher;
Expand Down Expand Up @@ -137,7 +138,7 @@ public URL sanitizeURL(URL url) throws MalformedURLException {
}

@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();
Expand Down

0 comments on commit 7aa7989

Please sign in to comment.