From b7730dcf891a54723d2257b4febcaad372392fc5 Mon Sep 17 00:00:00 2001 From: psp Date: Wed, 25 Sep 2024 12:29:56 +0000 Subject: [PATCH] *Plugins: Fixes/Changes/Maintenance* - KernelVideoSharingComThepornbangCom: updated comment - ImgSrcRuCrawler: dumped some old code and added more loggers RE forum 96470 git-svn-id: svn://svn.jdownloader.org/jdownloader/trunk@49862 ebf7c1c2-ba36-0410-9fe8-c592906822b4 Former-commit-id: aedd8291ce7db46f358d757c632838fa35fdd534 --- src/jd/plugins/decrypter/ImgSrcRuCrawler.java | 45 +++++++------------ .../KernelVideoSharingComThepornbangCom.java | 2 +- 2 files changed, 18 insertions(+), 29 deletions(-) diff --git a/src/jd/plugins/decrypter/ImgSrcRuCrawler.java b/src/jd/plugins/decrypter/ImgSrcRuCrawler.java index ccbd710b74..3204e5bb5d 100644 --- a/src/jd/plugins/decrypter/ImgSrcRuCrawler.java +++ b/src/jd/plugins/decrypter/ImgSrcRuCrawler.java @@ -23,7 +23,6 @@ import java.util.Set; import java.util.regex.Pattern; import org.appwork.utils.StringUtils; -import org.appwork.utils.encoding.URLEncode; import org.appwork.utils.parser.UrlQuery; import org.jdownloader.plugins.controller.LazyPlugin; @@ -89,7 +88,6 @@ public class ImgSrcRuCrawler extends PluginForDecrypt { private String password = null; private String username = null; - private String id = null; private String pwd = null; private PluginForHost plugin = null; private List passwords = null; @@ -156,7 +154,7 @@ public class ImgSrcRuCrawler extends PluginForDecrypt { } } - private String getGalleryName(Browser br) { + private String getGalleryName(final Browser br) { String ret = br.getRegex("from '([^\r\n]+)").getMatch(0); if (ret == null) { ret = br.getRegex("(.*?)(\\s*@\\s*iMGSRC\\.RU)?").getMatch(0); @@ -209,7 +207,9 @@ public class ImgSrcRuCrawler extends PluginForDecrypt { final ArrayList ret = new ArrayList(); try { // best to get the original parameter, as the page could contain blocks due to forward or password - if (!getPage(param.getCryptedUrl(), param)) { + String contenturl = param.getCryptedUrl(); + final boolean firstGetPageResult = getPage(contenturl, param); + if (!firstGetPageResult) { throw new PluginException(LinkStatus.ERROR_PLUGIN_DEFECT); } else if (br._getURL().getPath().equalsIgnoreCase("/main/search.php")) { throw new PluginException(LinkStatus.ERROR_FILE_NOT_FOUND); @@ -219,7 +219,6 @@ public class ImgSrcRuCrawler extends PluginForDecrypt { username = br.getRegex(">\\s*Add\\s*(.*?)\\s*to\\s*your").getMatch(0); if (username == null) { username = br.getRegex("/main/user\\.php\\?user=(.*?)'").getMatch(0); - username = URLEncode.decodeURIComponent(username); } } if (username == null) { @@ -229,45 +228,30 @@ public class ImgSrcRuCrawler extends PluginForDecrypt { if (username == null) { throw new PluginException(LinkStatus.ERROR_PLUGIN_DEFECT); } - final UrlQuery query = UrlQuery.parse(param.getCryptedUrl()); + username = Encoding.htmlDecode(username).trim(); + final UrlQuery query = UrlQuery.parse(contenturl); final String galleryTitle = getGalleryName(br); if (galleryTitle == null) { throw new PluginException(LinkStatus.ERROR_PLUGIN_DEFECT); } + // final String album_id_old = new Regex(contenturl, "(?i)/a(\\d+)\\.html").getMatch(0); String aid = query.get("ad"); if (aid == null) { aid = query.get("aid"); - if (aid == null) { - aid = new Regex(param.getCryptedUrl(), "/a(\\d+)\\.html").getMatch(0); - } } String uid = query.get("id"); if (uid == null) { - uid = new Regex(param.getCryptedUrl(), "/(\\d+)\\.html").getMatch(0); + uid = new Regex(contenturl, "(?i)/(\\d+)\\.html").getMatch(0); } if (uid == null && aid == null) { throw new PluginException(LinkStatus.ERROR_PLUGIN_DEFECT); } - // We need to make sure we are on page 1 otherwise we could miss pages. - // but this also makes things look tidy, making all parameters the same format - if (aid != null) { - id = "a" + aid; - } else { - id = uid; - } - final String galleryURL = br.getURL("/" + username + "/" + id + ".html").toExternalForm(); - if (!br.getURL().matches(Pattern.quote(galleryURL) + ".*?")) { - /* Access gallery-URL if it hasn't already been accessed. */ - if (!getPage(galleryURL, param)) { - throw new PluginException(LinkStatus.ERROR_PLUGIN_DEFECT); - } - } /** * 2024-03-18: Change image view to be able to find all items.
* And no, this not give us all images on one page, just lets us paginate over the gallery. */ final String allImagesOnOnePage = br.getRegex("'(/main/tape\\.php\\?aid=\\d+&id=\\d+&pwd=[^']*)'").getMatch(0); - if (allImagesOnOnePage != null && !br.getURL().contains("tape.php")) { + if (allImagesOnOnePage != null && !br.getURL().endsWith(allImagesOnOnePage)) { getPage(allImagesOnOnePage, param); } final String title = Encoding.htmlDecode(username.trim()) + " @ " + Encoding.htmlDecode(galleryTitle).trim(); @@ -277,11 +261,12 @@ public class ImgSrcRuCrawler extends PluginForDecrypt { final String quotedUsername = Pattern.quote(username); final Set pagesDone = new HashSet(); final List pagesTodo = new ArrayList(); + int page = 1; pagination: do { final int numberofResultsOld = ret.size(); final ArrayList thisPageResults = this.crawlImages(param); for (final DownloadLink result : thisPageResults) { - result.setProperty("username", username.trim()); + result.setProperty("username", username); if (galleryTitle != null) { result.setProperty("gallery", galleryTitle.trim()); } @@ -289,7 +274,9 @@ public class ImgSrcRuCrawler extends PluginForDecrypt { distribute(result); } ret.addAll(thisPageResults); - if (ret.size() == numberofResultsOld) { + final int numberofNewItemsThisPage = ret.size() - numberofResultsOld; + logger.info("Crawled page " + page + " | New items this page: " + numberofNewItemsThisPage + " | Total: " + ret.size()); + if (numberofNewItemsThisPage == 0) { if (ret.isEmpty()) { throw new PluginException(LinkStatus.ERROR_PLUGIN_DEFECT, "Found zero new results"); } else { @@ -330,6 +317,8 @@ public class ImgSrcRuCrawler extends PluginForDecrypt { break pagination; } } + /* Continue to crawl next page */ + page++; } while (!this.isAbort()); if (ret.isEmpty()) { throw new PluginException(LinkStatus.ERROR_PLUGIN_DEFECT); @@ -508,7 +497,7 @@ public class ImgSrcRuCrawler extends PluginForDecrypt { password = passwords.remove(0); } else { password = getUserInput("Enter password for link: " + param.getCryptedUrl(), param); - if (password == null || password.equals("")) { + if (StringUtils.isEmpty(password)) { logger.info("User aborted/entered blank password"); throw new DecrypterException(DecrypterException.PASSWORD); } diff --git a/src/jd/plugins/hoster/KernelVideoSharingComThepornbangCom.java b/src/jd/plugins/hoster/KernelVideoSharingComThepornbangCom.java index ebe92767ef..1f5c320993 100644 --- a/src/jd/plugins/hoster/KernelVideoSharingComThepornbangCom.java +++ b/src/jd/plugins/hoster/KernelVideoSharingComThepornbangCom.java @@ -94,7 +94,7 @@ public class KernelVideoSharingComThepornbangCom extends KernelVideoSharingComV2 @Override protected boolean enableFastLinkcheck() { - /* 2024-09-25: Experiment to counter problems reported here: https://board.jdownloader.org/showthread.php?t=96207 */ + /* 2024-09-25: To counter problems reported here: https://board.jdownloader.org/showthread.php?t=96207 */ return true; } } \ No newline at end of file