mirror of
https://github.com/mirror/jdownloader.git
synced 2024-11-27 05:50:51 +00:00
PornHubCom:
-updated getFirstPageWithAccount to auto learn new accessAge cookies build>full git-svn-id: svn://svn.jdownloader.org/jdownloader/trunk@48037 ebf7c1c2-ba36-0410-9fe8-c592906822b4 Former-commit-id: e38936c2dfacd9bf9013e9d3efce7793a5549c3a
This commit is contained in:
parent
a3a2b95462
commit
d723c3c076
@ -38,23 +38,6 @@ import javax.script.ScriptEngine;
|
||||
import javax.script.ScriptEngineManager;
|
||||
import javax.script.ScriptException;
|
||||
|
||||
import org.appwork.storage.JSonMapperException;
|
||||
import org.appwork.storage.JSonStorage;
|
||||
import org.appwork.storage.TypeRef;
|
||||
import org.appwork.utils.ReflectionUtils;
|
||||
import org.appwork.utils.StringUtils;
|
||||
import org.appwork.utils.net.httpconnection.HTTPConnection;
|
||||
import org.appwork.utils.net.httpconnection.SSLSocketStreamOptions;
|
||||
import org.appwork.utils.net.httpconnection.SSLSocketStreamOptionsModifier;
|
||||
import org.jdownloader.downloader.hls.HLSDownloader;
|
||||
import org.jdownloader.downloader.hls.M3U8Playlist;
|
||||
import org.jdownloader.gui.translate._GUI;
|
||||
import org.jdownloader.logging.LogController;
|
||||
import org.jdownloader.net.BCSSLSocketStreamFactory;
|
||||
import org.jdownloader.plugins.components.hls.HlsContainer;
|
||||
import org.jdownloader.plugins.controller.LazyPlugin;
|
||||
import org.jdownloader.scripting.JavaScriptEngineFactory;
|
||||
|
||||
import jd.PluginWrapper;
|
||||
import jd.config.ConfigContainer;
|
||||
import jd.config.ConfigEntry;
|
||||
@ -86,6 +69,23 @@ import jd.plugins.PluginException;
|
||||
import jd.plugins.PluginForHost;
|
||||
import jd.plugins.decrypter.PornHubComVideoCrawler;
|
||||
|
||||
import org.appwork.storage.JSonMapperException;
|
||||
import org.appwork.storage.JSonStorage;
|
||||
import org.appwork.storage.TypeRef;
|
||||
import org.appwork.utils.ReflectionUtils;
|
||||
import org.appwork.utils.StringUtils;
|
||||
import org.appwork.utils.net.httpconnection.HTTPConnection;
|
||||
import org.appwork.utils.net.httpconnection.SSLSocketStreamOptions;
|
||||
import org.appwork.utils.net.httpconnection.SSLSocketStreamOptionsModifier;
|
||||
import org.jdownloader.downloader.hls.HLSDownloader;
|
||||
import org.jdownloader.downloader.hls.M3U8Playlist;
|
||||
import org.jdownloader.gui.translate._GUI;
|
||||
import org.jdownloader.logging.LogController;
|
||||
import org.jdownloader.net.BCSSLSocketStreamFactory;
|
||||
import org.jdownloader.plugins.components.hls.HlsContainer;
|
||||
import org.jdownloader.plugins.controller.LazyPlugin;
|
||||
import org.jdownloader.scripting.JavaScriptEngineFactory;
|
||||
|
||||
@HostPlugin(revision = "$Revision$", interfaceVersion = 3, names = {}, urls = {})
|
||||
@PluginDependencies(dependencies = { PornHubComVideoCrawler.class })
|
||||
public class PornHubCom extends PluginForHost {
|
||||
@ -360,19 +360,43 @@ public class PornHubCom extends PluginForHost {
|
||||
}
|
||||
|
||||
public static Request getFirstPageWithAccount(final PornHubCom plg, final Account account, final String url) throws Exception {
|
||||
if (account == null) {
|
||||
return getPage(plg.getBrowser(), url);
|
||||
} else {
|
||||
synchronized (account) {
|
||||
final boolean verifiedLogin = plg.login(account, false);
|
||||
final Request request = getPage(plg.getBrowser(), url);
|
||||
if (!isLoggedInHtml(plg.getBrowser())) {
|
||||
plg.getLogger().info("Not logged in?|VerifiedLogin:" + verifiedLogin);
|
||||
plg.login(account, true);
|
||||
return getPage(plg.getBrowser(), url);
|
||||
} else {
|
||||
synchronized (DEFAULT_COOKIES) {
|
||||
final Browser br = plg.getBrowser();
|
||||
if (account == null) {
|
||||
while (true) {
|
||||
final Request request = getPage(br, url);
|
||||
final String accessAgeCookie[] = new Regex(request.getHtmlCode(), "setCookieAdvanced\\s*\\(\\s*'(accessAge[^']+)'\\s*,\\s*([^,]+),").getRow(0);
|
||||
if (accessAgeCookie != null) {
|
||||
if (!DEFAULT_COOKIES.containsKey(accessAgeCookie[0])) {
|
||||
plg.getLogger().info("Auto-Learn new accessAge cookie:" + Arrays.toString(accessAgeCookie));
|
||||
DEFAULT_COOKIES.put(accessAgeCookie[0], accessAgeCookie[1].trim());
|
||||
setDefaultCookies(br, br.getBaseURL());
|
||||
continue;
|
||||
}
|
||||
}
|
||||
return request;
|
||||
}
|
||||
} else {
|
||||
while (true) {
|
||||
final boolean verifiedLogin = plg.login(account, false);
|
||||
final Request request = getPage(br, url);
|
||||
final String accessAgeCookie[] = new Regex(request.getHtmlCode(), "setCookieAdvanced\\s*\\(\\s*'(accessAge[^']+)'\\s*,\\s*([^,]+),").getRow(0);
|
||||
if (accessAgeCookie != null) {
|
||||
if (!DEFAULT_COOKIES.containsKey(accessAgeCookie[0])) {
|
||||
plg.getLogger().info("Auto-Learn new accessAge cookie:" + Arrays.toString(accessAgeCookie));
|
||||
DEFAULT_COOKIES.put(accessAgeCookie[0], accessAgeCookie[1].trim());
|
||||
setDefaultCookies(br, br.getBaseURL());
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (!isLoggedInHtml(br)) {
|
||||
plg.getLogger().info("Not logged in?|VerifiedLogin:" + verifiedLogin);
|
||||
plg.login(account, true);
|
||||
continue;
|
||||
} else {
|
||||
return request;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1217,8 +1241,8 @@ public class PornHubCom extends PluginForHost {
|
||||
if (premiumExpired && !isPremiumDomain(br.getHost())) {
|
||||
/**
|
||||
* Expired pornhub premium --> It should still be a valid free account --> We might need to access a special url
|
||||
* which redirects us to the pornhub free mainpage and sets the cookies. </br>
|
||||
* 2022-06-27: Old code but let's leave it in for now as we can't know if it is still needed.
|
||||
* which redirects us to the pornhub free mainpage and sets the cookies. </br> 2022-06-27: Old code but let's leave
|
||||
* it in for now as we can't know if it is still needed.
|
||||
*/
|
||||
logger.info("Expired premium --> Free account (?)");
|
||||
final String pornhubMainpageCookieRedirectUrl = br.getRegex("\\'pornhubLink\\'\\s*?:\\s*?(?:\"|\\')(https?://(?:www\\.)?pornhub\\.(?:com|org)/[^<>\"\\']+)(?:\"|\\')").getMatch(0);
|
||||
@ -1271,8 +1295,7 @@ public class PornHubCom extends PluginForHost {
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks login and sets account-type. </br>
|
||||
* Expects browser instance to be logged in already (cookies need to be there).
|
||||
* Checks login and sets account-type. </br> Expects browser instance to be logged in already (cookies need to be there).
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
@ -1568,12 +1591,23 @@ public class PornHubCom extends PluginForHost {
|
||||
return br;
|
||||
}
|
||||
|
||||
private static Map<String, String> DEFAULT_COOKIES = new HashMap<String, String>();
|
||||
static {
|
||||
synchronized (DEFAULT_COOKIES) {
|
||||
DEFAULT_COOKIES.put("accessAgeDisclaimerPH", "1");
|
||||
DEFAULT_COOKIES.put("accessAgeDisclaimerUK", "1");// 2023-07-19
|
||||
/* 2023-04-14: STATE OF UTAH WARNING */
|
||||
DEFAULT_COOKIES.put("accessPH", "1");
|
||||
}
|
||||
}
|
||||
|
||||
private static void setDefaultCookies(final Browser br, final String domain) {
|
||||
br.setCookie(domain, "cookiesBannerSeen", "1");
|
||||
br.setCookie(domain, "accessAgeDisclaimerPH", "1");
|
||||
br.setCookie(domain, "accessAgeDisclaimerUK", "1"); // 2023-07-19
|
||||
/* 2023-04-14: STATE OF UTAH WARNING */
|
||||
br.setCookie(domain, "accessPH", "1");
|
||||
synchronized (DEFAULT_COOKIES) {
|
||||
for (Map.Entry<String, String> defaultCookie : DEFAULT_COOKIES.entrySet()) {
|
||||
br.setCookie(domain, defaultCookie.getKey(), defaultCookie.getValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void setEnglishLangCookie(final Browser br, final String domain) {
|
||||
|
@ -158,7 +158,7 @@ public abstract class LazyPlugin<T extends Plugin> implements MinTimeWeakReferen
|
||||
COOKIE_LOGIN_ONLY {
|
||||
@Override
|
||||
public String getLabel() {
|
||||
return _JDT.T.LazyHostPlugin_FEATURE_COOKIE_ONLY();
|
||||
return _JDT.T.LazyHostPlugin_FEATURE_COOKIE_LOGIN_ONLY();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -174,7 +174,7 @@ public abstract class LazyPlugin<T extends Plugin> implements MinTimeWeakReferen
|
||||
|
||||
@Override
|
||||
public String getTooltip() {
|
||||
return _JDT.T.LazyHostPlugin_FEATURE_COOKIE_OPTIONAL_TOOLTIP();
|
||||
return _JDT.T.LazyHostPlugin_FEATURE_COOKIE_LOGIN_OPTIONAL_TOOLTIP();
|
||||
}
|
||||
};
|
||||
public static final long CACHEVERSION = Math.abs(StringUtils.join(values(), "<->").hashCode()) + Math.abs(StringUtils.join(values(), ":").hashCode()) + Math.abs(StringUtils.join(values(), "<=>").hashCode());
|
||||
|
@ -1078,10 +1078,10 @@ public interface JdownloaderTranslation extends TranslateInterface {
|
||||
String LazyHostPlugin_FEATURE_COOKIE_LOGIN_OPTIONAL();
|
||||
|
||||
@Default(lngs = { "en" }, values = { "This plugin also supports login via cookies" })
|
||||
String LazyHostPlugin_FEATURE_COOKIE_OPTIONAL_TOOLTIP();
|
||||
String LazyHostPlugin_FEATURE_COOKIE_LOGIN_OPTIONAL_TOOLTIP();
|
||||
|
||||
@Default(lngs = { "en" }, values = { "Cookie login only" })
|
||||
String LazyHostPlugin_FEATURE_COOKIE_ONLY();
|
||||
String LazyHostPlugin_FEATURE_COOKIE_LOGIN_ONLY();
|
||||
|
||||
@Default(lngs = { "en" }, values = { "This plugin only supports login via cookies" })
|
||||
String LazyHostPlugin_FEATURE_COOKIE_LOGIN_ONLY_TOOLTIP();
|
||||
|
Loading…
Reference in New Issue
Block a user