mirror of
https://github.com/kodjodevf/mangayomi-extensions.git
synced 2026-02-15 03:10:59 +00:00
extension(autoembed): Added mulitple stream source
This commit is contained in:
@@ -6,7 +6,7 @@ const mangayomiSources = [{
|
|||||||
"iconUrl": "https://www.google.com/s2/favicons?sz=64&domain=https://autoembed.cc/",
|
"iconUrl": "https://www.google.com/s2/favicons?sz=64&domain=https://autoembed.cc/",
|
||||||
"typeSource": "multi",
|
"typeSource": "multi",
|
||||||
"isManga": false,
|
"isManga": false,
|
||||||
"version": "1.0.3",
|
"version": "1.1.0",
|
||||||
"dateFormat": "",
|
"dateFormat": "",
|
||||||
"dateFormatLocale": "",
|
"dateFormatLocale": "",
|
||||||
"pkgPath": "anime/src/all/autoembed.js"
|
"pkgPath": "anime/src/all/autoembed.js"
|
||||||
@@ -129,7 +129,7 @@ class DefaultExtension extends MProvider {
|
|||||||
if (release < dateNow) {
|
if (release < dateNow) {
|
||||||
var episodeNum = video.episode
|
var episodeNum = video.episode
|
||||||
var name = `S${seasonNum}:E${episodeNum} - ${video.name}`
|
var name = `S${seasonNum}:E${episodeNum} - ${video.name}`
|
||||||
var eplink = `${link}/${seasonNum}/${episodeNum}`
|
var eplink = `${link}||${seasonNum}||${episodeNum}`
|
||||||
|
|
||||||
chaps.push({
|
chaps.push({
|
||||||
name: name,
|
name: name,
|
||||||
@@ -152,7 +152,7 @@ class DefaultExtension extends MProvider {
|
|||||||
chaps.reverse();
|
chaps.reverse();
|
||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
async extractStreams(url) {
|
async extractStreams(url, hdr = {}) {
|
||||||
const response = await new Client().get(url);
|
const response = await new Client().get(url);
|
||||||
const body = response.body;
|
const body = response.body;
|
||||||
const lines = body.split('\n');
|
const lines = body.split('\n');
|
||||||
@@ -161,12 +161,14 @@ class DefaultExtension extends MProvider {
|
|||||||
for (let i = 0; i < lines.length; i++) {
|
for (let i = 0; i < lines.length; i++) {
|
||||||
if (lines[i].startsWith('#EXT-X-STREAM-INF:')) {
|
if (lines[i].startsWith('#EXT-X-STREAM-INF:')) {
|
||||||
const resolution = lines[i].match(/RESOLUTION=(\d+x\d+)/)[1];
|
const resolution = lines[i].match(/RESOLUTION=(\d+x\d+)/)[1];
|
||||||
const m3u8Url = lines[i + 1].trim();
|
var m3u8Url = lines[i + 1].trim();
|
||||||
|
m3u8Url =
|
||||||
|
m3u8Url.replace("./", `${url}/`)
|
||||||
streams.push({
|
streams.push({
|
||||||
url: m3u8Url,
|
url: m3u8Url,
|
||||||
originalUrl: m3u8Url,
|
originalUrl: m3u8Url,
|
||||||
quality: resolution,
|
quality: resolution,
|
||||||
|
headers: hdr
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -192,31 +194,90 @@ class DefaultExtension extends MProvider {
|
|||||||
return [...sortedStreams, ...copyStreams]
|
return [...sortedStreams, ...copyStreams]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async getSubtitleList(id, s, e) {
|
||||||
|
var api = `https://sub.wyzie.ru/search?id=${id}`
|
||||||
|
if (s != "0") api = `${api}&season=${s}&episode=${e}`
|
||||||
|
var response = await new Client().get(api);
|
||||||
|
var body = JSON.parse(response.body);
|
||||||
|
|
||||||
|
var subs = []
|
||||||
|
for (var sub of body) {
|
||||||
|
subs.push({
|
||||||
|
file: sub.url
|
||||||
|
,
|
||||||
|
label: sub.display
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
return subs
|
||||||
|
}
|
||||||
|
|
||||||
// For anime episode video list
|
// For anime episode video list
|
||||||
async getVideoList(url) {
|
async getVideoList(url) {
|
||||||
|
var streamAPI = parseInt(await this.getPreference("pref_stream_source"))
|
||||||
|
|
||||||
var parts = url.split("||");
|
var parts = url.split("||");
|
||||||
var media_type = parts[0];
|
var media_type = parts[0];
|
||||||
var id = parts[1];
|
var id = parts[1];
|
||||||
var api = `${this.source.apiUrl}/api/getVideoSource?type=${media_type}&id=${id}`
|
var tmdb = id
|
||||||
const response = await new Client().get(api, this.getHeaders());
|
var streams = []
|
||||||
const body = JSON.parse(response.body);
|
var subtitles = []
|
||||||
|
switch (streamAPI) {
|
||||||
|
case 2: {
|
||||||
|
var s = "0"
|
||||||
|
var e = "0"
|
||||||
|
if (media_type == "tv") {
|
||||||
|
s = parts[2]
|
||||||
|
e = parts[3]
|
||||||
|
id = `${id}/${s}/${e}`
|
||||||
|
}
|
||||||
|
var api = `https://play2.123embed.net/server/3?path=/${media_type}/${id}`
|
||||||
|
var response = await new Client().get(api);
|
||||||
|
var body = JSON.parse(response.body);
|
||||||
|
|
||||||
if (response.statusCode == 404) {
|
if (response.statusCode != 200) {
|
||||||
throw new Error("Video unavailable");
|
throw new Error("Video unavailable");
|
||||||
|
}
|
||||||
|
var link = body.playlist[0].file
|
||||||
|
subtitles = await this.getSubtitleList(tmdb, s, e)
|
||||||
|
streams.push({
|
||||||
|
url: link,
|
||||||
|
originalUrl: link,
|
||||||
|
quality: "auto",
|
||||||
|
headers: { "Origin": "https://play2.123embed.net" }
|
||||||
|
,
|
||||||
|
subtitles: subtitles
|
||||||
|
});
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default: {
|
||||||
|
if (media_type == "tv") {
|
||||||
|
id = `${id}/${parts[2]}/${parts[3]}`
|
||||||
|
}
|
||||||
|
var api = `${this.source.apiUrl}/api/getVideoSource?type=${media_type}&id=${id}`
|
||||||
|
var response = await new Client().get(api, this.getHeaders());
|
||||||
|
var body = JSON.parse(response.body);
|
||||||
|
|
||||||
|
if (response.statusCode != 200) {
|
||||||
|
throw new Error("Video unavailable");
|
||||||
|
}
|
||||||
|
var link = body.videoSource
|
||||||
|
subtitles =
|
||||||
|
body.subtitles
|
||||||
|
streams = await this.extractStreams(link);
|
||||||
|
streams.push({
|
||||||
|
url: link,
|
||||||
|
originalUrl: link,
|
||||||
|
quality: "auto",
|
||||||
|
subtitles: subtitles,
|
||||||
|
});
|
||||||
|
streams = await this.sortStreams(streams);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
var link = body.videoSource
|
return streams
|
||||||
|
|
||||||
var subtitles = body.subtitles
|
|
||||||
var streams = await this.extractStreams(link);
|
|
||||||
streams.push({
|
|
||||||
url: link,
|
|
||||||
originalUrl: link,
|
|
||||||
quality: "auto",
|
|
||||||
subtitles: subtitles,
|
|
||||||
});
|
|
||||||
|
|
||||||
return await this.sortStreams(streams);
|
|
||||||
}
|
}
|
||||||
// For manga chapter pages
|
// For manga chapter pages
|
||||||
async getPageList() {
|
async getPageList() {
|
||||||
@@ -255,8 +316,16 @@ class DefaultExtension extends MProvider {
|
|||||||
entryValues: ["movies", "series"]
|
entryValues: ["movies", "series"]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
key: 'pref_stream_source',
|
||||||
|
listPreference: {
|
||||||
|
title: 'Preferred stream source',
|
||||||
|
summary: '',
|
||||||
|
valueIndex: 0,
|
||||||
|
entries: ["tom.autoembed.cc", "123embed.net"],
|
||||||
|
entryValues: ["1", "2"]
|
||||||
|
}
|
||||||
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user