Last active
March 29, 2025 07:03
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const { SeanimeExtension, MediaType } = require("@rahim/extension-kit"); | |
const extension = new SeanimeExtension({ | |
meta: { | |
id: "donghuastream", | |
name: "DonghuaStream", | |
version: "1.0.1", | |
icon: "https://donghuastream.com/favicon.ico", | |
supportedLanguages: ["en"], | |
}, | |
// [1] Search using AniList title | |
async search(query) { | |
try { | |
const response = await fetch(`https://donghuastream.com/?s=${encodeURIComponent(query)}`); | |
const html = await response.text(); | |
const parser = new DOMParser(); | |
const doc = parser.parseFromString(html, "text/html"); | |
return Array.from(doc.querySelectorAll(".item")).map((item) => { | |
const link = item.querySelector(".data h3 a"); | |
return { | |
id: link.href.split("/").filter(Boolean).pop(), // URL slug as ID | |
title: link.textContent.trim(), | |
type: MediaType.ANIME, | |
}; | |
}); | |
} catch (error) { | |
console.error("[DonghuaStream] Search error:", error); | |
return []; | |
} | |
}, | |
// [2] Match episodes to AniList numbering | |
async getMediaInfo(mediaId) { | |
try { | |
const response = await fetch(`https://donghuastream.com/${mediaId}/`); | |
const html = await response.text(); | |
const parser = new DOMParser(); | |
const doc = parser.parseFromString(html, "text/html"); | |
// Extract episodes with AniList-compatible numbering | |
const episodes = Array.from(doc.querySelectorAll("#episodes li")).map((ep) => { | |
const episodeUrl = ep.querySelector("a").href; | |
const slugParts = episodeUrl.split("/").filter(Boolean).pop().split("-"); | |
// Extract episode number from URL (e.g., ...episode-140...) | |
const episodeNumber = parseInt(slugParts[slugParts.indexOf("episode") + 1]); | |
return { | |
id: episodeUrl.split("/").filter(Boolean).pop(), // Full episode slug | |
number: episodeNumber, // Matches AniList's numbering | |
title: `Episode ${episodeNumber}` | |
}; | |
}); | |
return { | |
id: mediaId, | |
title: doc.querySelector(".data h1").textContent.trim(), | |
episodes: episodes.sort((a, b) => a.number - b.number), // Ascending order | |
}; | |
} catch (error) { | |
console.error("[DonghuaStream] Media info error:", error); | |
return null; | |
} | |
}, | |
// [3] Video sources | |
async getVideoSources(episodeId) { | |
try { | |
const response = await fetch(`https://donghuastream.com/${episodeId}/`); | |
const html = await response.text(); | |
const parser = new DOMParser(); | |
const doc = parser.parseFromString(html, "text/html"); | |
return Array.from(doc.querySelectorAll(".player iframe")) | |
.map((iframe) => ({ | |
quality: "1080p", | |
url: iframe.src, | |
headers: { Referer: "https://donghuastream.com/" } | |
})); | |
} catch (error) { | |
console.error("[DonghuaStream] Video sources error:", error); | |
return []; | |
} | |
}, | |
}); | |
module.exports = extension; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment