mirror of
https://github.com/kodjodevf/mangayomi-extensions.git
synced 2026-02-14 10:51:17 +00:00
extension(netflixMirror): updated cookie logic
This commit is contained in:
@@ -7,7 +7,7 @@ const mangayomiSources = [{
|
|||||||
"typeSource": "single",
|
"typeSource": "single",
|
||||||
"isManga": false,
|
"isManga": false,
|
||||||
"itemType": 1,
|
"itemType": 1,
|
||||||
"version": "0.0.9",
|
"version": "0.0.10",
|
||||||
"dateFormat": "",
|
"dateFormat": "",
|
||||||
"dateFormatLocale": "",
|
"dateFormatLocale": "",
|
||||||
"pkgPath": "anime/src/all/netflixmirror.js"
|
"pkgPath": "anime/src/all/netflixmirror.js"
|
||||||
@@ -30,19 +30,25 @@ class DefaultExtension extends MProvider {
|
|||||||
|
|
||||||
async getCookie() {
|
async getCookie() {
|
||||||
const preferences = new SharedPreferences();
|
const preferences = new SharedPreferences();
|
||||||
let cookie;
|
let cookie = preferences.getString("cookie", "");
|
||||||
cookie = preferences.getString("cookie", "");
|
var cookie_ts = parseInt(preferences.getString("cookie_ts", "0"));
|
||||||
const check = await new Client().get(`${this.source.baseUrl}/home`, { "cookie": cookie });
|
var now_ts = parseInt(new Date().getTime() / 1000);
|
||||||
const hDocBody = new Document(check.body).selectFirst("body")
|
|
||||||
const elements = hDocBody.select(".tray-container, #top10");
|
// Cookie lasts for 24hrs but still checking for 12hrs
|
||||||
if (elements && elements.length > 0) {
|
if (now_ts - cookie_ts > 60 * 60 * 12) {
|
||||||
return cookie;
|
const check = await new Client().get(`${this.source.baseUrl}/home`, { "cookie": cookie });
|
||||||
|
const hDocBody = new Document(check.body).selectFirst("body")
|
||||||
|
|
||||||
|
const addhash = hDocBody.attr("data-addhash");
|
||||||
|
const data_time = hDocBody.attr("data-time");
|
||||||
|
|
||||||
|
var res = await new Client().post(`${this.getTVApi()}/tv/p.php`, { "cookie": "" }, { "hash": addhash });
|
||||||
|
cookie = res.headers["set-cookie"];
|
||||||
|
preferences.setString("cookie", cookie);
|
||||||
|
preferences.setString("cookie_ts", data_time);
|
||||||
}
|
}
|
||||||
|
|
||||||
const addhash = hDocBody.attr("data-addhash");
|
|
||||||
var res = await new Client().post(`${this.getTVApi()}/tv/p.php`, { "cookie": "" }, { "hash": addhash });
|
|
||||||
cookie = res.headers["set-cookie"];
|
|
||||||
preferences.setString("cookie", cookie);
|
|
||||||
return cookie;
|
return cookie;
|
||||||
}
|
}
|
||||||
async request(url, cookie, tvApi = false) {
|
async request(url, cookie, tvApi = false) {
|
||||||
@@ -81,7 +87,7 @@ class DefaultExtension extends MProvider {
|
|||||||
const list = [];
|
const list = [];
|
||||||
data.searchResult.map(async (res) => {
|
data.searchResult.map(async (res) => {
|
||||||
const id = res.id;
|
const id = res.id;
|
||||||
list.push({ name: res.t, imageUrl: rhis.getPoster(id), link: id });
|
list.push({ name: res.t, imageUrl: this.getPoster(id), link: id });
|
||||||
})
|
})
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|||||||
Reference in New Issue
Block a user