This repository has been archived on 2024-10-25. You can view files and clone it, but cannot push or open issues or pull requests.
CrunchyDL/pages/index.vue

145 lines
3.8 KiB
Vue
Raw Normal View History

2024-04-16 20:20:30 +02:00
<template>
2024-04-21 04:21:43 +02:00
<div class="h-screen overflow-hidden">
2024-04-16 20:20:30 +02:00
<MainHeader />
2024-04-21 04:21:43 +02:00
<div class="flex flex-col text-white mt-16 overflow-y-scroll h-[calc(100vh-4rem)]">
2024-04-18 00:54:47 +02:00
<!-- <button @click="deletePlaylist">
Delete Playlist
2024-04-18 00:54:47 +02:00
</button> -->
2024-04-21 14:20:41 +02:00
<div v-for="p in playlist" class="flex flex-row gap-4 h-40 p-5 bg-[#636363] border-b-[1px] border-gray-400">
2024-04-16 20:20:30 +02:00
<div class="flex min-w-52 w-52">
<img :src="p.media.images.thumbnail[0].find((p) => p.height === 1080)?.source" alt="Image" class="object-cover rounded-xl" />
</div>
<div class="flex flex-col w-full">
<div class="text-sm capitalize">
{{ p.status }}
</div>
<div class="text-base capitalize"> {{ p.media.series_title }} Season {{ p.media.season_number }} Episode {{ p.media.episode_number }} </div>
<div class="relative w-full min-h-5 bg-[#bdbbbb] mt-1 rounded">
<div
v-if="p.partsleft && p.status === 'downloading'"
class="w-full h-full rounded bg-[#4e422d] transition-all duration-300"
:style="`width: calc((${p.partsdownloaded} / ${p.partsleft}) * 100%);`"
></div>
2024-04-16 20:20:30 +02:00
<div v-if="p.status === 'completed'" class="w-full h-full rounded bg-[#79ff77] transition-all duration-300"></div>
<div v-if="p.status === 'merging'" class="absolute top-0 w-20 h-full rounded bg-[#293129] transition-all duration-300 loading-a"></div>
</div>
<div class="flex h-full"> </div>
<div class="flex flex-row gap-2 mt-2">
2024-04-21 14:20:41 +02:00
<div class="text-sm">{{ p.quality }}p</div>
2024-04-16 20:20:30 +02:00
<div class="text-sm">Dubs: {{ p.dub.map((t) => t.name).join(', ') }}</div>
2024-04-21 04:09:38 +02:00
<div class="text-sm">Subs: {{ p.sub.length !== 0 ? p.sub.map((t) => t.name).join(', ') : '-' }}</div>
2024-04-16 20:20:30 +02:00
<div v-if="p.partsleft && p.status === 'downloading'" class="text-sm">{{ p.partsdownloaded }}/{{ p.partsleft }}</div>
<div v-if="p.downloadspeed && p.status === 'downloading'" class="text-sm">{{ p.downloadspeed }} MB/s</div>
2024-04-16 20:20:30 +02:00
</div>
</div>
</div> </div
>s
</div>
</template>
<script lang="ts" setup>
import type { CrunchyEpisode } from '~/components/Episode/Types'
const playlist = ref<
Array<{
id: number
status: string
media: CrunchyEpisode
dub: Array<{ locale: string; name: string }>
sub: Array<{ locale: string; name: string }>
dir: string
partsleft: number
partsdownloaded: number
downloadspeed: number
2024-04-21 14:20:41 +02:00
quality: number
2024-04-16 20:20:30 +02:00
}>
>()
const getPlaylist = async () => {
const { data, error } = await useFetch<
Array<{
id: number
status: string
media: CrunchyEpisode
dub: Array<{ locale: string; name: string }>
sub: Array<{ locale: string; name: string }>
dir: string
partsleft: number
2024-04-16 20:20:30 +02:00
partsdownloaded: number
downloadspeed: number
2024-04-21 14:20:41 +02:00
quality: number
2024-04-16 20:20:30 +02:00
}>
>('http://localhost:8080/api/crunchyroll/playlist')
if (error.value) {
alert(error.value)
return
}
if (!data.value) {
return
}
playlist.value = data.value
2024-04-16 20:20:30 +02:00
}
const deletePlaylist = async () => {
const { data, error } = await useFetch('http://localhost:8080/api/crunchyroll/playlist', {
2024-04-21 14:20:41 +02:00
method: 'delete'
})
if (error.value) {
alert(error.value)
return
}
if (!data.value) {
return
}
}
2024-04-16 20:20:30 +02:00
onMounted(() => {
getPlaylist()
2024-04-20 17:45:32 +02:00
setInterval(getPlaylist, 1000)
2024-04-16 20:20:30 +02:00
})
</script>
2024-04-21 04:21:43 +02:00
<style scoped>
2024-04-16 20:20:30 +02:00
.loading-a {
animation: animation infinite 3s;
}
2024-04-21 04:21:43 +02:00
::-webkit-scrollbar-track {
background: #303030;
}
/* Handle */
::-webkit-scrollbar-thumb {
background: #cac9c9;
}
/* Handle on hover */
::-webkit-scrollbar-thumb:hover {
background: #555;
}
::-webkit-scrollbar {
width: 10px;
}
2024-04-16 20:20:30 +02:00
@keyframes animation {
0% {
left: 0%;
}
50% {
left: 88%;
}
100% {
left: 0%;
}
}
</style>