From 7296e211b78f99b13e75f5e56c525c4066fca8e1 Mon Sep 17 00:00:00 2001 From: aka paul <50n50@noreply.localhost> Date: Tue, 6 Jan 2026 19:56:26 +0000 Subject: [PATCH] Add senshi/senshi.js --- senshi/senshi.js | 100 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 100 insertions(+) create mode 100644 senshi/senshi.js diff --git a/senshi/senshi.js b/senshi/senshi.js new file mode 100644 index 0000000..8adda99 --- /dev/null +++ b/senshi/senshi.js @@ -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: "" + }); + } +} \ No newline at end of file