Skip to content

Commit 0467b26

Browse files
author
updating-bot
committed
mirroring bot - 2024/10/17
1 parent 5a31725 commit 0467b26

File tree

18 files changed

+647
-567
lines changed

18 files changed

+647
-567
lines changed

svn_trunk/src/jd/plugins/AccountInfo.java

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -551,24 +551,21 @@ public List<String> setMultiHostSupportV2(final PluginForHost multiHostPlugin, f
551551
}
552552
best.add(plugin);
553553
}
554-
if (best.size() > 1) {
555-
unassignedMultiHostSupport.add(maindomainCleaned);
556-
if (logger != null) {
557-
logger.warning("Found more than one possible plugins for one domain: " + maindomainCleaned);
558-
logger.log(new Exception("DEBUG: " + maindomainCleaned));
559-
}
560-
continue cleanListLoop;
561-
} else if (best.size() == 0 && skippedByPluginAllowHandleEntries.size() == 0) {
562-
unassignedMultiHostSupport.add(maindomainCleaned);
563-
continue cleanListLoop;
564-
}
565554
final LazyHostPlugin finalplugin;
566555
if (best.size() == 1) {
567556
finalplugin = best.get(0);
568-
} else {
557+
} else if (skippedByPluginAllowHandleEntries.size() == plugins.size()) {
569558
/* Take first result of fallback list. */
570559
finalplugin = plugins.iterator().next();
571560
mhost.setStatus(MultihosterHostStatus.DEACTIVATED_JDOWNLOADER_NOT_ALLOWED_BY_ORIGINAL_PLUGIN);
561+
} else {
562+
/* Too many results and/or all results are for offline domains */
563+
unassignedMultiHostSupport.add(maindomainCleaned);
564+
if (best.size() > 1 && logger != null) {
565+
logger.warning("Found more than one possible plugins for one domain: " + maindomainCleaned);
566+
logger.log(new Exception("DEBUG: " + maindomainCleaned));
567+
}
568+
continue cleanListLoop;
572569
}
573570
final boolean hostIsWorkingAccordingToMultihost = mhost.getStatus() == MultihosterHostStatus.WORKING || mhost.getStatus() == MultihosterHostStatus.WORKING_UNSTABLE;
574571
final boolean printNonWorkingHosts = true;

svn_trunk/src/jd/plugins/MultiHostHost.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,10 @@ public boolean canDownload(final DownloadLink link) {
225225
}
226226
}
227227

228-
/** Returns custom set status text. Typically used to describe why this host is currently not working. */
228+
/**
229+
* Returns custom set status text. </br>
230+
* Typically used to describe why this host is currently not working but can also be used as an informative field.
231+
*/
229232
public String getStatusText() {
230233
return statusText;
231234
}

svn_trunk/src/jd/plugins/PluginForHost.java

Lines changed: 162 additions & 137 deletions
Large diffs are not rendered by default.

svn_trunk/src/jd/plugins/decrypter/AlldebridComFolder.java

Lines changed: 55 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,12 @@
1616
package jd.plugins.decrypter;
1717

1818
import java.util.ArrayList;
19+
import java.util.HashMap;
1920
import java.util.List;
2021
import java.util.Map;
2122
import java.util.regex.Pattern;
2223

2324
import org.appwork.storage.TypeRef;
24-
import org.appwork.utils.StringUtils;
2525
import org.appwork.utils.parser.UrlQuery;
2626
import org.jdownloader.scripting.JavaScriptEngineFactory;
2727

@@ -40,7 +40,7 @@
4040
import jd.plugins.PluginForDecrypt;
4141
import jd.plugins.hoster.AllDebridCom;
4242

43-
@DecrypterPlugin(revision = "$Revision: 49909 $", interfaceVersion = 3, names = {}, urls = {})
43+
@DecrypterPlugin(revision = "$Revision: 49981 $", interfaceVersion = 3, names = {}, urls = {})
4444
public class AlldebridComFolder extends PluginForDecrypt {
4545
public AlldebridComFolder(PluginWrapper wrapper) {
4646
super(wrapper);
@@ -91,75 +91,79 @@ public ArrayList<DownloadLink> decryptIt(final CryptedLink param, ProgressContro
9191
query.appendEncoded("agent", AllDebridCom.agent_raw);
9292
query.appendEncoded("apikey", AllDebridCom.getStoredApiKey(account));
9393
query.appendEncoded("id", magnetID);
94-
br.getPage(AllDebridCom.api_base + "/magnet/status?" + query.toString());
94+
/* When "jd" parameter is supplied, information which is unnecessary for JD will be excluded from json response. */
95+
query.appendEncoded("jd", "");
96+
br.getPage(AllDebridCom.api_base_41 + "/magnet/status?" + query.toString());
9597
final Map<String, Object> entries = restoreFromString(br.getRequest().getHtmlCode(), TypeRef.MAP);
9698
if (entries.containsKey("error")) {
9799
throw new PluginException(LinkStatus.ERROR_FILE_NOT_FOUND);
98100
}
99101
final Map<String, Object> magnet = (Map<String, Object>) JavaScriptEngineFactory.walkJson(entries, "data/magnets");
100102
final String torrentName = (String) magnet.get("filename");
101103
final String torrentNameEscaped = Pattern.quote(torrentName);
102-
final List<Map<String, Object>> resourcelist = (List<Map<String, Object>>) magnet.get("links");
104+
final List<Map<String, Object>> resourcelist = (List<Map<String, Object>>) magnet.get("files");
103105
if (resourcelist == null || resourcelist.isEmpty()) {
104106
/* Probably unfinished torrent download */
105107
throw new PluginException(LinkStatus.ERROR_FILE_NOT_FOUND);
106108
}
107-
final ArrayList<DownloadLink> ret = new ArrayList<DownloadLink>();
108109
final String folderRoot = torrentName;
109110
final FilePackage fpRoot = FilePackage.getInstance();
110111
fpRoot.setName(folderRoot);
111-
for (final Map<String, Object> resource : resourcelist) {
112-
final String url = resource.get("link").toString();
113-
final String filename = resource.get("filename").toString();
114-
final DownloadLink dl = this.createDownloadlink(url);
115-
dl.setName(filename);
116-
dl.setDownloadSize(((Number) resource.get("size")).longValue());
117-
final boolean isSpecialRar = filename.matches("^" + torrentNameEscaped + "(\\.rar|\\.part\\d+\\.rar)$");
118-
if (isSpecialRar) {
119-
dl.setRelativeDownloadFolderPath(folderRoot);
120-
dl._setFilePackage(fpRoot);
121-
} else {
122-
/* Check whether or not this file goes into a deeper subfolder level. */
123-
String filePath = getFilePath((List<Object>) resource.get("files"), "");
124-
/* Path is full path with filename at the end -> Remove that */
125-
filePath = filePath.replaceAll("/" + Pattern.quote(filename) + "$", "");
126-
if (!StringUtils.isEmpty(filePath)) {
127-
/* File that goes into (nested) subfolder. */
128-
dl.setRelativeDownloadFolderPath(folderRoot + filePath);
129-
final FilePackage nestedFilePackage = FilePackage.getInstance();
130-
nestedFilePackage.setName(folderRoot + filePath);
131-
dl._setFilePackage(nestedFilePackage);
132-
} else {
133-
/* File that is in the root of the torrent main folder (named after torrent name). */
134-
dl.setRelativeDownloadFolderPath(folderRoot);
135-
dl._setFilePackage(fpRoot);
136-
}
137-
}
138-
dl.setAvailable(true);
139-
ret.add(dl);
140-
}
112+
final ArrayList<DownloadLink> ret = new ArrayList<DownloadLink>();
113+
crawlRecursive(ret, new HashMap<String, FilePackage>(), resourcelist, torrentNameEscaped, torrentName);
141114
return ret;
142115
}
143116

144-
/** Recursive function which returns the complete path to a file inside nested json arrays. */
145-
private String getFilePath(final List<Object> subfolderList, String path) {
146-
if (subfolderList.isEmpty()) {
117+
private List<DownloadLink> crawlRecursive(final List<DownloadLink> results, final Map<String, FilePackage> fps, Object o, final String torrentNameEscaped, final String path) {
118+
if (o == null) {
147119
return null;
148120
}
149-
final Map<String, Object> entries = (Map<String, Object>) subfolderList.get(0);
150-
final Object subfolderNameO = entries.get("n");
151-
if (subfolderNameO == null) {
152-
return null;
153-
}
154-
final String subfolderName = (String) subfolderNameO;
155-
path += "/" + subfolderName;
156-
final Object nextSubFolderLevel = entries.get("e");
157-
if (nextSubFolderLevel == null) {
158-
/* We've reached the end */
159-
return path;
121+
if (o instanceof List) {
122+
for (final Object resourceO : (List<Object>) o) {
123+
this.crawlRecursive(results, fps, resourceO, torrentNameEscaped, path);
124+
}
125+
return results;
160126
} else {
161-
/* Go deeper */
162-
return this.getFilePath((List<Object>) nextSubFolderLevel, path);
127+
final Map<String, Object> resource = (Map<String, Object>) o;
128+
final String url = (String) resource.get("l");
129+
final String name = resource.get("n").toString();
130+
if (url != null) {
131+
/* Single file */
132+
final String folderRoot = new Regex(path, "^([^/]+)").getMatch(0);
133+
final DownloadLink dl = this.createDownloadlink(url);
134+
dl.setName(name);
135+
dl.setDownloadSize(((Number) resource.get("s")).longValue());
136+
final boolean isSpecialRar = name.matches("^" + torrentNameEscaped + "(\\.rar|\\.part\\d+\\.rar)$");
137+
if (isSpecialRar) {
138+
FilePackage fpRoot = fps.get(folderRoot);
139+
if (fpRoot == null) {
140+
fpRoot = FilePackage.getInstance();
141+
fpRoot.setName(folderRoot);
142+
fps.put(folderRoot, fpRoot);
143+
}
144+
dl.setRelativeDownloadFolderPath(folderRoot);
145+
dl._setFilePackage(fpRoot);
146+
} else {
147+
/* Remove filename from path. */
148+
final String filePath = path.replaceAll("/" + Pattern.quote(name) + "$", "");
149+
/* File that goes into (nested) subfolder. */
150+
dl.setRelativeDownloadFolderPath(filePath);
151+
FilePackage nestedFilePackage = fps.get(filePath);
152+
if (nestedFilePackage == null) {
153+
nestedFilePackage = FilePackage.getInstance();
154+
nestedFilePackage.setName(filePath);
155+
fps.put(filePath, nestedFilePackage);
156+
}
157+
dl._setFilePackage(nestedFilePackage);
158+
}
159+
dl.setAvailable(true);
160+
results.add(dl);
161+
} else {
162+
final List<Map<String, Object>> nextSubFolderLevel = (List<Map<String, Object>>) resource.get("e");
163+
/* Go deeper */
164+
return this.crawlRecursive(results, fps, nextSubFolderLevel, torrentNameEscaped, path + "/" + name);
165+
}
163166
}
167+
return results;
164168
}
165169
}

svn_trunk/src/jd/plugins/decrypter/GrosfichiersComFolder.java

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
import java.util.ArrayList;
1919
import java.util.List;
20+
import java.util.Locale;
2021

2122
import org.appwork.utils.formatter.SizeFormatter;
2223

@@ -25,15 +26,17 @@
2526
import jd.http.Browser;
2627
import jd.http.URLConnectionAdapter;
2728
import jd.nutils.encoding.Encoding;
29+
import jd.parser.Regex;
2830
import jd.plugins.CryptedLink;
2931
import jd.plugins.DecrypterPlugin;
3032
import jd.plugins.DownloadLink;
33+
import jd.plugins.FilePackage;
3134
import jd.plugins.LinkStatus;
3235
import jd.plugins.PluginException;
3336
import jd.plugins.PluginForDecrypt;
3437
import jd.plugins.hoster.DirectHTTP;
3538

36-
@DecrypterPlugin(revision = "$Revision: 49497 $", interfaceVersion = 3, names = {}, urls = {})
39+
@DecrypterPlugin(revision = "$Revision: 49975 $", interfaceVersion = 3, names = {}, urls = {})
3740
public class GrosfichiersComFolder extends PluginForDecrypt {
3841
public GrosfichiersComFolder(PluginWrapper wrapper) {
3942
super(wrapper);
@@ -43,6 +46,7 @@ public GrosfichiersComFolder(PluginWrapper wrapper) {
4346
public Browser createNewBrowserInstance() {
4447
final Browser br = super.createNewBrowserInstance();
4548
br.setFollowRedirects(true);
49+
br.setCookie(getHost(), "gf_lg", "en");
4650
return br;
4751
}
4852

@@ -75,6 +79,12 @@ public static String[] buildAnnotationUrls(final List<String[]> pluginDomains) {
7579
}
7680

7781
public ArrayList<DownloadLink> decryptIt(final CryptedLink param, ProgressController progress) throws Exception {
82+
final Regex urlinfo = new Regex(param.getCryptedUrl(), this.getSupportedLinks());
83+
final String folderID = urlinfo.getMatch(0);
84+
if (folderID.toLowerCase(Locale.ENGLISH).equals(folderID)) {
85+
/* Lowercase string -> Must be invalid e.g. https://www.grosfichiers.com/css */
86+
throw new PluginException(LinkStatus.ERROR_FILE_NOT_FOUND);
87+
}
7888
final ArrayList<DownloadLink> ret = new ArrayList<DownloadLink>();
7989
URLConnectionAdapter con = null;
8090
try {
@@ -96,9 +106,20 @@ public ArrayList<DownloadLink> decryptIt(final CryptedLink param, ProgressContro
96106
}
97107
final String thispath = br._getURL().getPath();
98108
final String[] links = br.getRegex("(/[A-Za-z0-9]+_[A-Za-z0-9]+)\"").getColumn(0);
109+
/*
110+
* Folders can be offline but still contain the file information so let's determine the offline status here and use it later in case
111+
* the files' information is still available.
112+
*/
113+
final boolean isOffline = br.containsHTML(">\\s*Sorry, the files are no longer available");
99114
if (links == null || links.length == 0) {
100-
throw new PluginException(LinkStatus.ERROR_PLUGIN_DEFECT);
115+
if (isOffline) {
116+
throw new PluginException(LinkStatus.ERROR_FILE_NOT_FOUND);
117+
} else {
118+
throw new PluginException(LinkStatus.ERROR_PLUGIN_DEFECT);
119+
}
101120
}
121+
final FilePackage fp = FilePackage.getInstance();
122+
fp.setName(folderID);
102123
final List<String> pathsWithoutDupes = new ArrayList<String>();
103124
for (final String path : links) {
104125
if (!path.equals(thispath) && !pathsWithoutDupes.contains(path)) {
@@ -127,7 +148,12 @@ public ArrayList<DownloadLink> decryptIt(final CryptedLink param, ProgressContro
127148
final String filename = filenames[i];
128149
direct.setName(Encoding.htmlDecode(filename).trim());
129150
}
130-
direct.setAvailable(true);
151+
if (isOffline) {
152+
direct.setAvailable(false);
153+
} else {
154+
direct.setAvailable(true);
155+
}
156+
direct._setFilePackage(fp);
131157
ret.add(direct);
132158
}
133159
if (ret.isEmpty()) {

0 commit comments

Comments
 (0)