refactored ehentai tag blacklisting
This commit is contained in:
parent
97ed831c94
commit
70799e39b9
@ -12,6 +12,7 @@ import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import com.rarchives.ripme.ui.RipStatusMessage;
|
||||
import com.rarchives.ripme.utils.RipUtils;
|
||||
import org.jsoup.nodes.Document;
|
||||
import org.jsoup.nodes.Element;
|
||||
import org.jsoup.select.Elements;
|
||||
@ -126,32 +127,7 @@ public class EHentaiRipper extends AbstractHTMLRipper {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks for blacklisted tags on page. If it finds one it returns it, if not it return null
|
||||
*
|
||||
* @param doc
|
||||
* @return String
|
||||
*/
|
||||
public String checkTags(Document doc, String[] blackListedTags) {
|
||||
// If the user hasn't blacklisted any tags we return null;
|
||||
if (blackListedTags == null) {
|
||||
return null;
|
||||
}
|
||||
LOGGER.info("Blacklisted tags " + blackListedTags[0]);
|
||||
List<String> tagsOnPage = getTags(doc);
|
||||
for (String tag : blackListedTags) {
|
||||
for (String pageTag : tagsOnPage) {
|
||||
// We replace all dashes in the tag with spaces because the tags we get from the site are separated using
|
||||
// dashes
|
||||
if (tag.trim().toLowerCase().equals(pageTag.toLowerCase())) {
|
||||
return tag;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private List<String> getTags(Document doc) {
|
||||
public List<String> getTags(Document doc) {
|
||||
List<String> tags = new ArrayList<>();
|
||||
LOGGER.info("Getting tags");
|
||||
for (Element tag : doc.select("td > div > a")) {
|
||||
@ -169,7 +145,7 @@ public class EHentaiRipper extends AbstractHTMLRipper {
|
||||
}
|
||||
this.lastURL = this.url.toExternalForm();
|
||||
LOGGER.info("Checking blacklist");
|
||||
String blacklistedTag = checkTags(albumDoc, Utils.getConfigStringArray("ehentai.blacklist.tags"));
|
||||
String blacklistedTag = RipUtils.checkTags(Utils.getConfigStringArray("ehentai.blacklist.tags"), getTags(albumDoc));
|
||||
if (blacklistedTag != null) {
|
||||
sendUpdate(RipStatusMessage.STATUS.DOWNLOAD_WARN, "Skipping " + url.toExternalForm() + " as it " +
|
||||
"contains the blacklisted tag \"" + blacklistedTag + "\"");
|
||||
|
Loading…
Reference in New Issue
Block a user