mirror of
https://github.com/Arrowar/StreamingCommunity.git
synced 2025-06-07 20:15:24 +00:00
start implementing download
This commit is contained in:
parent
d269cde308
commit
d775977f78
@ -179,7 +179,7 @@ class DownloadView(viewsets.ViewSet):
|
|||||||
self.media_id, self.media_slug
|
self.media_id, self.media_slug
|
||||||
)
|
)
|
||||||
episodes_downloader.download_episode(self.download_id)
|
episodes_downloader.download_episode(self.download_id)
|
||||||
case "OVA":
|
case "OVA" | "SPECIAL":
|
||||||
anime_download_film(
|
anime_download_film(
|
||||||
id_film=self.media_id, title_name=self.media_slug
|
id_film=self.media_id, title_name=self.media_slug
|
||||||
)
|
)
|
||||||
@ -191,7 +191,7 @@ class DownloadView(viewsets.ViewSet):
|
|||||||
}
|
}
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
response_dict = {
|
response_dict = {
|
||||||
"error": "Error while downloading the media, please try again later",
|
"error": "Error while downloading the media",
|
||||||
"message": str(e),
|
"message": str(e),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -13,4 +13,24 @@ import { RouterLink, RouterView } from 'vue-router'
|
|||||||
-moz-osx-font-smoothing: grayscale;
|
-moz-osx-font-smoothing: grayscale;
|
||||||
margin-top: 60px;
|
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;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
@ -11,6 +11,14 @@ function get(url: string): Promise<any> {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function post(url: string, data: any): Promise<any> {
|
||||||
|
return axios.post(`${BASE_URL}${url}`, data)
|
||||||
|
.then(response => response.data)
|
||||||
|
.catch(error => {
|
||||||
|
throw error;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
export default function search(query: string, type: string) : Promise<MediaItemResponse> {
|
export default function search(query: string, type: string) : Promise<MediaItemResponse> {
|
||||||
return get(`/search?search_terms=${query}&type=${type}`)
|
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'
|
'Content-Type': 'text/event-stream'
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function downloadFilm(mediaId: number, mediaSlug: string, mediaType: string): Promise<Response> {
|
||||||
|
const url = `/download/`;
|
||||||
|
const data = {
|
||||||
|
media_id: mediaId,
|
||||||
|
media_slug: mediaSlug,
|
||||||
|
type_media: mediaType
|
||||||
|
};
|
||||||
|
return post(url, data);
|
||||||
}
|
}
|
@ -2,7 +2,7 @@
|
|||||||
import { useRoute } from 'vue-router'
|
import { useRoute } from 'vue-router'
|
||||||
import type {Episode, MediaItem, Season, SeasonResponse} from "@/api/interfaces";
|
import type {Episode, MediaItem, Season, SeasonResponse} from "@/api/interfaces";
|
||||||
import { onMounted, ref } from "vue";
|
import { onMounted, ref } from "vue";
|
||||||
import { getEpisodesInfo } from "@/api/api";
|
import {downloadFilm, getEpisodesInfo} from "@/api/api";
|
||||||
|
|
||||||
const route = useRoute()
|
const route = useRoute()
|
||||||
|
|
||||||
@ -11,9 +11,10 @@ const imageUrl: string = <string>route.params.imageUrl
|
|||||||
const animeEpisodes = ref<Episode[]>([])
|
const animeEpisodes = ref<Episode[]>([])
|
||||||
const tvShowEpisodes = ref<any[]>([])
|
const tvShowEpisodes = ref<any[]>([])
|
||||||
const loading = ref(false)
|
const loading = ref(false)
|
||||||
|
const selectingEpisodes = ref(false)
|
||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
if (['MOVIE', 'OVA'].includes(item.type)) {
|
if (['MOVIE', 'OVA', 'SPECIAL'].includes(item.type)) {
|
||||||
return
|
return
|
||||||
} else {
|
} else {
|
||||||
loading.value = true;
|
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...')
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
@ -64,6 +92,14 @@ onMounted(async () => {
|
|||||||
</div>
|
</div>
|
||||||
<h3 v-if="animeEpisodes.length > 0 && !loading">Numero episodi: {{ animeEpisodes[0].episode_total }}</h3>
|
<h3 v-if="animeEpisodes.length > 0 && !loading">Numero episodi: {{ animeEpisodes[0].episode_total }}</h3>
|
||||||
<h3 v-if="tvShowEpisodes.length > 0 && !loading">Numero stagioni: {{ tvShowEpisodes.length }}</h3>
|
<h3 v-if="tvShowEpisodes.length > 0 && !loading">Numero stagioni: {{ tvShowEpisodes.length }}</h3>
|
||||||
|
<hr style="opacity: 0.2"/>
|
||||||
|
<div class="download-section">
|
||||||
|
<button :disabled="loading || selectingEpisodes" @click="downloadItems">Scarica {{['TV_ANIME', 'TV'].includes(item.type)? 'tutto' : ''}}</button>
|
||||||
|
<template v-if="!loading && ['TV_ANIME', 'TV'].includes(item.type)">
|
||||||
|
<button @click="toggleEpisodeSelection">{{selectingEpisodes ? 'Disattiva' : 'Attiva'}} selezione episodi</button>
|
||||||
|
<button>Download episodi</button>
|
||||||
|
</template>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@ -88,6 +124,11 @@ onMounted(async () => {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<!--MOVIES SECTION-->
|
||||||
|
<div v-else-if="!loading && ['MOVIE', 'OVA', 'SPECIAL'].includes(item.type)">
|
||||||
|
<p>Questo è un {{item.type}}</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
<!--LOADING SECTION-->
|
<!--LOADING SECTION-->
|
||||||
<div v-else-if="loading">
|
<div v-else-if="loading">
|
||||||
<p>Loading...</p>
|
<p>Loading...</p>
|
||||||
@ -126,7 +167,7 @@ h3 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.details-image {
|
.details-image {
|
||||||
max-width: 300px;
|
width: 295px;
|
||||||
margin-right: 2rem;
|
margin-right: 2rem;
|
||||||
border-radius: 0.5rem;
|
border-radius: 0.5rem;
|
||||||
}
|
}
|
||||||
@ -205,6 +246,15 @@ h3 {
|
|||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.download-section {
|
||||||
|
margin-top: 1rem;
|
||||||
|
flex: fit-content;
|
||||||
|
flex-direction: row;
|
||||||
|
button {
|
||||||
|
margin-right: 5px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@media (max-width: 768px) {
|
@media (max-width: 768px) {
|
||||||
.episodes-container {
|
.episodes-container {
|
||||||
grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
|
grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
|
||||||
|
@ -49,7 +49,7 @@ function searchTitle() {
|
|||||||
/>
|
/>
|
||||||
<div class="toggle-button-container">
|
<div class="toggle-button-container">
|
||||||
<Toggle v-model="selectedOption" class="search-toggle"></Toggle>
|
<Toggle v-model="selectedOption" class="search-toggle"></Toggle>
|
||||||
<button @click="searchTitle" class="search-button">Cerca</button>
|
<button @click="searchTitle">Cerca</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -104,21 +104,6 @@ function searchTitle() {
|
|||||||
margin: 0 8px;
|
margin: 0 8px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.search-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;
|
|
||||||
}
|
|
||||||
|
|
||||||
.search-button:hover {
|
|
||||||
background-color: #3a9f74;
|
|
||||||
}
|
|
||||||
|
|
||||||
.card-container {
|
.card-container {
|
||||||
display: grid;
|
display: grid;
|
||||||
grid-template-columns: repeat(4, 1fr);
|
grid-template-columns: repeat(4, 1fr);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user