Added some unit tests for DeviantartRipper
This commit is contained in:
parent
dab771f2da
commit
ae6d09c6e8
@ -190,13 +190,11 @@ public class DeviantartRipper extends AbstractJSONRipper {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getGalleryID(Document doc) {
|
public String getGalleryID(Document doc) {
|
||||||
for (Element el : doc.select("input[name=set]")) {
|
for (Element el : doc.select("input[name=set]")) {
|
||||||
try {
|
try {
|
||||||
String galleryID = el.attr("value");
|
String galleryID = el.attr("value");
|
||||||
if (galleryID.length() == 8) {
|
return galleryID;
|
||||||
return galleryID;
|
|
||||||
}
|
|
||||||
} catch (NullPointerException e) {
|
} catch (NullPointerException e) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -205,7 +203,7 @@ public class DeviantartRipper extends AbstractJSONRipper {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getUsername(Document doc) {
|
public String getUsername(Document doc) {
|
||||||
return doc.select("meta[property=og:title]").attr("content").replaceAll("'s DeviantArt gallery", "");
|
return doc.select("meta[property=og:title]").attr("content").replaceAll("'s DeviantArt gallery", "");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,6 +4,8 @@ import java.io.IOException;
|
|||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
|
|
||||||
import com.rarchives.ripme.ripper.rippers.DeviantartRipper;
|
import com.rarchives.ripme.ripper.rippers.DeviantartRipper;
|
||||||
|
import com.rarchives.ripme.utils.Http;
|
||||||
|
import org.jsoup.nodes.Document;
|
||||||
|
|
||||||
public class DeviantartRipperTest extends RippersTest {
|
public class DeviantartRipperTest extends RippersTest {
|
||||||
public void testDeviantartAlbum() throws IOException {
|
public void testDeviantartAlbum() throws IOException {
|
||||||
@ -22,4 +24,12 @@ public class DeviantartRipperTest extends RippersTest {
|
|||||||
DeviantartRipper ripper = new DeviantartRipper(url);
|
DeviantartRipper ripper = new DeviantartRipper(url);
|
||||||
assertEquals("airgee", ripper.getGID(url));
|
assertEquals("airgee", ripper.getGID(url));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testGetGalleryIDAndUsername() throws IOException {
|
||||||
|
URL url = new URL("https://www.deviantart.com/airgee/gallery/");
|
||||||
|
DeviantartRipper ripper = new DeviantartRipper(url);
|
||||||
|
Document doc = Http.url(url).get();
|
||||||
|
assertEquals("airgee", ripper.getUsername(doc));
|
||||||
|
assertEquals("714589", ripper.getGalleryID(doc));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user