mirror of
https://github.com/Arrowar/StreamingCommunity.git
synced 2025-06-07 12:05:35 +00:00
start implementing preview endpoint
This commit is contained in:
parent
59535f08ce
commit
ad132b7c53
@ -60,4 +60,17 @@ class PreviewManager:
|
||||
images_str = "\n".join(str(image) for image in self.images)
|
||||
return f"Title: ID={self.id}, Type={self.type}, Runtime={self.runtime}, Release Date={self.release_date}, Quality={self.quality}, Plot={self.plot}, Seasons Count={self.seasons_count}\nGenres:\n{genres_str}\nPreview:\n{self.preview}\nImages:\n{images_str}"
|
||||
|
||||
def to_dict(self):
|
||||
return {
|
||||
"id": self.id,
|
||||
"type": self.type,
|
||||
"runtime": self.runtime,
|
||||
"release_date": self.release_date,
|
||||
"quality": self.quality,
|
||||
"plot": self.plot,
|
||||
"seasons_count": self.seasons_count,
|
||||
"genres": [genre.__dict__ for genre in self.genres],
|
||||
"preview": self.preview.__dict__,
|
||||
"images": [image.__dict__ for image in self.images]
|
||||
}
|
||||
|
||||
|
@ -60,4 +60,17 @@ class PreviewManager:
|
||||
images_str = "\n".join(str(image) for image in self.images)
|
||||
return f"Title: ID={self.id}, Type={self.type}, Runtime={self.runtime}, Release Date={self.release_date}, Quality={self.quality}, Plot={self.plot}, Seasons Count={self.seasons_count}\nGenres:\n{genres_str}\nPreview:\n{self.preview}\nImages:\n{images_str}"
|
||||
|
||||
def to_dict(self):
|
||||
return {
|
||||
"id": self.id,
|
||||
"type": self.type,
|
||||
"runtime": self.runtime,
|
||||
"release_date": self.release_date,
|
||||
"quality": self.quality,
|
||||
"plot": self.plot,
|
||||
"seasons_count": self.seasons_count,
|
||||
"genres": [genre.__dict__ for genre in self.genres],
|
||||
"preview": self.preview.__dict__,
|
||||
"images": [image.__dict__ for image in self.images]
|
||||
}
|
||||
|
||||
|
@ -121,6 +121,34 @@ class SearchView(viewsets.ViewSet):
|
||||
)
|
||||
|
||||
return Response({"error": "No media found with that search query"})
|
||||
|
||||
@action(detail=False, methods=["get"])
|
||||
def get_preview(self, request):
|
||||
self.media_id = request.query_params.get("media_id")
|
||||
self.media_slug = request.query_params.get("media_slug")
|
||||
self.type_media = request.query_params.get("type_media")
|
||||
|
||||
try:
|
||||
if self.type_media in ["TV", "MOVIE"]:
|
||||
version, domain = get_version_and_domain()
|
||||
video_source = film_video_source()
|
||||
video_source.setup(media_id=self.media_id, version=version, domain=domain, series_name=self.media_slug)
|
||||
video_source.get_preview()
|
||||
return Response(video_source.obj_preview.to_dict())
|
||||
if self.type_media in ["TV_ANIME", "OVA", "SPECIAL"]:
|
||||
video_source = anime_source()
|
||||
video_source.setup(media_id=self.media_id, series_name=self.media_slug)
|
||||
video_source.get_preview()
|
||||
return Response(video_source.obj_preview.to_dict())
|
||||
except Exception as e:
|
||||
return Response(
|
||||
{
|
||||
"error": "Error while getting preview info",
|
||||
"message": str(e),
|
||||
}
|
||||
)
|
||||
|
||||
return Response({"error": "No media found with that search query"})
|
||||
|
||||
|
||||
'''
|
||||
|
@ -37,6 +37,15 @@ export async function getEpisodesInfo(
|
||||
});
|
||||
}
|
||||
|
||||
export async function getPreview(
|
||||
mediaId: number,
|
||||
mediaSlug: string,
|
||||
mediaType: string
|
||||
): Promise<AxiosResponse<any>> {
|
||||
const url = `/search/get_preview?media_id=${mediaId}&media_slug=${mediaSlug}&type_media=${mediaType}`;
|
||||
return get(url);
|
||||
}
|
||||
|
||||
async function downloadMedia(
|
||||
mediaId: number,
|
||||
mediaSlug: string,
|
||||
|
@ -1,8 +1,8 @@
|
||||
<script setup lang="ts">
|
||||
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 type {Episode, MediaItem, SeasonResponse} from "@/api/interfaces";
|
||||
import { onBeforeMount, onMounted, ref } from "vue";
|
||||
import { getEpisodesInfo, getPreview } from "@/api/api";
|
||||
import {
|
||||
alertDownload,
|
||||
handleMovieDownload,
|
||||
@ -22,13 +22,21 @@ const tvShowEpisodes = ref<any[]>([])
|
||||
const loading = ref(false)
|
||||
const selectingEpisodes = ref(false)
|
||||
const selectedEpisodes = ref<Episode[]>([])
|
||||
const previewItem = ref<MediaItem>(item)
|
||||
|
||||
onBeforeMount(async () => {
|
||||
const res = await getPreview(item.id, item.slug, item.type)
|
||||
if (res && res.data) {
|
||||
previewItem.plot = res.data.plot
|
||||
}
|
||||
})
|
||||
|
||||
onMounted(async () => {
|
||||
console.log(item)
|
||||
loading.value = true;
|
||||
if (['MOVIE', 'OVA', 'SPECIAL'].includes(item.type)) {
|
||||
loading.value = false;
|
||||
return
|
||||
} else {
|
||||
loading.value = true;
|
||||
const response = await getEpisodesInfo(item.id, item.slug, item.type)
|
||||
if (response && response.body) {
|
||||
loading.value = false;
|
||||
|
Loading…
x
Reference in New Issue
Block a user