mirror of
https://github.com/RipMeApp/ripme.git
synced 2025-09-03 02:42:47 +02:00
new URL(string) replaced with new URI(string).toURL(), as deprecated in java-20
This commit is contained in:
@@ -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.ArrayList;
|
||||
import java.util.HashMap;
|
||||
@@ -204,12 +206,12 @@ public class ListalRipper extends AbstractHTMLRipper {
|
||||
|
||||
String imageUrl = doc.getElementsByClass("pure-img").attr("src");
|
||||
if (imageUrl != "") {
|
||||
addURLToDownload(new URL(imageUrl), getPrefix(index), "", null, null,
|
||||
addURLToDownload(new URI(imageUrl).toURL(), getPrefix(index), "", null, null,
|
||||
getImageName());
|
||||
} else {
|
||||
LOGGER.error("Couldnt find image from url: " + url);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
} catch (IOException | URISyntaxException e) {
|
||||
LOGGER.error("[!] Exception while downloading image: " + url, e);
|
||||
}
|
||||
}
|
||||
|
@@ -100,7 +100,7 @@ public class History {
|
||||
|
||||
public void fromFile(String filename) throws IOException {
|
||||
try (InputStream is = new FileInputStream(filename)) {
|
||||
String jsonString = IOUtils.toString(is);
|
||||
String jsonString = IOUtils.toString(is, "UTF-8");
|
||||
JSONArray jsonArray = new JSONArray(jsonString);
|
||||
fromJSON(jsonArray);
|
||||
} catch (JSONException e) {
|
||||
@@ -134,7 +134,7 @@ public class History {
|
||||
|
||||
public void toFile(String filename) throws IOException {
|
||||
try (OutputStream os = new FileOutputStream(filename)) {
|
||||
IOUtils.write(toJSON().toString(2), os);
|
||||
IOUtils.write(toJSON().toString(2), os, "UTF-8");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -4,7 +4,8 @@ import com.rarchives.ripme.ripper.AbstractRipper;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
@@ -12,20 +13,20 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
public class AbstractRipperTest {
|
||||
|
||||
@Test
|
||||
public void testGetFileName() throws IOException {
|
||||
String fileName = AbstractRipper.getFileName(new URL("http://www.tsumino.com/Image/Object?name=U1EieteEGwm6N1dGszqCpA%3D%3D"),null, "test", "test");
|
||||
public void testGetFileName() throws IOException, URISyntaxException {
|
||||
String fileName = AbstractRipper.getFileName(new URI("http://www.tsumino.com/Image/Object?name=U1EieteEGwm6N1dGszqCpA%3D%3D").toURL(),null, "test", "test");
|
||||
assertEquals("test.test", fileName);
|
||||
|
||||
fileName = AbstractRipper.getFileName(new URL("http://www.tsumino.com/Image/Object?name=U1EieteEGwm6N1dGszqCpA%3D%3D"), null,"test", null);
|
||||
fileName = AbstractRipper.getFileName(new URI("http://www.tsumino.com/Image/Object?name=U1EieteEGwm6N1dGszqCpA%3D%3D").toURL(), null,"test", null);
|
||||
assertEquals("test", fileName);
|
||||
|
||||
fileName = AbstractRipper.getFileName(new URL("http://www.tsumino.com/Image/Object?name=U1EieteEGwm6N1dGszqCpA%3D%3D"), null,null, null);
|
||||
fileName = AbstractRipper.getFileName(new URI("http://www.tsumino.com/Image/Object?name=U1EieteEGwm6N1dGszqCpA%3D%3D").toURL(), null,null, null);
|
||||
assertEquals("Object", fileName);
|
||||
|
||||
fileName = AbstractRipper.getFileName(new URL("http://www.test.com/file.png"), null,null, null);
|
||||
fileName = AbstractRipper.getFileName(new URI("http://www.test.com/file.png").toURL(), null,null, null);
|
||||
assertEquals("file.png", fileName);
|
||||
|
||||
fileName = AbstractRipper.getFileName(new URL("http://www.test.com/file."), null,null, null);
|
||||
fileName = AbstractRipper.getFileName(new URI("http://www.test.com/file.").toURL(), null,null, null);
|
||||
assertEquals("file.", fileName);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user