Completely reformatted PahealRipper; add missing braces.
This commit is contained in:
parent
d2a4412a85
commit
56093cc1ad
@ -21,10 +21,6 @@ import org.jsoup.nodes.Document;
|
|||||||
import org.jsoup.nodes.Element;
|
import org.jsoup.nodes.Element;
|
||||||
import org.jsoup.select.Elements;
|
import org.jsoup.select.Elements;
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author
|
|
||||||
*/
|
|
||||||
public class PahealRipper extends AbstractHTMLRipper {
|
public class PahealRipper extends AbstractHTMLRipper {
|
||||||
private static Map<String, String> cookies = null;
|
private static Map<String, String> cookies = null;
|
||||||
private static Pattern gidPattern = null;
|
private static Pattern gidPattern = null;
|
||||||
@ -59,9 +55,10 @@ public class PahealRipper extends AbstractHTMLRipper{
|
|||||||
@Override
|
@Override
|
||||||
public Document getNextPage(Document page) throws IOException {
|
public Document getNextPage(Document page) throws IOException {
|
||||||
for (Element e : page.select("#paginator a")) {
|
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 Http.url(e.absUrl("href")).cookies(getCookies()).get();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -71,8 +68,9 @@ public class PahealRipper extends AbstractHTMLRipper{
|
|||||||
Elements elements = page.select(".shm-thumb.thumb>a").not(".shm-thumb-link");
|
Elements elements = page.select(".shm-thumb.thumb>a").not(".shm-thumb-link");
|
||||||
List<String> res = new ArrayList<String>(elements.size());
|
List<String> res = new ArrayList<String>(elements.size());
|
||||||
|
|
||||||
for(Element e:elements)
|
for (Element e : elements) {
|
||||||
res.add(e.absUrl("href"));
|
res.add(e.absUrl("href"));
|
||||||
|
}
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
@ -89,7 +87,11 @@ public class PahealRipper extends AbstractHTMLRipper{
|
|||||||
name = name.substring(0, name.length() - ext.length());
|
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) {
|
} catch (IOException ex) {
|
||||||
Logger.getLogger(PahealRipper.class.getName()).log(Level.SEVERE, null, ex);
|
Logger.getLogger(PahealRipper.class.getName()).log(Level.SEVERE, null, ex);
|
||||||
} catch (URISyntaxException ex) {
|
} catch (URISyntaxException ex) {
|
||||||
@ -98,12 +100,14 @@ public class PahealRipper extends AbstractHTMLRipper{
|
|||||||
}
|
}
|
||||||
|
|
||||||
private String getTerm(URL url) throws MalformedURLException {
|
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$_.+!*'(),%-]+)(/.*)?(#.*)?$");
|
gidPattern = Pattern.compile("^https?://(www\\.)?rule34\\.paheal\\.net/post/list/([a-zA-Z0-9$_.+!*'(),%-]+)(/.*)?(#.*)?$");
|
||||||
|
}
|
||||||
|
|
||||||
Matcher m = gidPattern.matcher(url.toExternalForm());
|
Matcher m = gidPattern.matcher(url.toExternalForm());
|
||||||
if(m.matches())
|
if (m.matches()) {
|
||||||
return m.group(2);
|
return m.group(2);
|
||||||
|
}
|
||||||
|
|
||||||
throw new MalformedURLException("Expected paheal.net URL format: rule34.paheal.net/post/list/searchterm - got " + url + " instead");
|
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");
|
throw new MalformedURLException("Expected paheal.net URL format: rule34.paheal.net/post/list/searchterm - got " + url + " instead");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user