mirror of
https://github.com/Arrowar/StreamingCommunity.git
synced 2025-06-07 12:05:35 +00:00
remove dependency from loading episodes to download all in anime series
This commit is contained in:
parent
31f99dbc30
commit
ba72616ce9
@ -44,4 +44,4 @@ async function downloadMedia(mediaId: number, mediaSlug: string, mediaType: stri
|
||||
export const downloadFilm = (mediaId: number, mediaSlug: string) => downloadMedia(mediaId, mediaSlug, 'MOVIE');
|
||||
export const downloadTvSeries = (mediaId: number, mediaSlug: string, downloadId: number) => downloadMedia(mediaId, mediaSlug, 'TV', downloadId);
|
||||
export const downloadAnimeFilm = (mediaId: number, mediaSlug: string) => downloadMedia(mediaId, mediaSlug, 'OVA');
|
||||
export const downloadAnimeSeries = (mediaId: number, mediaSlug: string, downloadId: number) => downloadMedia(mediaId, mediaSlug, 'OVA', downloadId);
|
||||
export const downloadAnimeSeries = (mediaId: number, mediaSlug: string, downloadId: number) => downloadMedia(mediaId, mediaSlug, 'TV_ANIME', downloadId);
|
||||
|
@ -16,10 +16,10 @@ export const handleMovieDownload = async (item: MediaItem) => {
|
||||
handleDownloadError(res);
|
||||
};
|
||||
|
||||
export const handleTVAnimeDownload = async (animeEpisodes: Episode[], item: MediaItem) => {
|
||||
export const handleTVAnimeDownload = async (episodeCount: number, item: MediaItem) => {
|
||||
alertDownload();
|
||||
for (const episode of animeEpisodes) {
|
||||
const res = (await downloadAnimeSeries(item.id, item.slug, episode.episode_id)).data;
|
||||
for (let i = 0; i < episodeCount; i++) {
|
||||
const res = (await downloadAnimeSeries(item.id, item.slug, i)).data;
|
||||
handleDownloadError(res);
|
||||
}
|
||||
};
|
||||
|
@ -4,12 +4,14 @@ import type {Episode, MediaItem, SeasonResponse} from "@/api/interfaces";
|
||||
import { onMounted, ref } from "vue";
|
||||
import { getEpisodesInfo } from "@/api/api";
|
||||
import { alertDownload, handleMovieDownload, handleOVADownload, handleTVAnimeDownload, handleTVDownload } from "@/api/utils";
|
||||
import {i} from "vite/dist/node/types.d-aGj9QkWt";
|
||||
|
||||
const route = useRoute()
|
||||
|
||||
const item: MediaItem = JSON.parse(<string>route.params.item)
|
||||
const imageUrl: string = <string>route.params.imageUrl
|
||||
const animeEpisodes = ref<Episode[]>([])
|
||||
const totalEpisodes = ref<number>(0)
|
||||
const tvShowEpisodes = ref<any[]>([])
|
||||
const loading = ref(false)
|
||||
const selectingEpisodes = ref(false)
|
||||
@ -32,6 +34,7 @@ onMounted(async () => {
|
||||
if (item.type === 'TV_ANIME') {
|
||||
const episodesData:Episode = JSON.parse(value.trim());
|
||||
animeEpisodes.value.push(episodesData);
|
||||
totalEpisodes.value = episodesData.episode_total;
|
||||
} else {
|
||||
const episodesData:SeasonResponse = JSON.parse(value.trim());
|
||||
for (const seasonKey in episodesData.episodes) {
|
||||
@ -54,6 +57,7 @@ const toggleEpisodeSelection = () => {
|
||||
}
|
||||
|
||||
const downloadItems = async () => {
|
||||
console.log(item)
|
||||
try {
|
||||
switch (item.type) {
|
||||
case 'TV':
|
||||
@ -62,7 +66,7 @@ const downloadItems = async () => {
|
||||
await handleMovieDownload(item);
|
||||
break;
|
||||
case 'TV_ANIME':
|
||||
await handleTVAnimeDownload(animeEpisodes.value, item);
|
||||
await handleTVAnimeDownload(totalEpisodes.value, item);
|
||||
break;
|
||||
case 'OVA':
|
||||
case 'SPECIAL':
|
||||
@ -91,7 +95,7 @@ const downloadItems = async () => {
|
||||
<p v-if="['TV_ANIME', 'OVA', 'SPECIAL'].includes(item.type)">{{ item.plot }}</p>
|
||||
<p v-else-if="tvShowEpisodes.length > 0">{{ tvShowEpisodes[0][0].plot }}</p>
|
||||
</div>
|
||||
<h3 v-if="animeEpisodes.length > 0 && !loading">Numero episodi: {{ animeEpisodes[0].episode_total }}</h3>
|
||||
<h3 v-if="animeEpisodes.length > 0 && !loading">Numero episodi: {{ totalEpisodes }}</h3>
|
||||
<h3 v-if="tvShowEpisodes.length > 0 && !loading">Numero stagioni: {{ tvShowEpisodes.length }}</h3>
|
||||
<hr style="opacity: 0.2; margin-top: 10px"/>
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user