mirror of
https://github.com/mirror/jdownloader.git
synced 2024-11-23 03:59:51 +00:00
*General*
- MultiHostHost: added two more fields - PluginForHost: minor changes git-svn-id: svn://svn.jdownloader.org/jdownloader/trunk@49701 ebf7c1c2-ba36-0410-9fe8-c592906822b4 Former-commit-id: 9476b1136d2ee00c5c6c6a7fac1bfcd503a93999
This commit is contained in:
parent
989d6148e1
commit
14caaef91f
@ -29,6 +29,8 @@ public class MultiHostHost {
|
||||
private long timestampLimitReset = -1;
|
||||
/* How much traffic is credited when downloading from this host? */
|
||||
private short trafficUsageFactorPercent = 100;
|
||||
private int maxChunks = 0;
|
||||
private boolean resume = true;
|
||||
private String statusText = null;
|
||||
private MultihosterHostStatus status = MultihosterHostStatus.WORKING;
|
||||
|
||||
@ -147,8 +149,24 @@ public class MultiHostHost {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public int getMaxChunks() {
|
||||
return maxChunks;
|
||||
}
|
||||
|
||||
public void setMaxChunks(int maxChunks) {
|
||||
this.maxChunks = maxChunks;
|
||||
}
|
||||
|
||||
public boolean isResume() {
|
||||
return resume;
|
||||
}
|
||||
|
||||
public void setResume(boolean resume) {
|
||||
this.resume = resume;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return this.getDomain() + " | LinksAvailable: " + this.getLinksLeft() + "/" + this.getLinksMax() + " | Traffic: " + SizeFormatter.formatBytes(this.getTrafficLeft()) + "/" + SizeFormatter.formatBytes(this.getTrafficMax());
|
||||
return this.getDomain() + " | LinksAvailable: " + this.getLinksLeft() + "/" + this.getLinksMax() + " | Traffic: " + SizeFormatter.formatBytes(this.getTrafficLeft()) + "/" + SizeFormatter.formatBytes(this.getTrafficMax()) + " | Chunks: " + this.getMaxChunks() + " | Resume: " + this.isResume();
|
||||
}
|
||||
}
|
||||
|
@ -46,50 +46,6 @@ import javax.swing.JPanel;
|
||||
import javax.swing.JPopupMenu;
|
||||
import javax.swing.SwingConstants;
|
||||
|
||||
import jd.PluginWrapper;
|
||||
import jd.captcha.JACMethod;
|
||||
import jd.config.SubConfiguration;
|
||||
import jd.controlling.accountchecker.AccountChecker.AccountCheckJob;
|
||||
import jd.controlling.accountchecker.AccountCheckerThread;
|
||||
import jd.controlling.captcha.CaptchaSettings;
|
||||
import jd.controlling.captcha.SkipException;
|
||||
import jd.controlling.captcha.SkipRequest;
|
||||
import jd.controlling.downloadcontroller.DiskSpaceManager.DISKSPACERESERVATIONRESULT;
|
||||
import jd.controlling.downloadcontroller.DiskSpaceReservation;
|
||||
import jd.controlling.downloadcontroller.DownloadSession;
|
||||
import jd.controlling.downloadcontroller.DownloadWatchDog;
|
||||
import jd.controlling.downloadcontroller.DownloadWatchDogJob;
|
||||
import jd.controlling.downloadcontroller.ExceptionRunnable;
|
||||
import jd.controlling.downloadcontroller.SingleDownloadController;
|
||||
import jd.controlling.downloadcontroller.SingleDownloadController.WaitingQueueItem;
|
||||
import jd.controlling.linkchecker.LinkChecker;
|
||||
import jd.controlling.linkcollector.LinkCollector;
|
||||
import jd.controlling.linkcrawler.CheckableLink;
|
||||
import jd.controlling.linkcrawler.CrawledLink;
|
||||
import jd.controlling.linkcrawler.LinkCrawler;
|
||||
import jd.controlling.linkcrawler.LinkCrawlerThread;
|
||||
import jd.controlling.packagecontroller.AbstractNode;
|
||||
import jd.controlling.proxy.AbstractProxySelectorImpl;
|
||||
import jd.controlling.reconnect.ipcheck.BalancedWebIPCheck;
|
||||
import jd.controlling.reconnect.ipcheck.IPCheckException;
|
||||
import jd.controlling.reconnect.ipcheck.OfflineException;
|
||||
import jd.gui.swing.jdgui.views.settings.panels.pluginsettings.PluginConfigPanel;
|
||||
import jd.http.Browser;
|
||||
import jd.http.Browser.BrowserException;
|
||||
import jd.http.NoGateWayException;
|
||||
import jd.http.ProxySelectorInterface;
|
||||
import jd.http.Request;
|
||||
import jd.http.StaticProxySelector;
|
||||
import jd.http.URLConnectionAdapter;
|
||||
import jd.nutils.Formatter;
|
||||
import jd.nutils.JDHash;
|
||||
import jd.plugins.Account.AccountError;
|
||||
import jd.plugins.DownloadLink.AvailableStatus;
|
||||
import jd.plugins.download.DownloadInterface;
|
||||
import jd.plugins.download.DownloadInterfaceFactory;
|
||||
import jd.plugins.download.DownloadLinkDownloadable;
|
||||
import jd.plugins.download.Downloadable;
|
||||
|
||||
import org.appwork.exceptions.WTFException;
|
||||
import org.appwork.net.protocol.http.HTTPConstants;
|
||||
import org.appwork.storage.JSonStorage;
|
||||
@ -189,6 +145,50 @@ import org.jdownloader.translate._JDT;
|
||||
import org.jdownloader.updatev2.UpdateController;
|
||||
import org.jdownloader.updatev2.UpdateHandler;
|
||||
|
||||
import jd.PluginWrapper;
|
||||
import jd.captcha.JACMethod;
|
||||
import jd.config.SubConfiguration;
|
||||
import jd.controlling.accountchecker.AccountChecker.AccountCheckJob;
|
||||
import jd.controlling.accountchecker.AccountCheckerThread;
|
||||
import jd.controlling.captcha.CaptchaSettings;
|
||||
import jd.controlling.captcha.SkipException;
|
||||
import jd.controlling.captcha.SkipRequest;
|
||||
import jd.controlling.downloadcontroller.DiskSpaceManager.DISKSPACERESERVATIONRESULT;
|
||||
import jd.controlling.downloadcontroller.DiskSpaceReservation;
|
||||
import jd.controlling.downloadcontroller.DownloadSession;
|
||||
import jd.controlling.downloadcontroller.DownloadWatchDog;
|
||||
import jd.controlling.downloadcontroller.DownloadWatchDogJob;
|
||||
import jd.controlling.downloadcontroller.ExceptionRunnable;
|
||||
import jd.controlling.downloadcontroller.SingleDownloadController;
|
||||
import jd.controlling.downloadcontroller.SingleDownloadController.WaitingQueueItem;
|
||||
import jd.controlling.linkchecker.LinkChecker;
|
||||
import jd.controlling.linkcollector.LinkCollector;
|
||||
import jd.controlling.linkcrawler.CheckableLink;
|
||||
import jd.controlling.linkcrawler.CrawledLink;
|
||||
import jd.controlling.linkcrawler.LinkCrawler;
|
||||
import jd.controlling.linkcrawler.LinkCrawlerThread;
|
||||
import jd.controlling.packagecontroller.AbstractNode;
|
||||
import jd.controlling.proxy.AbstractProxySelectorImpl;
|
||||
import jd.controlling.reconnect.ipcheck.BalancedWebIPCheck;
|
||||
import jd.controlling.reconnect.ipcheck.IPCheckException;
|
||||
import jd.controlling.reconnect.ipcheck.OfflineException;
|
||||
import jd.gui.swing.jdgui.views.settings.panels.pluginsettings.PluginConfigPanel;
|
||||
import jd.http.Browser;
|
||||
import jd.http.Browser.BrowserException;
|
||||
import jd.http.NoGateWayException;
|
||||
import jd.http.ProxySelectorInterface;
|
||||
import jd.http.Request;
|
||||
import jd.http.StaticProxySelector;
|
||||
import jd.http.URLConnectionAdapter;
|
||||
import jd.nutils.Formatter;
|
||||
import jd.nutils.JDHash;
|
||||
import jd.plugins.Account.AccountError;
|
||||
import jd.plugins.DownloadLink.AvailableStatus;
|
||||
import jd.plugins.download.DownloadInterface;
|
||||
import jd.plugins.download.DownloadInterfaceFactory;
|
||||
import jd.plugins.download.DownloadLinkDownloadable;
|
||||
import jd.plugins.download.Downloadable;
|
||||
|
||||
/**
|
||||
* Dies ist die Oberklasse fuer alle Plugins, die von einem Anbieter Dateien herunterladen koennen
|
||||
*
|
||||
@ -197,14 +197,13 @@ import org.jdownloader.updatev2.UpdateHandler;
|
||||
public abstract class PluginForHost extends Plugin {
|
||||
private static final String COPY_MOVE_FILE = "CopyMoveFile";
|
||||
private static final Pattern[] PATTERNS = new Pattern[] {
|
||||
/**
|
||||
* these patterns should split filename and fileextension (extension must include the
|
||||
* point)
|
||||
*/
|
||||
// multipart rar archives
|
||||
Pattern.compile("(.*)(\\.pa?r?t?\\.?[0-9]+.*?\\.rar$)", Pattern.CASE_INSENSITIVE),
|
||||
// normal files with extension
|
||||
Pattern.compile("(.*)(\\..*?$)", Pattern.CASE_INSENSITIVE) };
|
||||
/**
|
||||
* these patterns should split filename and fileextension (extension must include the point)
|
||||
*/
|
||||
// multipart rar archives
|
||||
Pattern.compile("(.*)(\\.pa?r?t?\\.?[0-9]+.*?\\.rar$)", Pattern.CASE_INSENSITIVE),
|
||||
// normal files with extension
|
||||
Pattern.compile("(.*)(\\..*?$)", Pattern.CASE_INSENSITIVE) };
|
||||
private LazyHostPlugin lazyP = null;
|
||||
/**
|
||||
* Is true if the user has answered a captcha challenge. Does not say anything whether or not the answer was correct.
|
||||
@ -1293,23 +1292,34 @@ public abstract class PluginForHost extends Plugin {
|
||||
}
|
||||
|
||||
public void update(final DownloadLink downloadLink, final Account account, long bytesTransfered) throws PluginException {
|
||||
if (account != null && bytesTransfered > 0) {
|
||||
// update the AccountInfo and NOT the AccountTrafficView
|
||||
final AccountInfo ai = account.getAccountInfo();
|
||||
if (ai != null && !ai.isUnlimitedTraffic()) {
|
||||
final long left = Math.max(0, ai.getTrafficLeft() - bytesTransfered);
|
||||
ai.setTrafficLeft(left);
|
||||
if (left == 0) {
|
||||
if (!ai.isSpecialTraffic()) {
|
||||
throw new PluginException(LinkStatus.ERROR_PREMIUM, PluginException.VALUE_ID_PREMIUM_TEMP_DISABLE);
|
||||
}
|
||||
if (account == null) {
|
||||
return;
|
||||
} else if (bytesTransfered == 0) {
|
||||
return;
|
||||
}
|
||||
// update the AccountInfo and NOT the AccountTrafficView
|
||||
final AccountInfo ai = account.getAccountInfo();
|
||||
if (ai == null) {
|
||||
return;
|
||||
}
|
||||
if (!ai.isUnlimitedTraffic()) {
|
||||
final long left = Math.max(0, ai.getTrafficLeft() - bytesTransfered);
|
||||
ai.setTrafficLeft(left);
|
||||
if (left == 0) {
|
||||
if (!ai.isSpecialTraffic()) {
|
||||
throw new PluginException(LinkStatus.ERROR_PREMIUM, PluginException.VALUE_ID_PREMIUM_TEMP_DISABLE);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void postHandle(final DownloadLink downloadLink, final Account account, final PluginForHost pluginForHost) throws Exception {
|
||||
if (pluginForHost != null && downloadLink != null && StringUtils.equalsIgnoreCase(downloadLink.getHost(), pluginForHost.getHost())) {
|
||||
if (pluginForHost == null) {
|
||||
return;
|
||||
} else if (downloadLink == null) {
|
||||
return;
|
||||
}
|
||||
if (StringUtils.equalsIgnoreCase(downloadLink.getHost(), pluginForHost.getHost())) {
|
||||
if (downloadLink.hasGenericVariantSupport() && downloadLink.hasVariantSupport()) {
|
||||
final GenericVariants var = downloadLink.getVariant(GenericVariants.class);
|
||||
if (var != null) {
|
||||
@ -1320,7 +1330,12 @@ public abstract class PluginForHost extends Plugin {
|
||||
}
|
||||
|
||||
public void preHandle(final DownloadLink downloadLink, final Account account, final PluginForHost pluginForHost) throws Exception {
|
||||
if (pluginForHost != null && downloadLink != null && StringUtils.equalsIgnoreCase(downloadLink.getHost(), pluginForHost.getHost())) {
|
||||
if (pluginForHost == null) {
|
||||
return;
|
||||
} else if (downloadLink == null) {
|
||||
return;
|
||||
}
|
||||
if (StringUtils.equalsIgnoreCase(downloadLink.getHost(), pluginForHost.getHost())) {
|
||||
if (downloadLink.hasGenericVariantSupport() && downloadLink.hasVariantSupport()) {
|
||||
final GenericVariants var = downloadLink.getVariant(GenericVariants.class);
|
||||
if (var != null) {
|
||||
@ -1594,16 +1609,15 @@ public abstract class PluginForHost extends Plugin {
|
||||
try {
|
||||
link.addPluginProgress(prg);
|
||||
final AskDownloadPasswordDialogInterface handle = UIOManager.I().show(AskDownloadPasswordDialogInterface.class, new AskForDownloadLinkDialog(title, message, link));
|
||||
if (handle.getCloseReason() == CloseReason.OK) {
|
||||
final String password = handle.getText();
|
||||
if (StringUtils.isEmpty(password)) {
|
||||
throw new PluginException(LinkStatus.ERROR_FATAL, _JDT.T.plugins_errors_wrongpassword());
|
||||
} else {
|
||||
return password;
|
||||
}
|
||||
} else {
|
||||
if (handle.getCloseReason() != CloseReason.OK) {
|
||||
throw new PluginException(LinkStatus.ERROR_FATAL, _JDT.T.plugins_errors_wrongpassword());
|
||||
}
|
||||
final String password = handle.getText();
|
||||
if (StringUtils.isEmpty(password)) {
|
||||
throw new PluginException(LinkStatus.ERROR_FATAL, _JDT.T.plugins_errors_wrongpassword());
|
||||
} else {
|
||||
return password;
|
||||
}
|
||||
} finally {
|
||||
link.removePluginProgress(prg);
|
||||
}
|
||||
@ -1761,9 +1775,10 @@ public abstract class PluginForHost extends Plugin {
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines whether or not mass- linkchecking is allowed. </br> If it is always possible, simply override
|
||||
* PluginForHost.checkLinks(final DownloadLink[] urls). </br> If it is generally possible but not always e.g. depending whether an
|
||||
* apikey is given or not, override this method. Example: </br> org.jdownloader.plugins.components.XFileSharingProBasic
|
||||
* Determines whether or not mass- linkchecking is allowed. </br>
|
||||
* If it is always possible, simply override PluginForHost.checkLinks(final DownloadLink[] urls). </br>
|
||||
* If it is generally possible but not always e.g. depending whether an apikey is given or not, override this method. Example: </br>
|
||||
* org.jdownloader.plugins.components.XFileSharingProBasic
|
||||
*/
|
||||
public boolean internal_supportsMassLinkcheck() {
|
||||
return implementsCheckLinks(this);
|
||||
@ -3046,9 +3061,11 @@ public abstract class PluginForHost extends Plugin {
|
||||
}
|
||||
|
||||
/**
|
||||
* Override this if API login is needed for this plugin. </br> Return an URL which will lead the user to his API key and/or instructions
|
||||
* on how to login via API in JDownloader. </br> Example(s): </br> pixeldrain.com:
|
||||
* https://pixeldrain.com/user/connect_app?app=jdownloader </br> cocoleech.com: https://members.cocoleech.com/settings
|
||||
* Override this if API login is needed for this plugin. </br>
|
||||
* Return an URL which will lead the user to his API key and/or instructions on how to login via API in JDownloader. </br>
|
||||
* Example(s): </br>
|
||||
* pixeldrain.com: https://pixeldrain.com/user/connect_app?app=jdownloader </br>
|
||||
* cocoleech.com: https://members.cocoleech.com/settings
|
||||
*/
|
||||
protected String getAPILoginHelpURL() {
|
||||
return null;
|
||||
@ -3060,7 +3077,8 @@ public abstract class PluginForHost extends Plugin {
|
||||
}
|
||||
|
||||
/**
|
||||
* Use this to pre-validate login credentials. </br> This method works locally/offline and shall not perform any http requests!
|
||||
* Use this to pre-validate login credentials. </br>
|
||||
* This method works locally/offline and shall not perform any http requests!
|
||||
*
|
||||
* @throws AccountInvalidException
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user