mirror of
https://github.com/kodjodevf/mangayomi-extensions.git
synced 2026-02-14 10:51:17 +00:00
extension(netflixMirror): Added stream quality preference
This commit is contained in:
@@ -7,7 +7,7 @@ const mangayomiSources = [{
|
|||||||
"typeSource": "single",
|
"typeSource": "single",
|
||||||
"isManga": false,
|
"isManga": false,
|
||||||
"itemType": 1,
|
"itemType": 1,
|
||||||
"version": "0.0.7",
|
"version": "0.0.9",
|
||||||
"dateFormat": "",
|
"dateFormat": "",
|
||||||
"dateFormatLocale": "",
|
"dateFormatLocale": "",
|
||||||
"pkgPath": "anime/src/all/netflixmirror.js"
|
"pkgPath": "anime/src/all/netflixmirror.js"
|
||||||
@@ -19,6 +19,11 @@ class DefaultExtension extends MProvider {
|
|||||||
return "https://pcmirror.cc"
|
return "https://pcmirror.cc"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async getPreference(key) {
|
||||||
|
const preferences = new SharedPreferences();
|
||||||
|
return preferences.get(key);
|
||||||
|
}
|
||||||
|
|
||||||
async getCookie() {
|
async getCookie() {
|
||||||
const preferences = new SharedPreferences();
|
const preferences = new SharedPreferences();
|
||||||
let cookie;
|
let cookie;
|
||||||
@@ -137,6 +142,26 @@ class DefaultExtension extends MProvider {
|
|||||||
return episodes;
|
return episodes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Sorts streams based on user preference.
|
||||||
|
async sortStreams(streams) {
|
||||||
|
var sortedStreams = [];
|
||||||
|
|
||||||
|
var copyStreams = streams.slice()
|
||||||
|
var pref = await this.getPreference("netmirror_pref_video_resolution");
|
||||||
|
for (var i in streams) {
|
||||||
|
var stream = streams[i];
|
||||||
|
if (stream.quality.indexOf(pref) > -1) {
|
||||||
|
sortedStreams.push(stream);
|
||||||
|
var index = copyStreams.indexOf(stream);
|
||||||
|
if (index > -1) {
|
||||||
|
copyStreams.splice(index, 1);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return [...sortedStreams, ...copyStreams]
|
||||||
|
}
|
||||||
|
|
||||||
async getVideoList(url) {
|
async getVideoList(url) {
|
||||||
const baseUrl = this.getTVApi();
|
const baseUrl = this.getTVApi();
|
||||||
const urlData = JSON.parse(url);
|
const urlData = JSON.parse(url);
|
||||||
@@ -194,7 +219,20 @@ class DefaultExtension extends MProvider {
|
|||||||
|
|
||||||
videoList[0].audios = audios;
|
videoList[0].audios = audios;
|
||||||
videoList[0].subtitles = subtitles;
|
videoList[0].subtitles = subtitles;
|
||||||
return videoList;
|
return this.sortStreams(videoList);
|
||||||
|
}
|
||||||
|
|
||||||
|
getSourcePreferences() {
|
||||||
|
return [{
|
||||||
|
key: 'netmirror_pref_video_resolution',
|
||||||
|
listPreference: {
|
||||||
|
title: 'Preferred video resolution',
|
||||||
|
summary: '',
|
||||||
|
valueIndex: 0,
|
||||||
|
entries: ["1080p", "720p", "480"],
|
||||||
|
entryValues: ["1080", "720", "480"]
|
||||||
|
}
|
||||||
|
},];
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user