diff --git a/123anime/123anime.js b/123anime/123anime.js new file mode 100644 index 0000000..3810a4c --- /dev/null +++ b/123anime/123anime.js @@ -0,0 +1,129 @@ +async function searchResults(keyword) { + const results = []; + try { + const response = await fetchv2("https://123animes.ru/search?keyword=" + encodeURIComponent(keyword)); + const html = await response.text(); + + const filmListMatch = html.match(/
([\s\S]*?)
<\/div>/); + if (!filmListMatch) { + return JSON.stringify(results); + } + + const filmList = filmListMatch[1]; + const itemRegex = /
[\s\S]*?]*class="poster"[\s\S]*?]*alt="([^"]+)"[^>]*src="([^"]+)"/g; + let match; + while ((match = itemRegex.exec(filmList)) !== null) { + results.push({ + title: match[2].trim(), + image: "https://123animes.ru" + match[3].trim(), + href: "https://123animes.ru" + match[1].trim() + }); + } + + return JSON.stringify(results); + } catch (err) { + return JSON.stringify([{ + title: "Error", + image: "Error", + href: "Error" + }]); + } +} + +async function extractDetails(url) { + try { + const response = await fetchv2(url); + const html = await response.text(); + + let description = "N/A"; + let aliases = "N/A"; + let airdate = "N/A"; + + const descMatch = html.match(/
([\s\S]*?)<\/div>/); + if (descMatch) { + description = descMatch[1].replace(/<[^>]*>/g, "").replace(/\s+/g, " ").trim(); + } + + const aliasMatch = html.match(/

([^<]*)<\/p>/); + if (aliasMatch) { + aliases = aliasMatch[1].trim(); + } + + const airdateMatch = html.match(/

Released:<\/dt>\s*
\s*]*>(\d+)<\/a>/); + if (airdateMatch) { + airdate = airdateMatch[1].trim(); + } + + return JSON.stringify([{ + description: description, + aliases: aliases, + airdate: airdate + }]); + } catch (err) { + return JSON.stringify([{ + description: "Error", + aliases: "Error", + airdate: "Error" + }]); + } +} + +async function extractEpisodes(url) { + const results = []; + try { + const animeId = url.split('/').pop(); + + const response = await fetchv2("https://123animes.ru/ajax/film/sv?id=" + animeId); + const jsonData = await response.json(); + const html = jsonData.html; + + const episodesMatch = html.match(/
    ]*>([\s\S]*?)<\/ul>/); + if (!episodesMatch) { + return JSON.stringify(results); + } + + const episodesHTML = episodesMatch[1]; + + const episodeRegex = /data-pop='(\d+)'/g; + let match; + const seenEpisodes = new Set(); + + while ((match = episodeRegex.exec(episodesHTML)) !== null) { + const episodeNum = parseInt(match[1], 10); + + if (!seenEpisodes.has(episodeNum)) { + seenEpisodes.add(episodeNum); + results.push({ + href: animeId + "/" + episodeNum + "/vidstreaming.io", + number: episodeNum + }); + } + } + + return JSON.stringify(results); + } catch (err) { + return JSON.stringify([{ + href: "Error", + number: "Error" + }]); + } +} + +async function extractStreamUrl(ID) { + try { + const response = await fetchv2("https://123animes.ru/ajax/episode/info?epr=" + ID); + const data = await response.json(); + + const target = data.target; + const streamID = target.split('/').pop(); + + const responseTwo = await fetchv2("https://play.shipimagesbolt.online/hs/getSources?id=" + streamID); + const dataTwo = await responseTwo.json(); + + const stream = dataTwo.sources; + + return stream; + } catch (err) { + return "https://error.org/"; + } +}