new domain and black on project

This commit is contained in:
Francesco Grazioso 2024-04-28 17:45:47 +02:00
parent 99b17aa652
commit 5b8379f0e6
3 changed files with 35 additions and 16 deletions

View File

@ -14,6 +14,7 @@ Including another URLconf
1. Import the include() function: from django.urls import include, path 1. Import the include() function: from django.urls import include, path
2. Add a URL to urlpatterns: path('blog/', include('blog.urls')) 2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
""" """
from django.contrib import admin from django.contrib import admin
from django.urls import path, include from django.urls import path, include

View File

@ -82,7 +82,9 @@ class SearchView(viewsets.ViewSet):
return Response({"episodes": episodes}) return Response({"episodes": episodes})
case "TV_ANIME": case "TV_ANIME":
episodes = [] episodes = []
episodes_downloader = EpisodeDownloader(self.media_id, self.media_slug) episodes_downloader = EpisodeDownloader(
self.media_id, self.media_slug
)
episoded_count = episodes_downloader.get_count_episodes() episoded_count = episodes_downloader.get_count_episodes()
items_per_page = 5 items_per_page = 5
paginator = Paginator(range(episoded_count), items_per_page) paginator = Paginator(range(episoded_count), items_per_page)
@ -136,11 +138,22 @@ class DownloadView(viewsets.ViewSet):
video_source.collect_title_season(self.download_id) video_source.collect_title_season(self.download_id)
episodes_count = video_source.obj_episode_manager.get_length() episodes_count = video_source.obj_episode_manager.get_length()
for i_episode in range(1, episodes_count + 1): for i_episode in range(1, episodes_count + 1):
episode_id = video_source.obj_episode_manager.episodes[i_episode - 1].id episode_id = video_source.obj_episode_manager.episodes[
i_episode - 1
].id
# Define filename and path for the downloaded video # Define filename and path for the downloaded video
mp4_name = remove_special_characters(f"{map_episode_title(self.media_slug,video_source.obj_episode_manager.episodes[i_episode - 1],self.download_id)}.mp4") mp4_name = remove_special_characters(
mp4_path = remove_special_characters(os.path.join(ROOT_PATH, SERIES_FOLDER, self.media_slug, f"S{self.download_id}")) f"{map_episode_title(self.media_slug,video_source.obj_episode_manager.episodes[i_episode - 1],self.download_id)}.mp4"
)
mp4_path = remove_special_characters(
os.path.join(
ROOT_PATH,
SERIES_FOLDER,
self.media_slug,
f"S{self.download_id}",
)
)
os.makedirs(mp4_path, exist_ok=True) os.makedirs(mp4_path, exist_ok=True)
# Get iframe and content for the episode # Get iframe and content for the episode
@ -152,16 +165,20 @@ class DownloadView(viewsets.ViewSet):
obj_download = Downloader( obj_download = Downloader(
m3u8_playlist=video_source.get_playlist(), m3u8_playlist=video_source.get_playlist(),
key=video_source.get_key(), key=video_source.get_key(),
output_filename = os.path.join(mp4_path, mp4_name) output_filename=os.path.join(mp4_path, mp4_name),
) )
obj_download.download_m3u8() obj_download.download_m3u8()
case "TV_ANIME": case "TV_ANIME":
episodes_downloader = EpisodeDownloader(self.media_id, self.media_slug) episodes_downloader = EpisodeDownloader(
self.media_id, self.media_slug
)
episodes_downloader.download_episode(self.download_id) episodes_downloader.download_episode(self.download_id)
case "OVA": case "OVA":
anime_download_film(id_film=self.media_id, title_name=self.media_slug) anime_download_film(
id_film=self.media_id, title_name=self.media_slug
)
case _: case _:
raise Exception("Type media not supported") raise Exception("Type media not supported")

View File

@ -2,7 +2,8 @@
"""Django's command-line utility for administrative tasks.""" """Django's command-line utility for administrative tasks."""
import os import os
import sys import sys
sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '..')))
sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), "..")))
def main(): def main():