extension(autoembed): Misc

This commit is contained in:
Swakshan
2025-01-03 13:10:02 +05:30
parent 754f8f95b4
commit 42b1f0492f

View File

@@ -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.1.0", "version": "1.1.1",
"dateFormat": "", "dateFormat": "",
"dateFormatLocale": "", "dateFormatLocale": "",
"pkgPath": "anime/src/all/autoembed.js" "pkgPath": "anime/src/all/autoembed.js"
@@ -152,18 +152,22 @@ class DefaultExtension extends MProvider {
chaps.reverse(); chaps.reverse();
return item; return item;
} }
async extractStreams(url, hdr = {}) { async extractStreams(url, lang = "", 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');
var streams = []; var streams = [{
url: url,
originalUrl: url,
quality: "auto",
}];
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]; var resolution = lines[i].match(/RESOLUTION=(\d+x\d+)/)[1];
resolution = `${lang} ${resolution}`
var m3u8Url = lines[i + 1].trim(); var m3u8Url = lines[i + 1].trim();
m3u8Url = m3u8Url = m3u8Url.replace("./", `${url}/`)
m3u8Url.replace("./", `${url}/`)
streams.push({ streams.push({
url: m3u8Url, url: m3u8Url,
originalUrl: m3u8Url, originalUrl: m3u8Url,
@@ -172,9 +176,29 @@ class DefaultExtension extends MProvider {
}); });
} }
} }
return await this.sortStreams(streams);
}
async splitStreams(url, lang = "", hdr = {}) {
var streams = [];
var quality = ["auto", "360", "480", "720", "1080"]
for (var q of quality) {
if (q != "auto") {
url = url.replace("index.m3u8", `${q}/index.m3u8`)
q = `${q}p`
}
streams.push({
url: url,
originalUrl: url,
quality: `${lang} - ${q}`,
headers: hdr
});
}
return streams; return streams;
} }
async sortStreams(streams) { async sortStreams(streams) {
var sortedStreams = []; var sortedStreams = [];
@@ -203,8 +227,7 @@ class DefaultExtension extends MProvider {
var subs = [] var subs = []
for (var sub of body) { for (var sub of body) {
subs.push({ subs.push({
file: sub.url file: sub.url,
,
label: sub.display label: sub.display
}) })
} }
@@ -233,22 +256,20 @@ class DefaultExtension extends MProvider {
} }
var api = `https://play2.123embed.net/server/3?path=/${media_type}/${id}` var api = `https://play2.123embed.net/server/3?path=/${media_type}/${id}`
var response = await new Client().get(api); var response = await new Client().get(api);
var body = JSON.parse(response.body);
if (response.statusCode != 200) { if (response.statusCode != 200) {
throw new Error("Video unavailable"); throw new Error("Video unavailable");
} }
var body = JSON.parse(response.body);
var link = body.playlist[0].file var link = body.playlist[0].file
subtitles = await this.getSubtitleList(tmdb, s, e) subtitles = await this.getSubtitleList(tmdb, s, e)
streams.push({ streams.push({
url: link, url: link,
originalUrl: link, originalUrl: link,
quality: "auto", quality: "auto",
headers: { "Origin": "https://play2.123embed.net" } headers: { "Origin": "https://play2.123embed.net" },
,
subtitles: subtitles
}); });
break; break;
} }
default: { default: {
@@ -257,26 +278,20 @@ class DefaultExtension extends MProvider {
} }
var api = `${this.source.apiUrl}/api/getVideoSource?type=${media_type}&id=${id}` var api = `${this.source.apiUrl}/api/getVideoSource?type=${media_type}&id=${id}`
var response = await new Client().get(api, this.getHeaders()); var response = await new Client().get(api, this.getHeaders());
var body = JSON.parse(response.body);
if (response.statusCode != 200) { if (response.statusCode != 200) {
throw new Error("Video unavailable"); throw new Error("Video unavailable");
} }
var body = JSON.parse(response.body);
var link = body.videoSource var link = body.videoSource
subtitles = subtitles = body.subtitles
body.subtitles
streams = await this.extractStreams(link); streams = await this.extractStreams(link);
streams.push({
url: link,
originalUrl: link,
quality: "auto",
subtitles: subtitles,
});
streams = await this.sortStreams(streams);
break; break;
} }
} }
streams[0].subtitles = subtitles
return streams return streams
} }
// For manga chapter pages // For manga chapter pages