mirror of
https://github.com/kodjodevf/mangayomi-extensions.git
synced 2026-02-14 10:51:17 +00:00
Update animepahe.dart. Add feature: Preferred audio selection for episodes (English/Japanese)
- Added a feature allowing users to set a default audio preference (English or Japanese). - Default is Japanese, but users can switch to English, and the preference is saved. - Eliminates the need to manually select English dub for each new episode.
This commit is contained in:
committed by
GitHub
parent
30eabb29c4
commit
6cfe22810a
@@ -147,11 +147,14 @@ class AnimePahe extends MProvider {
|
|||||||
final downloadLinks = document.select("div#pickDownload > a");
|
final downloadLinks = document.select("div#pickDownload > a");
|
||||||
final buttons = document.select("div#resolutionMenu > button");
|
final buttons = document.select("div#resolutionMenu > button");
|
||||||
List<MVideo> videos = [];
|
List<MVideo> videos = [];
|
||||||
|
|
||||||
for (var i = 0; i < buttons.length; i++) {
|
for (var i = 0; i < buttons.length; i++) {
|
||||||
final btn = buttons[i];
|
final btn = buttons[i];
|
||||||
|
final audio = btn.attr("data-audio"); // Get audio type (jpn/eng). Japanese or Dubbed.
|
||||||
final kwikLink = btn.attr("data-src");
|
final kwikLink = btn.attr("data-src");
|
||||||
final quality = btn.text;
|
final quality = btn.text;
|
||||||
final paheWinLink = downloadLinks[i].attr("href");
|
final paheWinLink = downloadLinks[i].attr("href");
|
||||||
|
|
||||||
if (getPreferenceValue(source.id, "preffered_link_type")) {
|
if (getPreferenceValue(source.id, "preffered_link_type")) {
|
||||||
final noRedirectClient = Client(source,
|
final noRedirectClient = Client(source,
|
||||||
json.encode({"followRedirects": false, "useDartHttpClient": true}));
|
json.encode({"followRedirects": false, "useDartHttpClient": true}));
|
||||||
@@ -266,8 +269,20 @@ class AnimePahe extends MProvider {
|
|||||||
|
|
||||||
List<MVideo> sortVideos(List<MVideo> videos) {
|
List<MVideo> sortVideos(List<MVideo> videos) {
|
||||||
String quality = getPreferenceValue(source.id, "preferred_quality");
|
String quality = getPreferenceValue(source.id, "preferred_quality");
|
||||||
|
String preferredAudio = getPreferenceValue(source.id, "preferred_audio"); // get user's audio preference
|
||||||
|
|
||||||
|
|
||||||
videos.sort((MVideo a, MVideo b) {
|
videos.sort((MVideo a, MVideo b) {
|
||||||
|
// Prioritize audio first.
|
||||||
|
// Preferred Audio: Videos with matching preferred audio are ranked highest.
|
||||||
|
int audioMatchA = a.quality.contains(preferredAudio) ? 1 : 0;
|
||||||
|
int audioMatchB = b.quality.contains(preferredAudio) ? 1 : 0;
|
||||||
|
if (audioMatchA != audioMatchB) {
|
||||||
|
return audioMatchB - audioMatchA;
|
||||||
|
}
|
||||||
|
|
||||||
|
// quality prioritized next
|
||||||
|
// Preferred Video Quality: If audio matches, videos with preferred video quality are ranked higher.
|
||||||
int qualityMatchA = 0;
|
int qualityMatchA = 0;
|
||||||
if (a.quality.contains(quality)) {
|
if (a.quality.contains(quality)) {
|
||||||
qualityMatchA = 1;
|
qualityMatchA = 1;
|
||||||
@@ -321,6 +336,14 @@ class AnimePahe extends MProvider {
|
|||||||
valueIndex: 0,
|
valueIndex: 0,
|
||||||
entries: ["1080p", "720p", "360p"],
|
entries: ["1080p", "720p", "360p"],
|
||||||
entryValues: ["1080", "720", "360"]),
|
entryValues: ["1080", "720", "360"]),
|
||||||
|
|
||||||
|
ListPreference(
|
||||||
|
key: "preferred_audio", // Add new preference for audio
|
||||||
|
title: "Preferred Audio",
|
||||||
|
summary: "Select your preferred audio language (Japanese or English).",
|
||||||
|
valueIndex: 0, // Default to Japanese (or whichever you prefer)
|
||||||
|
entries: ["Japanese", "English"],
|
||||||
|
entryValues: ["jpn", "eng"]),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user