better error handeling
This commit is contained in:
parent
36969b929c
commit
1e8b27dc7b
@ -1,58 +0,0 @@
|
||||
<template>
|
||||
<div
|
||||
class="fixed bottom-3 right-5 p-3 flex flex-col bg-[#111111dc] w-80 min-h-24 rounded-xl font-dm text-white transition-all duration-300"
|
||||
:class="
|
||||
(data?.status === 'update-available' && !ignoreUpdate) || data?.status === 'downloading' || data?.status === 'update-downloaded'
|
||||
? 'opacity-100'
|
||||
: 'opacity-0 pointer-events-none'
|
||||
"
|
||||
>
|
||||
<button @click="ignoreUpdate = true" class="absolute right-3 top-2">
|
||||
<Icon name="akar-icons:cross" class="h-4 w-4 text-white" />
|
||||
</button>
|
||||
<div class="text-base text-center"> Update available </div>
|
||||
<div class="text-sm text-center"> A new update is available </div>
|
||||
<div v-if="data && data.info && data.info.version" class="text-sm text-center"> v{{ data.info.version }} </div>
|
||||
<button @click="startDownload" v-if="data && data.status === 'update-available'" class="text-sm py-3 bg-[#363434] mt-5 rounded-xl" :disabled="downloading">
|
||||
Download Update
|
||||
</button>
|
||||
<button v-if="data && data.status === 'downloading'" class="relative text-sm py-3 bg-[#363434] mt-5 rounded-xl overflow-hidden">
|
||||
<div class="absolute top-0 left-0 w-full h-full bg-[#a1a1a141] transition-all duration-300" :style="`width: calc((${data.info.percent} / 100) * 100%);`"></div>
|
||||
Downloading...
|
||||
</button>
|
||||
<button @click="startInstall" v-if="data && data.status === 'update-downloaded'" class="text-sm py-3 bg-[#363434] mt-5 rounded-xl" :disabled="installing">
|
||||
Install Update
|
||||
</button>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
const data = ref<{ status: string; info: any }>()
|
||||
const downloading = ref<boolean>(false)
|
||||
const installing = ref<boolean>(false)
|
||||
const ignoreUpdate = ref<boolean>(false)
|
||||
|
||||
const checkUpdate = () => {
|
||||
;(window as any).myAPI.getUpdateStatus().then((result: any) => {
|
||||
data.value = result
|
||||
})
|
||||
}
|
||||
|
||||
const startDownload = () => {
|
||||
downloading.value = true
|
||||
;(window as any).myAPI.startUpdateDownload()
|
||||
}
|
||||
|
||||
const startInstall = () => {
|
||||
installing.value = true
|
||||
;(window as any).myAPI.startUpdateInstall()
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
checkUpdate()
|
||||
|
||||
setInterval(checkUpdate, 2000)
|
||||
})
|
||||
</script>
|
||||
|
||||
<style></style>
|
@ -1,6 +1,5 @@
|
||||
<template>
|
||||
<div class="relative h-screen overflow-hidden">
|
||||
<Updater />
|
||||
<MainHeader />
|
||||
<div class="flex flex-col text-white gap-5 mt-14 p-5 overflow-y-scroll h-[calc(100vh-3.5rem)]">
|
||||
<!-- <button @click="deletePlaylist">
|
||||
@ -21,6 +20,10 @@
|
||||
<div class="flex flex-col w-full">
|
||||
<div class="flex flex-row h-full">
|
||||
<div class="flex flex-col">
|
||||
<div v-if="p.status === 'failed'" class="flex flex-row items-center justify-center gap-1 text-xs capitalize p-1.5 bg-[#863232] rounded-lg">
|
||||
<Icon name="bitcoin-icons:cross-filled" class="h-3.5 w-3.5 text-white" />
|
||||
{{ p.status }}
|
||||
</div>
|
||||
<div v-if="p.status === 'waiting'" class="flex flex-row items-center justify-center gap-1 text-xs capitalize p-1.5 bg-[#866332] rounded-lg">
|
||||
<Icon name="mdi:clock" class="h-3.5 w-3.5 text-white" />
|
||||
{{ p.status }}
|
||||
@ -78,7 +81,6 @@
|
||||
<script lang="ts" setup>
|
||||
import type { ADNEpisode } from '~/components/ADN/Types'
|
||||
import type { CrunchyEpisode } from '~/components/Episode/Types'
|
||||
import Updater from '~/components/Updater.vue'
|
||||
|
||||
const playlist = ref<
|
||||
Array<{
|
||||
|
@ -330,6 +330,7 @@ export async function downloadCrunchyrollPlaylist(
|
||||
var playlist = await crunchyGetPlaylistDRM(e)
|
||||
|
||||
if (!playlist) {
|
||||
await updatePlaylistByID(downloadID, 'failed')
|
||||
console.log('Playlist not found')
|
||||
return
|
||||
}
|
||||
@ -340,11 +341,14 @@ export async function downloadCrunchyrollPlaylist(
|
||||
if (found) {
|
||||
await deleteVideoToken(episodeID, playlist.data.token)
|
||||
playlist = await crunchyGetPlaylistDRM(found.guid)
|
||||
} else {
|
||||
console.log('Exact Playlist not found, taking what crunchy gives.')
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!playlist) {
|
||||
await updatePlaylistByID(downloadID, 'failed')
|
||||
console.log('Exact Playlist not found')
|
||||
return
|
||||
}
|
||||
@ -389,6 +393,7 @@ export async function downloadCrunchyrollPlaylist(
|
||||
}
|
||||
|
||||
if (!subPlaylist) {
|
||||
await updatePlaylistByID(downloadID, 'failed')
|
||||
console.log('Subtitle Playlist not found')
|
||||
return
|
||||
}
|
||||
@ -482,6 +487,7 @@ export async function downloadCrunchyrollPlaylist(
|
||||
console.log(playlist.mediaGroups.AUDIO.audio.main.playlists[0].segments[0])
|
||||
console.log(playlist.mediaGroups.AUDIO.audio.main.playlists[0].segments[0].uri)
|
||||
console.log('No AssetID found, exiting.')
|
||||
await updatePlaylistByID(downloadID, 'failed')
|
||||
return
|
||||
}
|
||||
|
||||
@ -534,11 +540,19 @@ export async function downloadCrunchyrollPlaylist(
|
||||
code = e
|
||||
}
|
||||
|
||||
if (!code) return console.error('No clean stream found')
|
||||
if (!code) {
|
||||
await updatePlaylistByID(downloadID, 'failed')
|
||||
console.log('No Clean stream found')
|
||||
return
|
||||
}
|
||||
|
||||
const play = await crunchyGetPlaylistDRM(code)
|
||||
|
||||
if (!play) return
|
||||
if (!play) {
|
||||
await updatePlaylistByID(downloadID, 'failed')
|
||||
console.log('Failed to get Playlist in download Video')
|
||||
return
|
||||
}
|
||||
|
||||
var downloadURL
|
||||
|
||||
|
Reference in New Issue
Block a user