Add senshi/senshi.js
This commit is contained in:
@@ -0,0 +1,100 @@
|
||||
async function searchResults(keyword) {
|
||||
const results = [];
|
||||
const postData = `{"searchTerm":"${keyword}","page":1,"limit":100}`;
|
||||
try {
|
||||
const response = await fetchv2("https://senshi.live/anime/filter", {}, "POST", postData);
|
||||
const data = await response.json();
|
||||
|
||||
if (data.data && Array.isArray(data.data)) {
|
||||
for (const item of data.data) {
|
||||
results.push({
|
||||
title: item.title,
|
||||
image: "https://senshi.live" + item.anime_picture,
|
||||
href: item.id
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
return JSON.stringify(results);
|
||||
} catch (err) {
|
||||
return JSON.stringify([{
|
||||
title: "Error",
|
||||
image: "Error",
|
||||
href: "Error"
|
||||
}]);
|
||||
}
|
||||
}
|
||||
|
||||
async function extractDetails(ID) {
|
||||
try {
|
||||
const response = await fetchv2("https://senshi.live/anime/" + ID);
|
||||
const data = await response.json();
|
||||
|
||||
return JSON.stringify([{
|
||||
description: data.ani_description,
|
||||
aliases: data.synonyms,
|
||||
airdate: data.created_at
|
||||
}]);
|
||||
} catch (err) {
|
||||
return JSON.stringify([{
|
||||
description: "Error",
|
||||
aliases: "Error",
|
||||
airdate: "Error"
|
||||
}]);
|
||||
}
|
||||
}
|
||||
|
||||
async function extractEpisodes(ID) {
|
||||
const results = [];
|
||||
try {
|
||||
const response = await fetchv2("https://senshi.live/episodes/" + ID, {"Referer": "https://senshi.live/"});
|
||||
const data = await response.json();
|
||||
|
||||
if (Array.isArray(data)) {
|
||||
for (const ep of data) {
|
||||
results.push({
|
||||
href: "https://senshi.live/episode-embeds/" + ep.mal_id + "/" + ep.ep_id,
|
||||
number: ep.ep_id
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
return JSON.stringify(results);
|
||||
} catch (err) {
|
||||
return JSON.stringify([{
|
||||
href: "Error",
|
||||
number: "Error"
|
||||
}]);
|
||||
}
|
||||
}
|
||||
|
||||
async function extractStreamUrl(url) {
|
||||
try {
|
||||
const response = await fetchv2(url, {"Referer": "https://senshi.live/"});
|
||||
const data = await response.json();
|
||||
|
||||
const streams = [];
|
||||
const count = {};
|
||||
for (const item of data) {
|
||||
const status = item.status;
|
||||
if (!count[status]) count[status] = 0;
|
||||
count[status]++;
|
||||
const title = count[status] > 1 ? `${status} ${count[status]}` : status;
|
||||
streams.push({
|
||||
title: title,
|
||||
streamUrl: item.url,
|
||||
headers: { "Referer": "https://senshi.live/" }
|
||||
});
|
||||
}
|
||||
|
||||
return JSON.stringify({
|
||||
streams: streams,
|
||||
subtitle: ""
|
||||
});
|
||||
} catch (err) {
|
||||
return JSON.stringify({
|
||||
streams: [],
|
||||
subtitle: ""
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user