fixes on the web player
This commit is contained in:
@@ -643,6 +643,10 @@ const AnimePlayer = (function() {
|
||||
|
||||
const currentExt = els.extSelect.value;
|
||||
|
||||
if (currentExt !== 'local') {
|
||||
_isLocal = false;
|
||||
_rawVideoData = null;
|
||||
}
|
||||
if (currentExt === 'local') {
|
||||
try {
|
||||
const localId = await getLocalEntryId();
|
||||
@@ -650,7 +654,14 @@ const AnimePlayer = (function() {
|
||||
setLoading("Local entry not found in library.");
|
||||
return;
|
||||
}
|
||||
const localUrl = `/api/library/stream/anime/${localId}/${_currentEpisode}`;
|
||||
const check = await fetch(`/api/library/anime/${localId}/episodes`);
|
||||
const eps = await check.json();
|
||||
|
||||
if (!eps.includes(_currentEpisode)) {
|
||||
// 🔥 forzar online
|
||||
els.extSelect.value = _entrySource;
|
||||
return loadStream();
|
||||
}
|
||||
|
||||
_rawVideoData = {
|
||||
url: window.location.origin + localUrl,
|
||||
@@ -666,9 +677,16 @@ const AnimePlayer = (function() {
|
||||
}
|
||||
|
||||
const server = els.serverSelect.value || "";
|
||||
const sourceParam = `&source=${_entrySource}`;
|
||||
const extParam = `&ext=${currentExt}`;
|
||||
const url = `/api/watch/stream?animeId=${_animeId}&episode=${_currentEpisode}&server=${encodeURIComponent(server)}&category=${_audioMode}${extParam}${sourceParam}`;
|
||||
const realSource = _entrySource === 'local' ? 'anilist' : _entrySource;
|
||||
|
||||
const url =
|
||||
`/api/watch/stream?animeId=${_animeId}` +
|
||||
`&episode=${_currentEpisode}` +
|
||||
`&server=${encodeURIComponent(server)}` +
|
||||
`&category=${_audioMode}` +
|
||||
`${extParam}` +
|
||||
`&source=${realSource}`;
|
||||
|
||||
try {
|
||||
const res = await fetch(url);
|
||||
@@ -691,9 +709,10 @@ const AnimePlayer = (function() {
|
||||
if (headers['Referer'] && headers['Referer'] !== "null") proxyUrl += `&referer=${encodeURIComponent(headers['Referer'])}`;
|
||||
if (headers['User-Agent']) proxyUrl += `&userAgent=${encodeURIComponent(headers['User-Agent'])}`;
|
||||
|
||||
|
||||
const subtitles = (source.subtitles || []).map(sub => ({
|
||||
label: sub.language,
|
||||
srclang: sub.id,
|
||||
srclang: sub.language.toLowerCase().slice(0, 2), // en
|
||||
src: `/api/proxy?url=${encodeURIComponent(sub.url)}`
|
||||
}));
|
||||
|
||||
@@ -753,7 +772,8 @@ const AnimePlayer = (function() {
|
||||
sendRPC({ startTimestamp: start, endTimestamp: end });
|
||||
});
|
||||
|
||||
if (Hls.isSupported() && (type === 'm3u8' || url.includes('.m3u8'))) {
|
||||
|
||||
if (Hls.isSupported() && (type === 'm3u8')) {
|
||||
hlsInstance = new Hls();
|
||||
hlsInstance.attachMedia(els.video);
|
||||
|
||||
@@ -762,8 +782,13 @@ const AnimePlayer = (function() {
|
||||
});
|
||||
|
||||
hlsInstance.on(Hls.Events.MANIFEST_PARSED, () => {
|
||||
attachSubtitles(subtitles);
|
||||
initPlyr();
|
||||
|
||||
els.video.addEventListener('loadedmetadata', () => {
|
||||
applyAniSkip(_malId, _currentEpisode);
|
||||
}, { once: true });
|
||||
|
||||
plyrInstance.on('ready', () => {
|
||||
createAudioSelector(hlsInstance);
|
||||
createQualitySelector(hlsInstance);
|
||||
|
||||
Reference in New Issue
Block a user