use of com.firenio.codec.http11.Cookie in project BaseProject by feer921.
the class SerializableCookie method parseCursorToBean.
public static SerializableCookie parseCursorToBean(Cursor cursor) {
String host = cursor.getString(cursor.getColumnIndex(HOST));
byte[] cookieBytes = cursor.getBlob(cursor.getColumnIndex(COOKIE));
Cookie cookie = bytesToCookie(cookieBytes);
return new SerializableCookie(host, cookie);
}
use of com.firenio.codec.http11.Cookie in project BaseProject by feer921.
the class DBCookieStore method saveCookie.
@Override
public synchronized void saveCookie(HttpUrl url, Cookie cookie) {
if (!cookies.containsKey(url.host())) {
cookies.put(url.host(), new ConcurrentHashMap<String, Cookie>());
}
// 当前cookie是否过期
if (isCookieExpired(cookie)) {
removeCookie(url, cookie);
} else {
// 内存缓存
cookies.get(url.host()).put(getCookieToken(cookie), cookie);
// 数据库缓存
SerializableCookie serializableCookie = new SerializableCookie(url.host(), cookie);
CookieManager.getInstance().replace(serializableCookie);
}
}
use of com.firenio.codec.http11.Cookie in project BaseProject by feer921.
the class SPCookieStore method loadCookie.
/**
* 根据当前url获取所有需要的cookie,只返回没有过期的cookie
*/
@Override
public synchronized List<Cookie> loadCookie(HttpUrl url) {
List<Cookie> ret = new ArrayList<>();
if (!cookies.containsKey(url.host()))
return ret;
Collection<Cookie> urlCookies = cookies.get(url.host()).values();
for (Cookie cookie : urlCookies) {
if (isCookieExpired(cookie)) {
removeCookie(url, cookie);
} else {
ret.add(cookie);
}
}
return ret;
}
use of com.firenio.codec.http11.Cookie in project BaseProject by feer921.
the class MemoryCookieStore method saveCookie.
@Override
public synchronized void saveCookie(HttpUrl url, List<Cookie> cookies) {
List<Cookie> oldCookies = memoryCookies.get(url.host());
List<Cookie> needRemove = new ArrayList<>();
for (Cookie newCookie : cookies) {
for (Cookie oldCookie : oldCookies) {
if (newCookie.name().equals(oldCookie.name())) {
needRemove.add(oldCookie);
}
}
}
oldCookies.removeAll(needRemove);
oldCookies.addAll(cookies);
}
use of com.firenio.codec.http11.Cookie in project MiMangaNu by raulhaag.
the class KissManga method chapterInit.
@Override
public synchronized void chapterInit(Chapter chapter) throws Exception {
if (chapter.getPages() == 0) {
int pages = 0;
Response response = Navigator.getInstance().getResponse(HOST + chapter.getPath());
String source = response.body().string();
if (source.contains("class=\"g-recaptcha\"")) {
throw new Exception(context.getString(R.string.server_uses_captcha));
// Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(HOST + chapter.getPath()));
// context.startActivity(browserIntent);
}
if (source.contains("this captcha")) {
if (RequestWebViewUserAction.isRequestAvailable()) {
List<Cookie> cookies = Navigator.getCookieJar().loadForRequest(HttpUrl.parse(HOST + chapter.getPath()));
StringBuilder sb = new StringBuilder();
for (Cookie cookie : cookies) {
sb.append(cookie.name()).append("=").append(cookie.value()).append(";");
}
RequestWebViewUserAction.makeRequest(response.request().url().toString(), null, source.replaceAll("\"\\/\\/ads.+?\"", "").replaceAll("<.script>\\s<.div>\\s(<[\\s\\S]+?)<div id=\"footer\">", ""));
chapterInit(chapter);
return;
} else {
throw new Exception("User action required but unavailable");
}
}
String ca = getNavigatorAndFlushParameters().get(HOST + "/Scripts/ca.js");
String lo = getNavigatorAndFlushParameters().get(HOST + "/Scripts/lo.js");
try {
Duktape duktape = Duktape.create();
duktape.evaluate(ca);
duktape.evaluate(lo);
Pattern p = Pattern.compile("javascript\">(.+?)<", Pattern.DOTALL);
Matcher m = p.matcher(source);
while (m.find()) {
if (m.group(1).contains("CryptoJS")) {
duktape.evaluate(m.group(1));
}
}
p = Pattern.compile("lstOLA.push\\((wrap.+?\\))\\)", Pattern.DOTALL);
m = p.matcher(source);
StringBuilder sb = new StringBuilder();
String image;
while (m.find()) {
pages++;
image = (String) duktape.evaluate(m.group(1) + ".toString()");
sb.append("|").append(image);
}
chapter.setExtra(sb.toString());
} catch (Exception ignored) {
}
chapter.setPages(pages);
}
}
Aggregations