fix: continue batch finding multiple media

fix: disable hw accell HEVC decode
This commit is contained in:
ThaUnknown 2022-08-19 00:06:36 +02:00
parent 6f1a19ab47
commit c7d747efc1
2 changed files with 13 additions and 12 deletions

View file

@ -1,6 +1,6 @@
{
"name": "Miru",
"version": "3.1.0",
"version": "3.1.1",
"author": "ThaUnknown_ <ThaUnknown@users.noreply.github.com>",
"main": "src/index.js",
"homepage": "https://github.com/ThaUnknown/miru#readme",

View file

@ -87,7 +87,15 @@ async function handleFiles (files) {
return file
})
const nowPlaying = get(media)
let nowPlaying = get(media)
if (!nowPlaying) {
const max = highest(videoFiles, (file) => file?.media?.media?.id).media
if (max?.media) {
nowPlaying = { media: max.media, episode: (max.media.mediaListEntry?.progress + 1 || 1) }
media.set(nowPlaying)
}
}
const filtered = nowPlaying?.media && videoFiles.filter(file => file.media?.media?.id && file.media?.media?.id === nowPlaying.media.id)
@ -97,18 +105,11 @@ async function handleFiles (files) {
processed.set([...result, ...otherFiles])
await tick()
if (nowPlaying?.episode && filtered.length) {
let file = videoFiles.find(({ media }) => media.episode === nowPlaying.episode)
if (!file) file = videoFiles.find(({ media }) => media.episode === 1)
playFile(file || 0)
} else {
const max = highest(videoFiles, (file) => file?.media?.media?.id)
const res = max.media?.media && result.find(({ media }) => media.episode === (max.media.media.mediaListEntry?.progress + 1 || 1) && media.media?.id === max.media.media?.id)
playFile(res || videoFiles.find(({ media }) => media.episode === 1) || 0)
}
const file = nowPlaying?.episode && (result.find(({ media }) => media.episode === nowPlaying.episode) || result.find(({ media }) => media.episode === 1) || 0)
playFile(file || 0)
}
const highest = (arr = [], mapfn = () => {}) => arr.reduce((acc, el) => {
const highest = (arr = [], mapfn = a => a) => arr.reduce((acc, el) => {
const mapped = mapfn(el)
acc.sums[mapped] = (acc.sums[mapped] || 0) + 1
acc.max = acc.sums[mapfn(acc.max)] > acc.sums[mapped] ? acc.max : el