public void init() { if (init.compareAndSet(false, true)) { addSolver(JACSolver.getInstance()); if (CFG_GENERAL.CFG.isMyJDownloaderCaptchaSolverEnabled()) { addSolver(CaptchaMyJDSolver.getInstance()); } addSolver(DeathByCaptchaSolver.getInstance()); addSolver(ImageTyperzCaptchaSolver.getInstance()); addSolver(CheapCaptchaSolver.getInstance()); addSolver(CBSolver.getInstance()); addSolver(Captcha9kwSolver.getInstance()); addSolver(Captcha9kwSolverClick.getInstance()); if (!Application.isHeadless()) { addSolver(DialogBasicCaptchaSolver.getInstance()); } if (!Application.isHeadless()) { addSolver(DialogClickCaptchaSolver.getInstance()); } if (!Application.isHeadless()) { addSolver(BrowserSolver.getInstance()); } addSolver(KeyCaptchaJACSolver.getInstance()); if (!Application.isHeadless()) { addSolver(KeyCaptchaDialogSolver.getInstance()); } addSolver(CaptchaAPISolver.getInstance()); } }
/** * load FilePackages and DownloadLinks from database * * @return * @throws Exception * <p>private LinkedList<FilePackage> loadDownloadLinks() throws Exception { Object obj = * null; try { obj = JDUtilities.getDatabaseConnector().getLinks(); } catch (final * NoOldJDDataBaseFoundException e) { return null; } if (obj != null && obj instanceof * ArrayList && (((java.util.List<?>) obj).size() == 0 || ((java.util.List<?>) obj).size() > 0 * && ((java.util.List<?>) obj).get(0) instanceof FilePackage)) { return new * LinkedList<FilePackage>((java.util.List<FilePackage>) obj); } throw new Exception("Linklist * incompatible"); } */ private void postInit(LinkedList<FilePackage> fps) { if (fps == null || fps.size() == 0) return; final Iterator<FilePackage> iterator = fps.iterator(); DownloadLink localLink; PluginForHost pluginForHost = null; Iterator<DownloadLink> it; FilePackage fp; HashMap<String, PluginForHost> fixWith = new HashMap<String, PluginForHost>(); while (iterator.hasNext()) { fp = iterator.next(); java.util.List<DownloadLink> removeList = new ArrayList<DownloadLink>(); it = fp.getChildren().iterator(); while (it.hasNext()) { localLink = it.next(); if (CleanAfterDownloadAction.CLEANUP_ONCE_AT_STARTUP.equals( org.jdownloader.settings.staticreferences.CFG_GENERAL.CFG .getCleanupAfterDownloadAction()) && localLink.getLinkStatus().isFinished()) { logger.info("Remove " + localLink.getName() + " because Finished and CleanupOnStartup!"); removeList.add(localLink); continue; } /* * reset not if already exist, offline or finished. plugin errors will be reset here because plugin can be fixed again */ localLink .getLinkStatus() .resetStatus( LinkStatus.ERROR_ALREADYEXISTS, LinkStatus.ERROR_FILE_NOT_FOUND, LinkStatus.FINISHED, LinkStatus.ERROR_FATAL); /* assign defaultPlugin matching the hostname try { pluginForHost = null; LazyHostPlugin hPlugin = HostPluginController.getInstance().get(localLink.getHost()); if (hPlugin != null) { pluginForHost = hPlugin.getPrototype(null); } } catch (final Throwable e) { logger.log(e); } if (pluginForHost == null) { try { if (fixWith.containsKey(localLink.getHost()) == false) { for (LazyHostPlugin p : HostPluginController.getInstance().list()) { try { if (p.getPrototype(null).rewriteHost(localLink)) { pluginForHost = p.getPrototype(null); break; } } catch (final Throwable e) { logger.log(e); } } } else { PluginForHost rewriteWith = fixWith.get(localLink.getHost()); if (rewriteWith != null) { rewriteWith.rewriteHost(localLink); pluginForHost = rewriteWith; } } if (pluginForHost != null) { logger.info("Plugin " + pluginForHost.getHost() + " now handles " + localLink.getName()); } } catch (final Throwable e) { logger.log(e); } fixWith.put(localLink.getHost(), pluginForHost); } if (pluginForHost != null) { localLink.setDefaultPlugin(pluginForHost); } else { logger.severe("Could not find plugin: " + localLink.getHost() + " for " + localLink.getName()); }*/ } if (removeList.size() > 0) { fp.getChildren().removeAll(removeList); } if (fp.getChildren().size() == 0) { /* remove empty packages */ iterator.remove(); continue; } } }