Skip to content

Commit

Permalink
mirroring bot - 2025/01/14
Browse files Browse the repository at this point in the history
  • Loading branch information
updating-bot committed Jan 14, 2025
1 parent 6a691e9 commit 028dde0
Show file tree
Hide file tree
Showing 48 changed files with 1,506 additions and 370 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -563,7 +563,7 @@ public AccountCache getAccountCache(final DownloadLink link) {
cachedGroups.add(hosterFreeGroup);
}
/* free(no account) */
final CachedAccount noAccount = new CachedAccount(host, null, defaulPlugin);
CachedAccount noAccount = new CachedAccount(host, null, defaulPlugin);
final boolean addNoAccountGroup;
if (numberofPremiumAccounts > 0) {
/* At least one premium account is available -> Do not allow non-account download. */
Expand All @@ -575,11 +575,26 @@ public AccountCache getAccountCache(final DownloadLink link) {
/* Allow download without account */
addNoAccountGroup = true;
}
if (addNoAccountGroup) {
final CachedAccountGroup freeGroup = new CachedAccountGroup(Rules.ORDER);
freeGroup.add(noAccount);
cachedGroups.add(freeGroup);
if (!addNoAccountGroup) {
noAccount = new CachedAccount(host, null, defaulPlugin) {
final List<CachedAccountGroup> finalCachedGroups = new ArrayList<CachedAccountGroup>(cachedGroups);

@Override
public boolean canHandle(DownloadLink link) throws Exception {
for (final CachedAccountGroup cachedGroup : finalCachedGroups) {
for (final CachedAccount cachedAccount : cachedGroup) {
if (cachedAccount.canHandle(link)) {
return false;
}
}
}
return super.canHandle(link);
}
};
}
final CachedAccountGroup freeGroup = new CachedAccountGroup(Rules.ORDER);
freeGroup.add(noAccount);
cachedGroups.add(freeGroup);
ret = new AccountCache(cachedGroups);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,15 +118,7 @@ public void onRuleAdded(AccountUsageRule parameter) {
if (!isShown()) {
return;
}
if (HosterRuleController.getInstance().showEditPanel(parameter)) {
updateTable();
} else {
/**
* User closed/cancelled edit rule dialog. </br>
* Remove rule and don't refresh table so it looks as if this rule has never been added.
*/
HosterRuleController.getInstance().remove(parameter);
}
updateTable();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,9 @@ public void actionPerformed(ActionEvent e) {
/* Add rule for selected item. */
final AccountUsageRule rule = new AccountUsageRule(di.getTld());
rule.setEnabled(true);
hrc.add(rule);
if (HosterRuleController.getInstance().validateRule(rule) && HosterRuleController.getInstance().showEditPanel(rule)) {
hrc.add(rule);
}
}
} catch (DialogClosedException e1) {
e1.printStackTrace();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,6 @@
import javax.swing.Scrollable;
import javax.swing.SwingUtilities;

import jd.gui.swing.jdgui.JDGui;
import jd.gui.swing.jdgui.interfaces.SwitchPanel;
import jd.gui.swing.jdgui.views.settings.components.SettingsComponent;
import jd.gui.swing.jdgui.views.settings.components.StateUpdateListener;
import jd.gui.swing.jdgui.views.settings.sidebar.AddonConfig;
import jd.plugins.Account;
import jd.plugins.Plugin;
import jd.plugins.PluginConfigPanelNG;
import net.miginfocom.swing.MigLayout;

import org.appwork.exceptions.WTFException;
import org.appwork.storage.config.JsonConfig;
import org.appwork.swing.MigPanel;
Expand All @@ -51,13 +41,24 @@
import org.jdownloader.images.AbstractIcon;
import org.jdownloader.logging.LogController;
import org.jdownloader.plugins.controller.LazyPlugin;
import org.jdownloader.plugins.controller.LazyPlugin.FEATURE;
import org.jdownloader.plugins.controller.UpdateRequiredClassNotFoundException;
import org.jdownloader.plugins.controller.crawler.CrawlerPluginController;
import org.jdownloader.plugins.controller.crawler.LazyCrawlerPlugin;
import org.jdownloader.plugins.controller.host.HostPluginController;
import org.jdownloader.plugins.controller.host.LazyHostPlugin;
import org.jdownloader.settings.GraphicalUserInterfaceSettings;

import jd.gui.swing.jdgui.JDGui;
import jd.gui.swing.jdgui.interfaces.SwitchPanel;
import jd.gui.swing.jdgui.views.settings.components.SettingsComponent;
import jd.gui.swing.jdgui.views.settings.components.StateUpdateListener;
import jd.gui.swing.jdgui.views.settings.sidebar.AddonConfig;
import jd.plugins.Account;
import jd.plugins.Plugin;
import jd.plugins.PluginConfigPanelNG;
import net.miginfocom.swing.MigLayout;

public class PluginSettingsPanel extends JPanel implements SettingsComponent, ActionListener {
/**
*
Expand Down Expand Up @@ -276,7 +277,7 @@ private void fill() {
public List<LazyPlugin<?>> fillModel() {
final List<LazyPlugin<?>> lst = new ArrayList<LazyPlugin<?>>();
for (final LazyHostPlugin plg : HostPluginController.getInstance().list()) {
if (plg.isHasConfig() || plg.isPremium()) {
if (plg.isHasConfig() || (plg.isPremium() && (plg.isHasPremiumConfig() || plg.hasFeature(FEATURE.MULTIHOST)))) {
lst.add(plg);
}
}
Expand Down
2 changes: 1 addition & 1 deletion svn_trunk/src/jd/plugins/PluginForHost.java
Original file line number Diff line number Diff line change
Expand Up @@ -854,7 +854,7 @@ public SubConfiguration getPluginConfig() {
}

protected PluginConfigPanelNG createConfigPanel() {
if (getConfigInterface() == null && !isPremiumEnabled()) {
if (getConfigInterface() == null && (!isPremiumEnabled() || getAccountConfigInterface(null) == null)) {
return null;
}
final PluginConfigPanelNG ret = new PluginConfigPanelNG() {
Expand Down
32 changes: 25 additions & 7 deletions svn_trunk/src/jd/plugins/decrypter/ArchiveOrgCrawler.java
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@
import jd.plugins.download.HashInfo;
import jd.plugins.hoster.ArchiveOrg;

@DecrypterPlugin(revision = "$Revision: 50222 $", interfaceVersion = 2, names = { "archive.org", "subdomain.archive.org" }, urls = { "https?://(?:www\\.)?archive\\.org/((?:details|download|stream|embed)/.+|search\\?query=.+)", "https?://[^/]+\\.archive\\.org/view_archive\\.php\\?archive=[^\\&]+(?:\\&file=[^\\&]+)?" })
@DecrypterPlugin(revision = "$Revision: 50435 $", interfaceVersion = 2, names = { "archive.org", "subdomain.archive.org" }, urls = { "https?://(?:www\\.)?archive\\.org/((?:details|download|stream|embed)/.+|search\\?query=.+)", "https?://[^/]+\\.archive\\.org/view_archive\\.php\\?archive=[^\\&]+(?:\\&file=[^\\&]+)?" })
public class ArchiveOrgCrawler extends PluginForDecrypt {
public ArchiveOrgCrawler(PluginWrapper wrapper) {
super(wrapper);
Expand Down Expand Up @@ -874,7 +874,8 @@ private ArrayList<DownloadLink> crawlMetadataJsonV2(final String identifier, fin
final boolean crawlMetadataFiles = cfg.isFileCrawlerCrawlMetadataFiles();
final boolean crawlThumbnails = cfg.isFileCrawlerCrawlThumbnails();
final List<String> skippedItemsFilepaths = new ArrayList<String>();
String totalLengthSecondsStr = null;
String totalLengthSecondsOriginalStr = null;
String totalLengthSecondsDerivativeStr = null;
Object desiredFileArchiveFileCount = null;
final HashSet<String> originalFilenamesDupeCollection = new HashSet<String>();
/** Restricted access usually means that original files are not downloadable or only DRM protected / encrypted items exist. */
Expand Down Expand Up @@ -947,8 +948,14 @@ private ArrayList<DownloadLink> crawlMetadataJsonV2(final String identifier, fin
itemMapping.put(name, file);
if (isOriginal) {
originalMapping.put(name, null);
if (totalLengthSecondsOriginalStr == null) {
totalLengthSecondsOriginalStr = (String) filemap.get("length");
}
} else if ("derivative".equals(source) && originalO instanceof String) {
originalMapping.put(name, originalO.toString());
if (totalLengthSecondsDerivativeStr == null && StringUtils.endsWithCaseInsensitive(name, ".mp4")) {
totalLengthSecondsDerivativeStr = (String) filemap.get("length");
}
}
file.setProperty(ArchiveOrg.PROPERTY_FILENAME, filename);
file.setProperty(ArchiveOrg.PROPERTY_ARTIST, filemap.get("artist")); // Optional field
Expand Down Expand Up @@ -1009,9 +1016,6 @@ private ArrayList<DownloadLink> crawlMetadataJsonV2(final String identifier, fin
desiredFileArchiveFileCount = filemap.get("filecount");
singleDesiredFile2 = file;
}
if (isOriginal && totalLengthSecondsStr == null) {
totalLengthSecondsStr = (String) filemap.get("length");
}
/* Add items to list of all results. */
/* Check some skip conditions */
if (isOldVersion) {
Expand Down Expand Up @@ -1158,14 +1162,22 @@ private ArrayList<DownloadLink> crawlMetadataJsonV2(final String identifier, fin
}
} else if (StringUtils.equalsIgnoreCase(mediatype, "movies") && identifierDotMp4Exists) {
/* Video "playlist" handling */
if (totalLengthSecondsStr == null || !totalLengthSecondsStr.matches("\\d+(\\.\\d+)?")) {
if (totalLengthSecondsOriginalStr == null || !totalLengthSecondsOriginalStr.matches("\\d+(\\.\\d+)?")) {
/* This should never happen */
logger.warning("Detected mediatype 'movies' item but failed to determine video playtime");
/* Return original files */
return selectedItems;
}
final int secondsPerSegment = 60;
final double totalLengthSeconds = Double.parseDouble(totalLengthSecondsStr);
double totalLengthSeconds = Double.parseDouble(totalLengthSecondsOriginalStr);
if (totalLengthSeconds == 0 && (totalLengthSecondsDerivativeStr != null && totalLengthSecondsDerivativeStr.matches("\\d+(\\.\\d+)?"))) {
/**
* Edge case: Looks like archive.org original data may be corrupt sometimes, prividing "0.00" as length value. </br>
* Example: https://archive.org/details/KNTV_20200205_073400_The_Tonight_Show_Starring_Jimmy_Fallon
*/
logger.info("Failed to find video length via info from original item -> Fallback to length from derivative -> " + totalLengthSecondsDerivativeStr);
totalLengthSeconds = Double.parseDouble(totalLengthSecondsDerivativeStr);
}
final int numberofVideoSegments;
final double remainingSeconds = totalLengthSeconds % secondsPerSegment;
if (remainingSeconds == 0) {
Expand All @@ -1174,6 +1186,12 @@ private ArrayList<DownloadLink> crawlMetadataJsonV2(final String identifier, fin
/* Uneven total runtime -> Last segment will be shorter than the others. */
numberofVideoSegments = (int) ((totalLengthSeconds / secondsPerSegment) + 1);
}
if (totalLengthSeconds == 0) {
/* This should never happen */
logger.warning("Detected mediatype 'movies' item but determined playtime of 0 seconds is unplausible");
/* Return original files */
return selectedItems;
}
int offsetSeconds = 0;
/*
* Video can't be officially downloaded but it can be streamed in segments of X seconds each -> Generate those stream-links
Expand Down
33 changes: 22 additions & 11 deletions svn_trunk/src/jd/plugins/decrypter/CivitaiComCrawler.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@
import java.util.List;
import java.util.Map;

import org.appwork.storage.JSonStorage;
import org.appwork.storage.TypeRef;
import org.appwork.utils.parser.UrlQuery;
import org.jdownloader.plugins.components.config.CivitaiComConfig;
import org.jdownloader.plugins.config.PluginJsonConfig;

import jd.PluginWrapper;
import jd.controlling.ProgressController;
import jd.http.Browser;
Expand All @@ -39,13 +45,7 @@
import jd.plugins.hoster.CivitaiCom;
import jd.plugins.hoster.DirectHTTP;

import org.appwork.storage.JSonStorage;
import org.appwork.storage.TypeRef;
import org.appwork.utils.parser.UrlQuery;
import org.jdownloader.plugins.components.config.CivitaiComConfig;
import org.jdownloader.plugins.config.PluginJsonConfig;

@DecrypterPlugin(revision = "$Revision: 50389 $", interfaceVersion = 3, names = {}, urls = {})
@DecrypterPlugin(revision = "$Revision: 50439 $", interfaceVersion = 3, names = {}, urls = {})
@PluginDependencies(dependencies = { CivitaiCom.class })
public class CivitaiComCrawler extends PluginForDecrypt {
public CivitaiComCrawler(PluginWrapper wrapper) {
Expand Down Expand Up @@ -94,6 +94,7 @@ public ArrayList<DownloadLink> decryptIt(final CryptedLink param, ProgressContro
final String itemType = urlregex.getMatch(0);
final String itemID = urlregex.getMatch(1);
final CivitaiCom hosterplugin = (CivitaiCom) this.getNewPluginForHostInstance(this.getHost());
final CivitaiComConfig cfg = PluginJsonConfig.get(CivitaiComConfig.class);
/*
* Using API: https://github.com/civitai/civitai/wiki/REST-API-Reference,
* https://wiki.civitai.com/wiki/Civitai_API#GET_/api/v1/images
Expand Down Expand Up @@ -137,17 +138,21 @@ public ArrayList<DownloadLink> decryptIt(final CryptedLink param, ProgressContro
fp.setPackageKey("civitai://post/" + itemID);
for (final Map<String, Object> image : images) {
final String imageurl = image.get("url").toString();
final String tempName = getFileNameFromURL(new URL(imageurl));
final DownloadLink link = this.createDownloadlink(br.getURL("/images/" + image.get("id")).toExternalForm());
link._setFilePackage(fp);
final String tempName;
if (cfg.isUseIndexIDForImageFilename()) {
tempName = image.get("id").toString() + ".jpg";
} else {
tempName = getFileNameFromURL(new URL(imageurl));
}
if (tempName != null) {
link.setName(tempName);
}
link.setAvailable(true);
ret.add(link);
}
} else if (itemType.equals("user")) {
final CivitaiComConfig cfg = PluginJsonConfig.get(CivitaiComConfig.class);
final FilePackage fp = FilePackage.getInstance();
fp.setName(itemID);
fp.setPackageKey("civitai://user/" + itemID);
Expand All @@ -156,7 +161,8 @@ public ArrayList<DownloadLink> decryptIt(final CryptedLink param, ProgressContro
/* 2024-07-17: use small limit/pagination size to avoid timeout issues */
/**
* 2024-07-18: About the "nsfw" parameter: According to their docs, without nsfw parameter, all items will be rerturned but that
* is wrong --> Wrong API docs or bug in API. </br> Only with the nsfw parameter set to "X", all items will be returned.
* is wrong --> Wrong API docs or bug in API. </br>
* Only with the nsfw parameter set to "X", all items will be returned.
*/
final int maxItemsPerPage = cfg.getProfileCrawlerMaxPaginationItems();
final int paginationSleepMillis = cfg.getProfileCrawlerPaginationSleepMillis();
Expand All @@ -182,14 +188,19 @@ public ArrayList<DownloadLink> decryptIt(final CryptedLink param, ProgressContro
int numberofNewItems = 0;
for (final Map<String, Object> image : images) {
final String imageurl = image.get("url").toString();
final String tempName = getFileNameFromURL(new URL(imageurl));
final String imageid = image.get("id").toString();
if (!dupes.add(imageid)) {
continue;
}
numberofNewItems++;
final DownloadLink link = this.createDownloadlink(br.getURL("/images/" + imageid).toExternalForm());
link._setFilePackage(fp);
final String tempName;
if (cfg.isUseIndexIDForImageFilename()) {
tempName = imageid + ".jpg";
} else {
tempName = getFileNameFromURL(new URL(imageurl));
}
if (tempName != null) {
link.setName(tempName);
}
Expand Down
Loading

0 comments on commit 028dde0

Please sign in to comment.