diff --git a/api/endpoints/views.py b/api/endpoints/views.py index 330b0d9..5f4d412 100644 --- a/api/endpoints/views.py +++ b/api/endpoints/views.py @@ -179,7 +179,7 @@ class DownloadView(viewsets.ViewSet): self.media_id, self.media_slug ) episodes_downloader.download_episode(self.download_id) - case "OVA": + case "OVA" | "SPECIAL": anime_download_film( id_film=self.media_id, title_name=self.media_slug ) @@ -191,7 +191,7 @@ class DownloadView(viewsets.ViewSet): } except Exception as e: response_dict = { - "error": "Error while downloading the media, please try again later", + "error": "Error while downloading the media", "message": str(e), } diff --git a/frontend/src/App.vue b/frontend/src/App.vue index c9129ab..ad56b70 100644 --- a/frontend/src/App.vue +++ b/frontend/src/App.vue @@ -13,4 +13,24 @@ import { RouterLink, RouterView } from 'vue-router' -moz-osx-font-smoothing: grayscale; margin-top: 60px; } + +button { + background-color: #42b883; + color: white; + border: none; + border-radius: 4px; + padding: 8px 16px; + font-size: 16px; + cursor: pointer; + transition: background-color 0.3s ease; +} + +button:hover { + background-color: #3a9f74; +} + +button:disabled { + background-color: #d3d3d3; + cursor: not-allowed; +} diff --git a/frontend/src/api/api.ts b/frontend/src/api/api.ts index 132a881..91b21d9 100644 --- a/frontend/src/api/api.ts +++ b/frontend/src/api/api.ts @@ -11,6 +11,14 @@ function get(url: string): Promise { }); } +function post(url: string, data: any): Promise { + return axios.post(`${BASE_URL}${url}`, data) + .then(response => response.data) + .catch(error => { + throw error; + }); +} + export default function search(query: string, type: string) : Promise { return get(`/search?search_terms=${query}&type=${type}`) } @@ -23,6 +31,14 @@ export async function getEpisodesInfo(mediaId: number, mediaSlug: string, mediaT 'Content-Type': 'text/event-stream' } }); +} - +export async function downloadFilm(mediaId: number, mediaSlug: string, mediaType: string): Promise { + const url = `/download/`; + const data = { + media_id: mediaId, + media_slug: mediaSlug, + type_media: mediaType + }; + return post(url, data); } \ No newline at end of file diff --git a/frontend/src/views/Details.vue b/frontend/src/views/Details.vue index 083b775..f53f5c2 100644 --- a/frontend/src/views/Details.vue +++ b/frontend/src/views/Details.vue @@ -2,7 +2,7 @@ import { useRoute } from 'vue-router' import type {Episode, MediaItem, Season, SeasonResponse} from "@/api/interfaces"; import { onMounted, ref } from "vue"; -import { getEpisodesInfo } from "@/api/api"; +import {downloadFilm, getEpisodesInfo} from "@/api/api"; const route = useRoute() @@ -11,9 +11,10 @@ const imageUrl: string = route.params.imageUrl const animeEpisodes = ref([]) const tvShowEpisodes = ref([]) const loading = ref(false) +const selectingEpisodes = ref(false) onMounted(async () => { - if (['MOVIE', 'OVA'].includes(item.type)) { + if (['MOVIE', 'OVA', 'SPECIAL'].includes(item.type)) { return } else { loading.value = true; @@ -46,6 +47,33 @@ onMounted(async () => { } } }) + +const toggleEpisodeSelection = () => { + selectingEpisodes.value = !selectingEpisodes.value +} + +const downloadItems = async () => { + try { + if (item.type === 'MOVIE') { + const res = await downloadFilm(item.id, item.slug, item.type) + if (res.error) { + throw new Error(res.error + ' - ' + res.message) + } + alertDownload() + return + } + } catch (error) { + alertDownload(error) + } +} + +const alertDownload = (message?: any) => { + if (message) { + alert(message) + return; + } + alert('Il downlaod è iniziato, il file sarà disponibile tra qualche minuto nella cartella \'Video\' del progetto...') +}