Can now black list tags with spaces in them

This commit is contained in:
cyian-1756 2018-05-14 03:26:56 -04:00
parent 05cc8cec61
commit 4dcfe3b712

View File

@ -79,8 +79,7 @@ public class NhentaiRipper extends AbstractHTMLRipper {
* @param doc * @param doc
* @return String * @return String
*/ */
private String checkTags(Document doc) { public String checkTags(Document doc, String[] blackListedTags) {
String[] blackListedTags = Utils.getConfigStringArray("nhentai.blacklist.tags");
// If the user hasn't blacklisted any tags we return false; // If the user hasn't blacklisted any tags we return false;
if (blackListedTags == null) { if (blackListedTags == null) {
return null; return null;
@ -89,8 +88,9 @@ public class NhentaiRipper extends AbstractHTMLRipper {
List<String> tagsOnPage = getTags(doc); List<String> tagsOnPage = getTags(doc);
for (String tag : blackListedTags) { for (String tag : blackListedTags) {
for (String pageTag : tagsOnPage) { for (String pageTag : tagsOnPage) {
logger.info("tag: " + tag + " pageTag: " + pageTag); // We replace all dashes in the tag with spaces because the tags we get from the site are separated using
if (tag.trim().toLowerCase().equals(pageTag.toLowerCase())) { // dashes
if (tag.trim().toLowerCase().equals(pageTag.replaceAll("-", " ").toLowerCase())) {
return tag; return tag;
} }
} }
@ -117,7 +117,7 @@ public class NhentaiRipper extends AbstractHTMLRipper {
firstPage = Http.url(url).get(); firstPage = Http.url(url).get();
} }
String blacklistedTag = checkTags(firstPage); String blacklistedTag = checkTags(firstPage, Utils.getConfigStringArray("nhentai.blacklist.tags"));
if (blacklistedTag != null) { if (blacklistedTag != null) {
sendUpdate(RipStatusMessage.STATUS.DOWNLOAD_WARN, "Skipping " + url.toExternalForm() + " as it " + sendUpdate(RipStatusMessage.STATUS.DOWNLOAD_WARN, "Skipping " + url.toExternalForm() + " as it " +
"contains the blacklisted tag \"" + blacklistedTag + "\""); "contains the blacklisted tag \"" + blacklistedTag + "\"");