Completely reformatted PahealRipper; add missing braces.

This commit is contained in:
MetaPrime 2017-05-09 15:36:37 -07:00
parent d2a4412a85
commit 56093cc1ad

View File

@ -21,10 +21,6 @@ import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;
/**
*
* @author
*/
public class PahealRipper extends AbstractHTMLRipper {
private static Map<String, String> cookies = null;
private static Pattern gidPattern = null;
@ -59,9 +55,10 @@ public class PahealRipper extends AbstractHTMLRipper{
@Override
public Document getNextPage(Document page) throws IOException {
for (Element e : page.select("#paginator a")) {
if(e.text().toLowerCase().equals("next"))
if (e.text().toLowerCase().equals("next")) {
return Http.url(e.absUrl("href")).cookies(getCookies()).get();
}
}
return null;
}
@ -71,8 +68,9 @@ public class PahealRipper extends AbstractHTMLRipper{
Elements elements = page.select(".shm-thumb.thumb>a").not(".shm-thumb-link");
List<String> res = new ArrayList<String>(elements.size());
for(Element e:elements)
for (Element e : elements) {
res.add(e.absUrl("href"));
}
return res;
}
@ -89,7 +87,11 @@ public class PahealRipper extends AbstractHTMLRipper{
name = name.substring(0, name.length() - ext.length());
}
addURLToDownload(url,new File(workingDir.getCanonicalPath()+File.separator+Utils.filesystemSafe(new URI(name).getPath())+ext));
File outFile = new File(workingDir.getCanonicalPath()
+ File.separator
+ Utils.filesystemSafe(new URI(name).getPath())
+ ext);
addURLToDownload(url, outFile);
} catch (IOException ex) {
Logger.getLogger(PahealRipper.class.getName()).log(Level.SEVERE, null, ex);
} catch (URISyntaxException ex) {
@ -98,12 +100,14 @@ public class PahealRipper extends AbstractHTMLRipper{
}
private String getTerm(URL url) throws MalformedURLException {
if(gidPattern==null)
if (gidPattern == null) {
gidPattern = Pattern.compile("^https?://(www\\.)?rule34\\.paheal\\.net/post/list/([a-zA-Z0-9$_.+!*'(),%-]+)(/.*)?(#.*)?$");
}
Matcher m = gidPattern.matcher(url.toExternalForm());
if(m.matches())
if (m.matches()) {
return m.group(2);
}
throw new MalformedURLException("Expected paheal.net URL format: rule34.paheal.net/post/list/searchterm - got " + url + " instead");
}
@ -118,5 +122,4 @@ public class PahealRipper extends AbstractHTMLRipper{
throw new MalformedURLException("Expected paheal.net URL format: rule34.paheal.net/post/list/searchterm - got " + url + " instead");
}
}