Skip to content

Commit

Permalink
mirroring bot - 2025/01/28
Browse files Browse the repository at this point in the history
  • Loading branch information
updating-bot committed Jan 28, 2025
1 parent 1139e44 commit 89f83ac
Show file tree
Hide file tree
Showing 16 changed files with 717 additions and 63 deletions.
17 changes: 11 additions & 6 deletions svn_trunk/src/jd/plugins/decrypter/IssuuCom.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import java.util.List;
import java.util.Map;

import org.appwork.storage.JSonStorage;
import org.appwork.storage.TypeRef;
import org.jdownloader.plugins.components.config.IssuuComConfig;
import org.jdownloader.plugins.config.PluginJsonConfig;
Expand All @@ -37,7 +36,7 @@
import jd.plugins.PluginException;
import jd.plugins.PluginForDecrypt;

@DecrypterPlugin(revision = "$Revision: 48194 $", interfaceVersion = 2, names = { "issuu.com" }, urls = { "https?://(?:www\\.)?issuu\\.com/[a-z0-9\\-_\\.]+/docs/[a-z0-9\\-_\\.]+|https?://e\\.issuu\\.com/embed\\.html#\\d+/\\d+" })
@DecrypterPlugin(revision = "$Revision: 50515 $", interfaceVersion = 2, names = { "issuu.com" }, urls = { "https?://(?:www\\.)?issuu\\.com/[a-z0-9\\-_\\.]+/docs/[a-z0-9\\-_\\.]+|https?://e\\.issuu\\.com/embed\\.html#\\d+/\\d+" })
public class IssuuCom extends PluginForDecrypt {
public IssuuCom(PluginWrapper wrapper) {
super(wrapper);
Expand Down Expand Up @@ -80,15 +79,15 @@ public ArrayList<DownloadLink> decryptIt(final CryptedLink param, ProgressContro
ownerUsername = urlinfo.getMatch(0);
documentURI = urlinfo.getMatch(1);
}
br.getPage("https://api.issuu.com/call/backend-reader3/dynamic/" + ownerUsername + "/" + documentURI);
br.getPage("https://issuu.com/call/reader/dynamic/" + ownerUsername + "/" + documentURI);
if (isOffline(br)) {
/* E.g. {"message":"Document does not exist"} */
throw new PluginException(LinkStatus.ERROR_FILE_NOT_FOUND);
}
final Map<String, Object> docInfo = restoreFromString(br.toString(), TypeRef.MAP);
final Map<String, Object> docInfo = restoreFromString(br.getRequest().getHtmlCode(), TypeRef.MAP);
final Map<String, Object> metadata = (Map<String, Object>) docInfo.get("metadata");
br.getPage("https://reader3.isu.pub/" + ownerUsername + "/" + documentURI + "/reader3_4.json");
Map<String, Object> docInfo2 = restoreFromString(br.toString(), TypeRef.MAP);
Map<String, Object> docInfo2 = restoreFromString(br.getRequest().getHtmlCode(), TypeRef.MAP);
final Map<String, Object> document = (Map<String, Object>) docInfo2.get("document");
final List<Map<String, Object>> pages = (List<Map<String, Object>>) document.get("pages");
// final String username = docInfo.get("userDisplayName").toString();
Expand Down Expand Up @@ -124,7 +123,13 @@ public ArrayList<DownloadLink> decryptIt(final CryptedLink param, ProgressContro
}

private boolean isOffline(final Browser br) {
return br.getHttpConnection().getResponseCode() == 403 || br.getHttpConnection().getResponseCode() == 404;
if (br.getHttpConnection().getResponseCode() == 403) {
return true;
} else if (br.getHttpConnection().getResponseCode() == 404) {
return true;
} else {
return false;
}
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
import jd.plugins.hoster.DirectHTTP;
import jd.plugins.hoster.NaughtyamericaCom;

@DecrypterPlugin(revision = "$Revision: 49968 $", interfaceVersion = 2, names = { "naughtyamerica.com" }, urls = { "https?://(?:members|tour|www)\\.naughtyamerica\\.com/scene/[a-z0-9\\-]+\\-\\d+" })
@DecrypterPlugin(revision = "$Revision: 50515 $", interfaceVersion = 2, names = { "naughtyamerica.com" }, urls = { "https?://(?:members|tour|www)\\.naughtyamerica\\.com/scene/[a-z0-9\\-]+\\-\\d+" })
public class NaughtyamericaComCrawler extends PluginForDecrypt {
private NaughtyamericaConfig cfg;

Expand Down Expand Up @@ -91,7 +91,7 @@ private DownloadLink getPreferredVariant(List<DownloadLink> entries, boolean pre
return entries.get(0);
}

public ArrayList<DownloadLink> crawlContent(final CryptedLink param, final boolean ignoreQualitySelection) throws Exception {
public ArrayList<DownloadLink> crawlContent(final CryptedLink param, boolean ignoreQualitySelection) throws Exception {
cfg = PluginJsonConfig.get(NaughtyamericaConfig.class);
final ArrayList<DownloadLink> ret = new ArrayList<DownloadLink>();
/* 2016-12-12: Prefer current website instead of beta */
Expand Down Expand Up @@ -244,7 +244,8 @@ public ArrayList<DownloadLink> crawlContent(final CryptedLink param, final boole
ret.addAll(unknownQualities);
}
if (ret.isEmpty()) {
throw new DecrypterRetryException(RetryReason.PLUGIN_SETTINGS, "FAILED_TO_FIND_ANY_SELECTED_QUALITY_" + urlSlug, "None of your selected qualities have been found. Select all to get results.");
logger.info("User configured plugin in a way that would return zero results -> Returning all instead");
ignoreQualitySelection = true;
}
} else {
/* Fallback: Add all unknown qualities */
Expand Down
4 changes: 2 additions & 2 deletions svn_trunk/src/jd/plugins/decrypter/TbCmV2.java
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@
import jd.plugins.components.UserAgents;
import jd.plugins.components.UserAgents.BrowserName;

@DecrypterPlugin(revision = "$Revision: 50453 $", interfaceVersion = 3, names = {}, urls = {})
@DecrypterPlugin(revision = "$Revision: 50518 $", interfaceVersion = 3, names = {}, urls = {})
public class TbCmV2 extends PluginForDecrypt {
/* Shorted wait time between requests when JDownloader is run in IDE to allow for faster debugging. */
private static final int DDOS_WAIT_MAX = Application.isJared(null) ? 1000 : 10;
Expand Down Expand Up @@ -135,7 +135,7 @@ public String[] siteSupportedNames() {
public static String[] getAnnotationUrls() {
final List<String> ret = new ArrayList<String>();
for (final String[] domains : getPluginDomains()) {
String pattern = "https?://(?:www\\.)?" + buildHostsPatternPart(domains) + "/";
String pattern = "https?://(?:(?:www|m)\\.)?" + buildHostsPatternPart(domains) + "/";
pattern += "(";
pattern += "embed(\\?v=|/)" + VIDEO_ID_PATTERN + ".*";
pattern += "|live/" + VIDEO_ID_PATTERN;
Expand Down
284 changes: 284 additions & 0 deletions svn_trunk/src/jd/plugins/hoster/AnonServices.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,284 @@
//jDownloader - Downloadmanager
//Copyright (C) 2009 JD-Team [email protected]
//
//This program is free software: you can redistribute it and/or modify
//it under the terms of the GNU General Public License as published by
//the Free Software Foundation, either version 3 of the License, or
//(at your option) any later version.
//
//This program is distributed in the hope that it will be useful,
//but WITHOUT ANY WARRANTY; without even the implied warranty of
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
//GNU General Public License for more details.
//
//You should have received a copy of the GNU General Public License
//along with this program. If not, see <http://www.gnu.org/licenses/>.
package jd.plugins.hoster;

import java.io.IOException;
import java.net.MalformedURLException;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
import java.util.Map;

import org.appwork.storage.TypeRef;
import org.appwork.utils.StringUtils;
import org.appwork.utils.net.URLHelper;
import org.appwork.utils.parser.UrlQuery;

import jd.PluginWrapper;
import jd.http.Browser;
import jd.nutils.encoding.Encoding;
import jd.parser.Regex;
import jd.plugins.Account;
import jd.plugins.DownloadLink;
import jd.plugins.DownloadLink.AvailableStatus;
import jd.plugins.HostPlugin;
import jd.plugins.LinkStatus;
import jd.plugins.PluginException;
import jd.plugins.PluginForHost;
import jd.plugins.download.HashInfo;

@HostPlugin(revision = "$Revision: 50518 $", interfaceVersion = 3, names = {}, urls = {})
public class AnonServices extends PluginForHost {
public AnonServices(PluginWrapper wrapper) {
super(wrapper);
// this.enablePremium("");
}

public static String API_BASE = "https://anon.services/api";
private final String PROPERTY_ALLOW_DOWNLOAD_PASSWORD_FROM_URL = "allow_download_password_from_url";

@Override
public Browser createNewBrowserInstance() {
final Browser br = super.createNewBrowserInstance();
br.setFollowRedirects(true);
br.getHeaders().put("User-Agent", "JDownloader");
return br;
}

@Override
public String getAGBLink() {
return "https://" + getHost() + "/terms";
}

private static List<String[]> getPluginDomains() {
final List<String[]> ret = new ArrayList<String[]>();
// each entry in List<String[]> will result in one PluginForHost, Plugin.getHost() will return String[0]->main domain
ret.add(new String[] { "anon.services" });
return ret;
}

public static String[] getAnnotationNames() {
return buildAnnotationNames(getPluginDomains());
}

@Override
public String[] siteSupportedNames() {
return buildSupportedNames(getPluginDomains());
}

public static String[] getAnnotationUrls() {
final List<String> ret = new ArrayList<String>();
for (final String[] domains : getPluginDomains()) {
ret.add("https?://(?:www\\.)?" + buildHostsPatternPart(domains) + "/(?:download|file)/([A-Fa-f0-9\\-]{32,}).*");
}
return ret.toArray(new String[0]);
}

@Override
public String getLinkID(final DownloadLink link) {
final String fid = getFID(link);
if (fid != null) {
return this.getHost() + "://" + fid;
} else {
return super.getLinkID(link);
}
}

private boolean looksLikeValidFileID(final String str) {
if (str == null) {
return false;
} else if (!str.replace("-", "").matches("[a-f0-9]{32}")) {
return false;
} else {
return true;
}
}

private String getFID(final DownloadLink link) {
String fid = new Regex(link.getPluginPatternMatcher(), this.getSupportedLinks()).getMatch(0);
if (fid == null) {
return null;
}
/* API does not like uppercase! */
fid = fid.toLowerCase(Locale.ENGLISH);
return fid;
}

@Override
public boolean isResumeable(final DownloadLink link, final Account account) {
return true;
}

public int getMaxChunks(final DownloadLink link, final Account account) {
return 0;
}

private String getFileURL(final DownloadLink link, final String passCode) throws MalformedURLException {
String url = "https://" + getHost() + "/file/" + this.getFID(link);
if (passCode != null) {
url += "?file_pw=" + Encoding.urlEncode(passCode);
}
return url;
}

private String getContentURL(final DownloadLink link) throws MalformedURLException {
return getContentURL(link, link.getDownloadPassword());
}

private String getContentURL(final DownloadLink link, final String passCode) throws MalformedURLException {
String url;
if (passCode != null) {
url = URLHelper.getUrlWithoutParams(link.getPluginPatternMatcher());
url += "?file_pw=" + Encoding.urlEncode(passCode);
} else {
url = link.getPluginPatternMatcher();
}
return url;
}

@Override
public AvailableStatus requestFileInformation(final DownloadLink link) throws IOException, PluginException {
final String fid = this.getFID(link);
if (!link.isNameSet()) {
/* Fallback */
link.setName(fid);
} else if (!this.looksLikeValidFileID(fid)) {
throw new PluginException(LinkStatus.ERROR_FILE_NOT_FOUND);
}
this.setBrowserExclusive();
br.getPage(API_BASE + "/files/" + fid);
if (br.getHttpConnection().getResponseCode() == 403) {
/* We know that the file is online but we cannot get more information. */
/* E.g. {"error":"Folder password required or invalid"} */
link.setPasswordProtected(true);
return AvailableStatus.TRUE;
} else if (br.getHttpConnection().getResponseCode() == 404) {
/* E.g. {"msg":"File not found"} */
throw new PluginException(LinkStatus.ERROR_FILE_NOT_FOUND);
}
/* If we reach this, that file is definitely not password protected. */
link.setPasswordProtected(false);
final Map<String, Object> entries = restoreFromString(br.getRequest().getHtmlCode(), TypeRef.MAP);
/* Check for other/unknown errors */
final String msg = (String) entries.get("msg");
if (msg != null) {
throw new PluginException(LinkStatus.ERROR_FATAL, msg);
}
link.setFinalFileName(entries.get("filename").toString());
link.setVerifiedFileSize(((Number) entries.get("size")).longValue());
if (Boolean.TRUE.equals(entries.get("banned"))) {
throw new PluginException(LinkStatus.ERROR_FILE_NOT_FOUND, "File is banned");
}
return AvailableStatus.TRUE;
}

@Override
public void handleFree(final DownloadLink link) throws Exception, PluginException {
handleDownload(link);
}

private void handleDownload(final DownloadLink link) throws Exception, PluginException {
requestFileInformation(link);
String dllink = "https://" + getHost() + "/download/" + this.getFID(link);
String filePasswordQueryPart = "";
String passCode = null;
final boolean allowPassCodeFromURL = link.getBooleanProperty(PROPERTY_ALLOW_DOWNLOAD_PASSWORD_FROM_URL, true);
final String passCodeFromURL = allowPassCodeFromURL ? UrlQuery.parse(link.getPluginPatternMatcher()).get("file_pw") : null;
if (link.isPasswordProtected()) {
passCode = passCodeFromURL;
if (passCode == null) {
passCode = link.getDownloadPassword();
if (passCode == null) {
passCode = getUserInput("Password?", link);
}
}
filePasswordQueryPart = "?file_pw=" + Encoding.urlEncode(passCode);
dllink += filePasswordQueryPart;
}
if (link.getHashInfo() == null && org.jdownloader.settings.staticreferences.CFG_GENERAL.CFG.isHashCheckEnabled()) {
/* Crawl file hashes via website as API does not provide them. */
logger.info("Crawling file hashes");
final Browser brc = br.cloneBrowser();
/* Ensure that this also works for password protected links. */
brc.getPage(this.getFileURL(link, passCode));
checkErrorsWebsite(brc, link);
final String hash_sha256 = brc.getRegex("SHA256:\\s*([a-f0-9]{64})").getMatch(0);
final String hash_sha1 = brc.getRegex("SHA1:\\s*([a-f0-9]{40})").getMatch(0);
final String hash_md5 = brc.getRegex("MD5:\\s*([a-f0-9]{32})").getMatch(0);
final String hash_crc32 = brc.getRegex("CRC32:\\s*([a-f0-9]{8})").getMatch(0);
/* Set hashes for CRC check */
if (!StringUtils.isEmpty(hash_crc32)) {
link.addHashInfo(HashInfo.newInstanceSafe(hash_crc32, HashInfo.TYPE.CRC32));
}
if (!StringUtils.isEmpty(hash_md5)) {
link.addHashInfo(HashInfo.newInstanceSafe(hash_md5, HashInfo.TYPE.MD5));
}
if (!StringUtils.isEmpty(hash_sha1)) {
link.addHashInfo(HashInfo.newInstanceSafe(hash_sha1, HashInfo.TYPE.SHA1));
}
if (!StringUtils.isEmpty(hash_sha256)) {
link.addHashInfo(HashInfo.newInstanceSafe(hash_sha256, HashInfo.TYPE.SHA256));
}
if (link.getHashInfo() == null) {
logger.warning("Failed to find any file hashes");
}
}
dl = jd.plugins.BrowserAdapter.openDownload(br, link, dllink, this.isResumeable(link, null), this.getMaxChunks(link, null));
if (!this.looksLikeDownloadableContent(dl.getConnection())) {
br.followConnection(true);
checkErrorsWebsite(br, link);
throwConnectionExceptions(br, dl.getConnection());
throwFinalConnectionException(br, dl.getConnection());
/* Dead-end */
}
if (passCode != null && !StringUtils.equals(link.getDownloadPassword(), passCode)) {
/* Store for later usage */
logger.info("Found valid download password: " + passCode);
link.setDownloadPassword(passCode);
}
dl.startDownload();
}

private void checkErrorsWebsite(final Browser br, final DownloadLink link) throws PluginException {
if (br.getHttpConnection().getResponseCode() == 404) {
/* E.g. {"msg":"File not found"} */
throw new PluginException(LinkStatus.ERROR_FILE_NOT_FOUND);
} else if (isPasswordProtectedWebsite(br)) {
if (!link.isPasswordProtected()) {
/* This shall never happen as the correct password protected status should have been set before. */
logger.info("Got unespected 'file is password protected' message.");
link.setPasswordProtected(true);
}
link.setDownloadPassword(null);
link.setProperty(PROPERTY_ALLOW_DOWNLOAD_PASSWORD_FROM_URL, false);
throw new PluginException(LinkStatus.ERROR_RETRY, "Wrong password entered");
}
}

private boolean isPasswordProtectedWebsite(final Browser br) {
return br.containsHTML(">\\s*File is password protected");
}

@Override
public boolean hasCaptcha(DownloadLink link, jd.plugins.Account acc) {
return false;
}

@Override
public int getMaxSimultanFreeDownloadNum() {
return Integer.MAX_VALUE;
}
}
Loading

0 comments on commit 89f83ac

Please sign in to comment.