mirror of
https://github.com/ThaUnknown/miru.git
synced 2026-04-21 01:52:03 +00:00
AL completion
This commit is contained in:
parent
5db8a22abf
commit
e86d9ef7d6
5 changed files with 66 additions and 33 deletions
|
|
@ -37,7 +37,7 @@ function createWindow () {
|
||||||
icon: path.join(__dirname, '/renderer/public/favicon.ico'),
|
icon: path.join(__dirname, '/renderer/public/favicon.ico'),
|
||||||
show: false
|
show: false
|
||||||
})
|
})
|
||||||
mainWindow.removeMenu()
|
// mainWindow.removeMenu()
|
||||||
mainWindow.webContents.session.webRequest.onBeforeSendHeaders(
|
mainWindow.webContents.session.webRequest.onBeforeSendHeaders(
|
||||||
(details, callback) => {
|
(details, callback) => {
|
||||||
const { requestHeaders } = details
|
const { requestHeaders } = details
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,13 @@
|
||||||
<script>
|
<script>
|
||||||
import { getContext } from 'svelte'
|
import { getContext } from 'svelte'
|
||||||
import { alID } from '@/modules/anilist.js'
|
import { alID } from '@/modules/anilist.js'
|
||||||
|
import { media } from './pages/Player.svelte'
|
||||||
const sidebar = getContext('sidebar')
|
const sidebar = getContext('sidebar')
|
||||||
|
const view = getContext('view')
|
||||||
export let page
|
export let page
|
||||||
const links = [
|
const links = [
|
||||||
{
|
{
|
||||||
click: ()=>{
|
click: () => {
|
||||||
$sidebar = !$sidebar
|
$sidebar = !$sidebar
|
||||||
},
|
},
|
||||||
image: 'logo_cut.png',
|
image: 'logo_cut.png',
|
||||||
|
|
@ -28,7 +30,7 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
click: () => {
|
click: () => {
|
||||||
// TODO: open now playing
|
if (media) $view = media
|
||||||
},
|
},
|
||||||
icon: 'queue_music',
|
icon: 'queue_music',
|
||||||
text: 'Now Playing'
|
text: 'Now Playing'
|
||||||
|
|
|
||||||
|
|
@ -1,38 +1,52 @@
|
||||||
<script context="module">
|
<script context="module">
|
||||||
async function mediaChange(current, image) {
|
export let media = null
|
||||||
if (current) {
|
let fileMedia = null
|
||||||
const { release_group, anime_title, episode_number, episode_title } = await anitomyscript(current.name)
|
let hadImage = false
|
||||||
// honestly, this is made for anime, but works fantastic for everything else.
|
export function updateMedia(fileMed) {
|
||||||
const name = [anime_title, episode_number, episode_title].filter(i => i).join(' - ')
|
fileMedia = fileMed
|
||||||
if ('mediaSession' in navigator) {
|
media = fileMedia.media
|
||||||
const metadata = image
|
const name = [fileMedia.mediaTitle, fileMedia.episodeNumber, fileMedia.episodeTitle].filter(i => i).join(' - ')
|
||||||
? new MediaMetadata({
|
|
||||||
title: name || 'Video Player',
|
fileMedia.episodeThumbnail = !!fileMedia.episodeThumbnail
|
||||||
artwork: [
|
const metadata =
|
||||||
{
|
fileMedia.episodeThumbnail || fileMedia.mediaCover
|
||||||
src: image,
|
? new MediaMetadata({
|
||||||
sizes: '256x256',
|
title: name || 'Miru',
|
||||||
type: 'image/jpg'
|
artwork: [
|
||||||
}
|
{
|
||||||
]
|
src: fileMedia.episodeThumbnail || fileMedia.mediaCover,
|
||||||
})
|
sizes: '256x256',
|
||||||
: new MediaMetadata({
|
type: 'image/jpg'
|
||||||
title: name || 'Video Player'
|
}
|
||||||
})
|
]
|
||||||
if (release_group) metadata.artist = release_group
|
})
|
||||||
navigator.mediaSession.metadata = metadata
|
: new MediaMetadata({
|
||||||
}
|
title: name || 'Miru'
|
||||||
}
|
})
|
||||||
|
if (fileMedia.parseObject.release_group) metadata.artist = fileMedia.parseObject.release_group
|
||||||
|
navigator.mediaSession.metadata = metadata
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
import { alEntry } from '@/modules/anilist.js'
|
||||||
|
import { resolveFileMedia } from '@/modules/anime.js'
|
||||||
import Peer from '@/modules/Peer.js'
|
import Peer from '@/modules/Peer.js'
|
||||||
import Subtitles from '@/modules/subtitles.js'
|
import Subtitles from '@/modules/subtitles.js'
|
||||||
import { toTS, videoRx } from '@/modules/util.js'
|
import { toTS, videoRx } from '@/modules/util.js'
|
||||||
import anitomyscript from 'anitomyscript'
|
|
||||||
import Keyboard from './Keyboard.svelte'
|
import Keyboard from './Keyboard.svelte'
|
||||||
|
|
||||||
|
async function mediaChange(current, image) {
|
||||||
|
if (current && 'mediaSession' in navigator) {
|
||||||
|
if (!media || (!hadImage && image)) {
|
||||||
|
// filename is already mapped so this *should* be fine
|
||||||
|
const data = await resolveFileMedia({ fileName: current.name })
|
||||||
|
if (image) data.episodeThumbnail = image
|
||||||
|
updateMedia(data)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export let miniplayer = false
|
export let miniplayer = false
|
||||||
export let page
|
export let page
|
||||||
$: updateFiles(files)
|
$: updateFiles(files)
|
||||||
|
|
@ -145,10 +159,14 @@
|
||||||
interval: undefined,
|
interval: undefined,
|
||||||
video: undefined
|
video: undefined
|
||||||
})
|
})
|
||||||
|
src = ''
|
||||||
|
video?.load()
|
||||||
|
completed = false
|
||||||
file.getStreamURL((err, url) => {
|
file.getStreamURL((err, url) => {
|
||||||
src = url
|
src = url
|
||||||
current = file
|
current = file
|
||||||
video?.load()
|
video?.load()
|
||||||
|
currentTime = 0
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -599,6 +617,18 @@
|
||||||
target.classList.toggle('active')
|
target.classList.toggle('active')
|
||||||
target.closest('.dropdown').classList.toggle('show')
|
target.closest('.dropdown').classList.toggle('show')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let completed = false
|
||||||
|
function checkCompletion() {
|
||||||
|
if (!completed && duration - 180 < currentTime) {
|
||||||
|
if (fileMedia?.media?.episodes || fileMedia?.media?.nextAiringEpisode?.episode) {
|
||||||
|
if (fileMedia.media.episodes || fileMedia.media.nextAiringEpisode?.episode > fileMedia.episodeNumber) {
|
||||||
|
completed = true
|
||||||
|
alEntry(fileMedia)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<svelte:window on:keydown={handleKeydown} bind:innerWidth bind:innerHeight />
|
<svelte:window on:keydown={handleKeydown} bind:innerWidth bind:innerHeight />
|
||||||
|
|
@ -640,6 +670,7 @@
|
||||||
bind:muted
|
bind:muted
|
||||||
bind:playbackRate
|
bind:playbackRate
|
||||||
on:timeupdate={() => createThumbnail()}
|
on:timeupdate={() => createThumbnail()}
|
||||||
|
on:timeupdate={checkCompletion}
|
||||||
on:waiting={showBuffering}
|
on:waiting={showBuffering}
|
||||||
on:loadeddata={hideBuffering}
|
on:loadeddata={hideBuffering}
|
||||||
on:canplay={hideBuffering}
|
on:canplay={hideBuffering}
|
||||||
|
|
|
||||||
|
|
@ -54,12 +54,12 @@
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<Tabs>
|
<Tabs>
|
||||||
<div class="d-flex w-full h-full root">
|
<div class="d-flex w-full h-full">
|
||||||
<div class="d-flex flex-column h-full w-300 bg-dark border-left">
|
<div class="d-flex flex-column h-full w-300 bg-dark border-left">
|
||||||
<div class="px-20 py-15 font-size-20 font-weight-semi-bold border-bottom">Settings</div>
|
<div class="px-20 py-15 font-size-20 font-weight-semi-bold border-bottom root">Settings</div>
|
||||||
{#each Object.values(groups) as group}
|
{#each Object.values(groups) as group}
|
||||||
<TabLabel>
|
<TabLabel>
|
||||||
<div class="px-20 py-15 d-flex">
|
<div class="px-20 py-15 d-flex root">
|
||||||
<span class="material-icons font-size-24 pr-10">{group.icon}</span>
|
<span class="material-icons font-size-24 pr-10">{group.icon}</span>
|
||||||
<div>
|
<div>
|
||||||
<div class="font-weight-bold font-size-16">{group.name}</div>
|
<div class="font-weight-bold font-size-16">{group.name}</div>
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@ async function handleRequest (opts) {
|
||||||
}
|
}
|
||||||
|
|
||||||
export function alEntry (filemedia) {
|
export function alEntry (filemedia) {
|
||||||
if (filemedia.media && localStorage.getItem('ALtoken')) {
|
if (filemedia.media && alToken) {
|
||||||
alRequest({ method: 'SearchIDStatus', id: filemedia.media.id }).then(res => {
|
alRequest({ method: 'SearchIDStatus', id: filemedia.media.id }).then(res => {
|
||||||
if ((res.errors && res.errors[0].status === 404) || res.data.MediaList.progress <= filemedia.episodeNumber || filemedia.episodes === 1) {
|
if ((res.errors && res.errors[0].status === 404) || res.data.MediaList.progress <= filemedia.episodeNumber || filemedia.episodes === 1) {
|
||||||
const query = `
|
const query = `
|
||||||
|
|
@ -51,7 +51,7 @@ mutation ($id: Int, $status: MediaListStatus, $episode: Int, $repeat: Int) {
|
||||||
const options = {
|
const options = {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: {
|
headers: {
|
||||||
Authorization: 'Bearer ' + localStorage.getItem('ALtoken'),
|
Authorization: 'Bearer ' + alToken,
|
||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
Accept: 'application/json'
|
Accept: 'application/json'
|
||||||
},
|
},
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue