mirror of
https://github.com/kodjodevf/mangayomi-extensions.git
synced 2026-02-14 10:51:17 +00:00
Merge pull request #206 from Swakshan/anime/netmirror
Update: Netmirror
This commit is contained in:
@@ -7,21 +7,29 @@ const mangayomiSources = [{
|
|||||||
"iconUrl": "https://raw.githubusercontent.com/kodjodevf/mangayomi-extensions/main/javascript/icon/all.netflixmirror.png",
|
"iconUrl": "https://raw.githubusercontent.com/kodjodevf/mangayomi-extensions/main/javascript/icon/all.netflixmirror.png",
|
||||||
"typeSource": "single",
|
"typeSource": "single",
|
||||||
"itemType": 1,
|
"itemType": 1,
|
||||||
"version": "0.1.5",
|
"version": "0.2.1",
|
||||||
"pkgPath": "anime/src/all/netflixmirror.js"
|
"pkgPath": "anime/src/all/netflixmirror.js"
|
||||||
}];
|
}];
|
||||||
|
|
||||||
class DefaultExtension extends MProvider {
|
class DefaultExtension extends MProvider {
|
||||||
|
|
||||||
getTVApi() {
|
|
||||||
return "https://pcmirror.cc"
|
|
||||||
}
|
|
||||||
|
|
||||||
getPreference(key) {
|
getPreference(key) {
|
||||||
const preferences = new SharedPreferences();
|
const preferences = new SharedPreferences();
|
||||||
return preferences.get(key);
|
return preferences.get(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getMobileBaseUrl() {
|
||||||
|
return this.getPreference("netmirror_override_mobile_base_url");
|
||||||
|
}
|
||||||
|
|
||||||
|
getTVBaseUrl() {
|
||||||
|
return this.getPreference("netmirror_override_tv_base_url");
|
||||||
|
}
|
||||||
|
|
||||||
|
getServiceDetails() {
|
||||||
|
return this.getPreference("netmirror_pref_service");
|
||||||
|
}
|
||||||
|
|
||||||
getPoster(id, service) {
|
getPoster(id, service) {
|
||||||
if (service === "nf")
|
if (service === "nf")
|
||||||
return `https://imgcdn.media/poster/v/${id}.jpg`
|
return `https://imgcdn.media/poster/v/${id}.jpg`
|
||||||
@@ -29,9 +37,6 @@ class DefaultExtension extends MProvider {
|
|||||||
return `https://imgcdn.media/pv/480/${id}.jpg`
|
return `https://imgcdn.media/pv/480/${id}.jpg`
|
||||||
}
|
}
|
||||||
|
|
||||||
getServiceDetails() {
|
|
||||||
return this.getPreference("netmirror_pref_service");
|
|
||||||
}
|
|
||||||
|
|
||||||
async getCookie() {
|
async getCookie() {
|
||||||
const preferences = new SharedPreferences();
|
const preferences = new SharedPreferences();
|
||||||
@@ -41,13 +46,13 @@ class DefaultExtension extends MProvider {
|
|||||||
|
|
||||||
// Cookie lasts for 24hrs but still checking for 12hrs
|
// Cookie lasts for 24hrs but still checking for 12hrs
|
||||||
if (now_ts - cookie_ts > 60 * 60 * 12) {
|
if (now_ts - cookie_ts > 60 * 60 * 12) {
|
||||||
const check = await new Client().get(`${this.source.baseUrl}/home`, { "cookie": cookie });
|
const check = await new Client().get(this.getMobileBaseUrl() + `/mobile/home`, { "cookie": cookie });
|
||||||
const hDocBody = new Document(check.body).selectFirst("body")
|
const hDocBody = new Document(check.body).selectFirst("body")
|
||||||
|
|
||||||
const addhash = hDocBody.attr("data-addhash");
|
const addhash = hDocBody.attr("data-addhash");
|
||||||
const data_time = hDocBody.attr("data-time");
|
const data_time = hDocBody.attr("data-time");
|
||||||
|
|
||||||
var res = await new Client().post(`${this.getTVApi()}/tv/p.php`, { "cookie": "" }, { "hash": addhash });
|
var res = await new Client().post(`${this.getTVBaseUrl()}/tv/p.php`, { "cookie": "" }, { "hash": addhash });
|
||||||
cookie = res.headers["set-cookie"];
|
cookie = res.headers["set-cookie"];
|
||||||
preferences.setString("cookie", cookie);
|
preferences.setString("cookie", cookie);
|
||||||
preferences.setString("cookie_ts", data_time);
|
preferences.setString("cookie_ts", data_time);
|
||||||
@@ -64,8 +69,11 @@ class DefaultExtension extends MProvider {
|
|||||||
var slug = "";
|
var slug = "";
|
||||||
if (url == "/home") slug = "";
|
if (url == "/home") slug = "";
|
||||||
else if (service == "pv") slug = "/pv";
|
else if (service == "pv") slug = "/pv";
|
||||||
|
if (!(url.startsWith("https"))) {
|
||||||
|
url = this.getMobileBaseUrl() + "/mobile" + slug + url
|
||||||
|
}
|
||||||
|
|
||||||
return (await new Client().get(this.source.baseUrl + slug + url, { "cookie": cookie })).body;
|
return (await new Client().get(url, { "cookie": cookie })).body;
|
||||||
}
|
}
|
||||||
async getPopular(page) {
|
async getPopular(page) {
|
||||||
return await this.getPages(await this.request("/home"), ".tray-container, #top10")
|
return await this.getPages(await this.request("/home"), ".tray-container, #top10")
|
||||||
@@ -110,7 +118,7 @@ class DefaultExtension extends MProvider {
|
|||||||
async getDetail(url) {
|
async getDetail(url) {
|
||||||
var service = this.getServiceDetails();
|
var service = this.getServiceDetails();
|
||||||
const cookie = await this.getCookie();
|
const cookie = await this.getCookie();
|
||||||
var name_pref = this.getPreference("netmirror_pref_display_name_1");
|
|
||||||
const data = JSON.parse(await this.request(`/post.php?id=${url}`, cookie));
|
const data = JSON.parse(await this.request(`/post.php?id=${url}`, cookie));
|
||||||
const name = data.title;
|
const name = data.title;
|
||||||
const genre = [data.ua, ...(data.genre || '').split(',').map(g => g.trim())];
|
const genre = [data.ua, ...(data.genre || '').split(',').map(g => g.trim())];
|
||||||
@@ -145,7 +153,7 @@ class DefaultExtension extends MProvider {
|
|||||||
if (service === "pv") link = `https://www.primevideo.com/detail/${url}`
|
if (service === "pv") link = `https://www.primevideo.com/detail/${url}`
|
||||||
|
|
||||||
return {
|
return {
|
||||||
name: name_pref ? name : null, imageUrl: this.getPoster(url, service), link, description, status: 1, genre, episodes
|
name, imageUrl: this.getPoster(url, service), link, description, status: 1, genre, episodes
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
async getEpisodes(name, eid, sid, page, cookie) {
|
async getEpisodes(name, eid, sid, page, cookie) {
|
||||||
@@ -193,13 +201,22 @@ class DefaultExtension extends MProvider {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async getVideoList(url) {
|
async getVideoList(url) {
|
||||||
|
var slug = ""
|
||||||
var src = this.getPreference("netmirror_pref_stream_extraction");
|
var src = this.getPreference("netmirror_pref_stream_extraction");
|
||||||
|
|
||||||
var baseUrl = src === 'tv' ? this.getTVApi() : this.source.baseUrl
|
|
||||||
var service = this.getServiceDetails();
|
var service = this.getServiceDetails();
|
||||||
if (service === "nf" && src === 'tv') baseUrl += "/tv";
|
|
||||||
|
|
||||||
const data = JSON.parse(await this.request(`/playlist.php?id=${url}`));
|
// prime extracton works only in mobile
|
||||||
|
if (service == "pv") {
|
||||||
|
slug = "/pv"
|
||||||
|
src = "mobile"
|
||||||
|
}
|
||||||
|
|
||||||
|
var device = "/mobile"
|
||||||
|
if (src == 'tv') device = "/tv";
|
||||||
|
|
||||||
|
var baseUrl = src === 'tv' ? this.getTVBaseUrl() : this.getMobileBaseUrl()
|
||||||
|
url = baseUrl + device + slug + `/playlist.php?id=${url}`
|
||||||
|
const data = JSON.parse(await this.request(url));
|
||||||
let videoList = [];
|
let videoList = [];
|
||||||
let subtitles = [];
|
let subtitles = [];
|
||||||
let audios = [];
|
let audios = [];
|
||||||
@@ -269,41 +286,60 @@ class DefaultExtension extends MProvider {
|
|||||||
}
|
}
|
||||||
|
|
||||||
getSourcePreferences() {
|
getSourcePreferences() {
|
||||||
return [{
|
return [
|
||||||
key: 'netmirror_pref_video_resolution',
|
{
|
||||||
listPreference: {
|
key: "netmirror_override_mobile_base_url",
|
||||||
title: 'Preferred video resolution',
|
editTextPreference: {
|
||||||
summary: '',
|
title: "Override mobile base url",
|
||||||
valueIndex: 0,
|
summary: "",
|
||||||
entries: ["1080p", "720p", "480p"],
|
value: "https://netfree.cc",
|
||||||
entryValues: ["1080", "720", "480"]
|
dialogTitle: "Override base url",
|
||||||
}
|
dialogMessage: "",
|
||||||
}, {
|
}
|
||||||
"key": "netmirror_pref_display_name_1",
|
}, {
|
||||||
"switchPreferenceCompat": {
|
key: "netmirror_override_tv_base_url",
|
||||||
"title": "Display media name on home page",
|
editTextPreference: {
|
||||||
"summary": "Homepage loads faster by not calling details API",
|
title: "Override tv base url",
|
||||||
"value": true
|
summary: "",
|
||||||
}
|
value: "https://pcmirror.cc",
|
||||||
}, {
|
dialogTitle: "Override base url",
|
||||||
key: 'netmirror_pref_service',
|
dialogMessage: "",
|
||||||
listPreference: {
|
}
|
||||||
title: 'Preferred OTT service',
|
}, {
|
||||||
summary: '',
|
key: 'netmirror_pref_video_resolution',
|
||||||
valueIndex: 0,
|
listPreference: {
|
||||||
entries: ["Net mirror", "Prime mirror"],
|
title: 'Preferred video resolution',
|
||||||
entryValues: ["nf", "pv",]
|
summary: '',
|
||||||
}
|
valueIndex: 0,
|
||||||
}, {
|
entries: ["1080p", "720p", "480p"],
|
||||||
key: 'netmirror_pref_stream_extraction',
|
entryValues: ["1080", "720", "480"]
|
||||||
listPreference: {
|
}
|
||||||
title: 'Preferred stream extraction source',
|
}, {
|
||||||
summary: 'Extract stream from which source (if one source fails choose another)',
|
"key": "netmirror_pref_display_name_1",
|
||||||
valueIndex: 0,
|
"switchPreferenceCompat": {
|
||||||
entries: ["TV", "Mobile"],
|
"title": "Display media name on home page",
|
||||||
entryValues: ["tv", "mobile"]
|
"summary": "Homepage loads faster by not calling details API",
|
||||||
}
|
"value": true
|
||||||
},
|
}
|
||||||
|
}, {
|
||||||
|
key: 'netmirror_pref_service',
|
||||||
|
listPreference: {
|
||||||
|
title: 'Preferred OTT service',
|
||||||
|
summary: '',
|
||||||
|
valueIndex: 0,
|
||||||
|
entries: ["Net mirror", "Prime mirror"],
|
||||||
|
entryValues: ["nf", "pv",]
|
||||||
|
}
|
||||||
|
}, {
|
||||||
|
key: 'netmirror_pref_stream_extraction',
|
||||||
|
listPreference: {
|
||||||
|
title: 'Preferred stream extraction source',
|
||||||
|
summary: 'Extract stream from which source (if one source fails choose another)',
|
||||||
|
valueIndex: 0,
|
||||||
|
entries: ["TV", "Mobile"],
|
||||||
|
entryValues: ["tv", "mobile"]
|
||||||
|
}
|
||||||
|
},
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user