CrunchyDL/pages/index.vue

164 lines
4.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">
<div v-if="p.service === 'CR'" class="flex min-w-52 w-52">
<img :src="(p.media as CrunchyEpisode).images.thumbnail[0].find((p) => p.height === 1080)?.source" alt="Image" class="object-cover rounded-xl" />
</div>
<div v-if="p.service === 'ADN'" class="flex min-w-52 w-52">
<img :src="(p.media as ADNEpisode).image2x" alt="Image" class="object-cover rounded-xl" />
2024-04-16 20:20:30 +02:00
</div>
<div class="flex flex-col w-full">
<div class="flex flex-row">
<div class="text-sm capitalize">
{{ p.status }}
</div>
<div class="text-sm capitalize ml-auto">
{{ p.service === 'CR' ? 'Crunchyroll' : 'ADN' }}
</div>
2024-04-16 20:20:30 +02:00
</div>
<div v-if="p.service === 'CR'" class="text-base capitalize">
{{ (p.media as CrunchyEpisode).series_title }} Season {{ (p.media as CrunchyEpisode).season_number }} Episode {{ (p.media as CrunchyEpisode).episode_number }}
</div>
<div v-if="p.service === 'ADN'" class="text-base capitalize">
{{ (p.media as ADNEpisode).show.title }} Season {{ (p.media as ADNEpisode).season ? (p.media as ADNEpisode).season : 1 }} Episode {{ (p.media as ADNEpisode).shortNumber }}
</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>
<div class="text-sm uppercase">{{ p.format }}</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>
<div v-if="p.partsleft && p.status === 'downloading'" class="text-sm ml-auto">{{ 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>
2024-04-16 20:20:30 +02:00
</div>
</template>
<script lang="ts" setup>
import type { ADNEpisode } from '~/components/ADN/Types'
2024-04-16 20:20:30 +02:00
import type { CrunchyEpisode } from '~/components/Episode/Types'
const playlist = ref<
Array<{
id: number
status: string
media: CrunchyEpisode | ADNEpisode
2024-04-16 20:20:30 +02:00
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
service: string
format: string
2024-04-16 20:20:30 +02:00
}>
>()
const getPlaylist = async () => {
const { data, error } = await useFetch<
Array<{
id: number
status: string
media: CrunchyEpisode | ADNEpisode
2024-04-16 20:20:30 +02:00
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
service: string
format: string
2024-04-16 20:20:30 +02:00
}>
>('http://localhost:8080/api/service/playlist')
2024-04-16 20:20:30 +02:00
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/service/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>