More improvements for unit tests
This commit is contained in:
parent
c524d20ccb
commit
9967332057
@ -2,7 +2,6 @@ package com.rarchives.ripme.ripper.rippers;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.SocketTimeoutException;
|
||||
import java.net.URL;
|
||||
import java.util.List;
|
||||
import java.util.regex.Matcher;
|
||||
@ -59,7 +58,7 @@ public class RedditRipper extends AlbumRipper {
|
||||
URL jsonURL = getJsonURL(this.url);
|
||||
while (true) {
|
||||
jsonURL = getAndParseAndReturnNext(jsonURL);
|
||||
if (jsonURL == null) {
|
||||
if (jsonURL == null || isThisATest() || isStopped()) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -119,20 +118,10 @@ public class RedditRipper extends AlbumRipper {
|
||||
}
|
||||
lastRequestTime = System.currentTimeMillis();
|
||||
|
||||
int attempts = 0;
|
||||
logger.info(" Retrieving " + url);
|
||||
String jsonString = null;
|
||||
while(jsonString == null && attempts++ < 3) {
|
||||
try {
|
||||
jsonString = Http.url(url)
|
||||
.ignoreContentType()
|
||||
.response()
|
||||
.body();
|
||||
} catch(SocketTimeoutException ex) {
|
||||
if(attempts >= 3) throw ex;
|
||||
logger.warn(String.format("[!] Connection timed out (attempt %d)", attempts));
|
||||
}
|
||||
}
|
||||
String jsonString = Http.url(url)
|
||||
.ignoreContentType()
|
||||
.response()
|
||||
.body();
|
||||
|
||||
Object jsonObj = new JSONTokener(jsonString).nextValue();
|
||||
JSONArray jsonArray = new JSONArray();
|
||||
|
@ -52,16 +52,16 @@ public class SeeniveRipper extends AlbumRipper {
|
||||
}
|
||||
String lastID = null;
|
||||
for (Element element : doc.select("a.facebox")) {
|
||||
if (isStopped()) {
|
||||
break;
|
||||
}
|
||||
String card = element.attr("href"); // "/v/<video_id>"
|
||||
URL videoURL = new URL("http://seenive.com" + card);
|
||||
SeeniveImageThread vit = new SeeniveImageThread(videoURL);
|
||||
seeniveThreadPool.addThread(vit);
|
||||
lastID = card.substring(card.lastIndexOf('/') + 1);
|
||||
if (isStopped() || isThisATest()) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (lastID == null) {
|
||||
if (lastID == null || isStopped() || isThisATest()) {
|
||||
break;
|
||||
}
|
||||
|
||||
@ -74,8 +74,8 @@ public class SeeniveRipper extends AlbumRipper {
|
||||
|
||||
logger.info("[ ] Retrieving " + baseURL + "/next/" + lastID);
|
||||
JSONObject json = Http.url(baseURL + "/next/" + lastID)
|
||||
.referrer(baseURL)
|
||||
.getJSON();
|
||||
.referrer(baseURL)
|
||||
.getJSON();
|
||||
String html = json.getString("Html");
|
||||
if (html.equals("")) {
|
||||
break;
|
||||
@ -116,7 +116,7 @@ public class SeeniveRipper extends AlbumRipper {
|
||||
public void run() {
|
||||
try {
|
||||
Document doc = Http.url(this.url).get();
|
||||
logger.info("[ ] Retreiving video page " + this.url);
|
||||
logger.info("[ ] Retrieving video page " + this.url);
|
||||
sendUpdate(STATUS.LOADING_RESOURCE, this.url.toExternalForm());
|
||||
for (Element element : doc.select("source")) {
|
||||
String video = element.attr("src");
|
||||
|
@ -155,7 +155,7 @@ public class VkRipper extends AlbumRipper {
|
||||
}
|
||||
offset += elements.size();
|
||||
|
||||
if (isThisATest()) {
|
||||
if (isStopped() || isThisATest()) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -15,8 +15,8 @@ public class VkRipperTest extends RippersTest {
|
||||
}
|
||||
List<URL> contentURLs = new ArrayList<URL>();
|
||||
contentURLs.add(new URL("https://vk.com/album45506334_172415053"));
|
||||
contentURLs.add(new URL("https://vk.com/album45506334_0"));
|
||||
contentURLs.add(new URL("https://vk.com/photos45506334"));
|
||||
//contentURLs.add(new URL("https://vk.com/album45506334_0"));
|
||||
//contentURLs.add(new URL("https://vk.com/photos45506334"));
|
||||
for (URL url : contentURLs) {
|
||||
VkRipper ripper = new VkRipper(url);
|
||||
testRipper(ripper);
|
||||
|
Loading…
Reference in New Issue
Block a user