en/Donghuastream: Fix video loading and improve extractors#66
en/Donghuastream: Fix video loading and improve extractors#66cuong-tran merged 25 commits intomasterfrom
Conversation
* Fix API request * Support script extract for both Desktop/Mobile UA cases * Fix M3U8 master/playlist case * Prefer Server 1 over Server 3 which having issue * Extraxt Regex * Avoid resource leaks with Response
* Selector Changes * Fixed Extractors * Suggested Changes * Suggested Changes 2 --------- Co-authored-by: Yogesh S <yogesh.sakthivel@thoughtscrest.com>
Reviewer's GuideUpdates the DonghuaStream extension to support additional video hosts, configurable host/preview behavior, and a more robust StreamPlay extraction flow using async utilities and new extractors, while adjusting search/pagination and quality sorting. Sequence diagram for updated getVideoList host selection and extractionsequenceDiagram
participant DS as DonghuaStream
participant Pref as SharedPreferences
participant DME as DailymotionExtractor
participant SPE as StreamPlayExtractor
participant OKE as OkruExtractor
participant RE as RumbleExtractor
DS->>Pref: read getHosters
DS->>DS: runBlocking { getVideoList(url, name) }
alt Dailymotion enabled and url contains dailymotion
DS->>DME: videosFromUrl(url, prefix)
DME-->>DS: List Video
else Streamplay enabled and url contains streamplay
DS->>SPE: videosFromUrl(url, prefix)
SPE-->>DS: List Video
else Okru enabled and url contains ok.ru
DS->>DS: UrlUtils.fixUrl(url)
alt url fixed
DS->>OKE: videosFromUrl(fixedUrl, prefix)
OKE-->>DS: List Video
else invalid url
DS-->>DS: emptyList
end
else Rumble enabled and url contains rumble
DS->>RE: videosFromUrl(url, prefix)
RE-->>DS: List Video
else No matching enabled host
DS-->>DS: emptyList
end
Sequence diagram for new StreamPlayExtractor async extraction flowsequenceDiagram
participant DS as DonghuaStream
participant SPE as StreamPlayExtractor
participant C as OkHttpClient
participant SP as streamplay_page
participant API as streamplay_api
participant PU as PlaylistUtils
DS->>SPE: videosFromUrl(url, prefix)
SPE->>C: GET url with headers
C-->>SPE: Response
SPE->>SPE: useAsJsoup() parse document
loop for each server link
SPE->>SPE: extractAndDecodeFromDocument(serverUrl, serverPrefix)
SPE->>C: GET serverUrl
C-->>SPE: Response
SPE->>SPE: useAsJsoup() parse server document
alt packed script present
SPE->>SPE: JsUnpacker.unpackAndCombine(script)
SPE->>SPE: extract kaken via kakenRegex
else mobile non packed script
SPE->>SPE: extract kaken from window.kaken
end
SPE->>C: POST https://play.streamplay.co.in/api/ with kaken
C-->>SPE: API JSON
SPE->>SPE: parseAs APIResponse
SPE->>SPE: build subtitleList from tracks
par for each source in sources
alt type is hls and videoUrl endsWith master.m3u8
SPE->>PU: extractFromHls(videoUrl, referer, subtitleList, nameGen)
PU-->>SPE: List Video
else non HLS or non master
SPE-->>SPE: create single Video with Original label
end
end
end
SPE-->>DS: aggregated List Video
Class diagram for updated DonghuaStream extension and extractorsclassDiagram
class AnimeStream
class DonghuaStream {
+String name
+String baseUrl
+String lang
+boolean fetchFilters
+String[] prefQualityValues
+String[] prefQualityEntries
+fun popularAnimeNextPageSelector() String
+fun latestUpdatesNextPageSelector() String
+fun searchAnimeRequest(page~Int~, query~String~, filters~AnimeFilterList~) Request
+fun setupPreferenceScreen(screen~PreferenceScreen~) void
+fun episodeListParse(response~Response~) List~SEpisode~
+fun getVideoList(url~String~, name~String~) List~Video~
+fun List~Video~.sort() List~Video~
-SharedPreferences.ignorePreview : Boolean
-SharedPreferences.getHosters : Set~String~
-const PREF_HOSTER_KEY : String
-const INTERNAL_HOSTER_NAMES : List~String~
-const PREF_HOSTER_ENTRY_VALUES : List~String~
-const PREF_HOSTER_DEFAULT : Set~String~
-const IGNORE_PREVIEW_KEY : String
-const IGNORE_PREVIEW_DEFAULT : Boolean
-DailymotionExtractor dailymotionExtractor
-StreamPlayExtractor streamPlayExtractor
-OkruExtractor okruExtractor
-RumbleExtractor rumbleExtractor
-Regex qualityRegex
}
class StreamPlayExtractor {
-OkHttpClient client
-Headers headers
-PlaylistUtils playlistUtils
-Regex kakenRegex
+suspend fun videosFromUrl(url~String~, prefix~String~=) List~Video~
-suspend fun extractAndDecodeFromDocument(url~String~, prefix~String~) List~Video~
}
class RumbleExtractor {
-OkHttpClient client
-Headers headers
-PlaylistUtils playlistUtils
-Regex regex
+fun videosFromUrl(url~String~, prefix~String~=) List~Video~
-fun extractRumbleId(url~String~) String?
}
class APIResponse {
+List~SourceObject~ sources
+List~TrackObject~ tracks?
}
class SourceObject {
+String file
+String label
+String type
+String videoUrl
}
class TrackObject {
+String file
+String label
+String kind
}
class DailymotionExtractor
class OkruExtractor
class PlaylistUtils {
+fun extractFromHls(playlistUrl~String~, referer~String~, subtitleList~List~Track~~, videoNameGen~Function1~String,String~~) List~Video~
}
class RumbleExtractor_DependencyNote
DonghuaStream --|> AnimeStream
DonghuaStream --> DailymotionExtractor : uses
DonghuaStream --> StreamPlayExtractor : uses
DonghuaStream --> OkruExtractor : uses
DonghuaStream --> RumbleExtractor : uses
DonghuaStream --> SharedPreferences : stores_prefs
DonghuaStream --> Regex : uses_qualityRegex
StreamPlayExtractor --> PlaylistUtils : uses
StreamPlayExtractor --> APIResponse : parses
StreamPlayExtractor --> SourceObject : contains
StreamPlayExtractor --> TrackObject : contains
RumbleExtractor --> PlaylistUtils : uses
APIResponse o-- SourceObject : has_many
APIResponse o-- TrackObject : has_many
SourceObject --> String : file_label_type
TrackObject --> String : file_label_kind
File-Level Changes
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request focuses on improving the robustness and functionality of the DonghuaStream anime extension. It addresses video loading issues by integrating new video hoster extractors and enhancing an existing one, ensuring a wider range of content is playable. Additionally, it introduces user-configurable preferences for hoster selection and episode filtering, alongside refinements to navigation and search mechanisms, providing a more stable and customizable user experience. Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Changelog
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Hey - I've found 1 issue, and left some high level feedback:
- The host handling logic duplicates host identifiers between
INTERNAL_HOSTER_NAMESand the string checks ingetVideoList; consider centralizing these values (e.g., constants or an enum) so host keys and URL checks can't drift out of sync. - In
StreamPlayExtractor.SourceObject.videoUrl, themaster.txt→master.m3u8replacement assumes a specific filename pattern; if the API ever returns direct.m3u8or another variant, this could produce invalid URLs—consider making this transformation conditional or more defensive based ontypeor the existing extension.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- The host handling logic duplicates host identifiers between `INTERNAL_HOSTER_NAMES` and the string checks in `getVideoList`; consider centralizing these values (e.g., constants or an enum) so host keys and URL checks can't drift out of sync.
- In `StreamPlayExtractor.SourceObject.videoUrl`, the `master.txt` → `master.m3u8` replacement assumes a specific filename pattern; if the API ever returns direct `.m3u8` or another variant, this could produce invalid URLs—consider making this transformation conditional or more defensive based on `type` or the existing extension.
## Individual Comments
### Comment 1
<location path="src/en/donghuastream/src/eu/kanade/tachiyomi/animeextension/en/donghuastream/DonghuaStream.kt" line_range="40-43" />
<code_context>
+ override fun latestUpdatesNextPageSelector() = popularAnimeNextPageSelector()
+
+ override fun searchAnimeRequest(page: Int, query: String, filters: AnimeFilterList): Request {
+ val url = baseUrl.toHttpUrl().newBuilder().apply {
+ addPathSegment("pagg")
+ addPathSegment(page.toString())
+ addPathSegment("")
+ addQueryParameter("s", query)
+ }.build()
</code_context>
<issue_to_address>
**issue (bug_risk):** Empty path segment in searchAnimeRequest is likely invalid for HttpUrl and can throw at runtime.
OkHttp’s `addPathSegment` rejects empty strings and throws `IllegalArgumentException`, so this call will always fail. If you just need a trailing slash, remove this line, or construct the path explicitly with non-empty segments (e.g. `addPathSegment("pagg").addPathSegment(page.toString())`) and let the builder handle separators.
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
src/en/donghuastream/src/eu/kanade/tachiyomi/animeextension/en/donghuastream/DonghuaStream.kt
Show resolved
Hide resolved
There was a problem hiding this comment.
Code Review
This pull request significantly enhances the DonghuaStream extension by adding support for Ok.ru and Rumble video hosts, introducing user preferences for host selection and skipping previews, and overhauling the StreamPlay extractor to align with recent site changes. The implementation is solid, and the new features are valuable. I've included a couple of minor suggestions to improve code clarity and maintainability.
src/en/donghuastream/src/eu/kanade/tachiyomi/animeextension/en/donghuastream/DonghuaStream.kt
Outdated
Show resolved
Hide resolved
src/en/donghuastream/src/eu/kanade/tachiyomi/animeextension/en/donghuastream/DonghuaStream.kt
Show resolved
Hide resolved
There was a problem hiding this comment.
Pull request overview
This PR updates the DonghuaStream extension to restore/expand video extraction across multiple hosters and to improve playback reliability (notably for StreamPlay), while adding a couple of user-facing preferences to control hoster usage and episode filtering.
Changes:
- Reworked StreamPlay extraction to decode
kaken, call the StreamPlay API via POST, and generate videos from HLS or direct sources. - Added a Rumble extractor and integrated Ok.ru support into video extraction routing.
- Added extension preferences for hoster enable/disable and skipping preview episodes, plus adjusted pagination/search and refined video sorting.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
src/en/donghuastream/.../extractors/StreamPlayExtractor.kt |
Major StreamPlay extractor rewrite (unpacking + POST API flow, parallel server/source extraction). |
src/en/donghuastream/.../extractors/RumbleExtractor.kt |
New extractor to build an HLS playlist URL from a Rumble embed URL. |
src/en/donghuastream/.../DonghuaStream.kt |
Adds hoster selection + preview-skip preferences; routes Ok.ru/Rumble/StreamPlay/Dailymotion; tweaks paging/search and sorting. |
src/en/donghuastream/build.gradle |
Bumps extension version and adds okruextractor + unpacker dependencies needed by the new extractors. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
Summary by Sourcery
Update DonghuaStream extension to improve video host extraction, add host selection preferences, and refine episode and quality handling.
New Features:
Enhancements:
Build: