None 782b03d248
Bump v3.0.2
* Add api "StreamingWatch"

* Add hdplayer

---------

Co-authored-by: Lovi <62809003+Lovi-0@users.noreply.github.com>
2025-05-01 14:22:47 +02:00

61 lines
1.6 KiB
Python

# 29.04.25
import os
# External library
from rich.console import Console
# Internal utilities
from StreamingCommunity.Util.os import os_manager
from StreamingCommunity.Util.message import start_message
from StreamingCommunity.Lib.Downloader import HLS_Downloader
# Logic class
from StreamingCommunity.Api.Template.config_loader import site_constant
from StreamingCommunity.Api.Template.Class.SearchType import MediaItem
# Player
from StreamingCommunity.Api.Player.hdplayer import VideoSource
# Variable
console = Console()
def download_film(select_title: MediaItem, proxy) -> str:
"""
Downloads a film using the provided film ID, title name, and domain.
Parameters:
- domain (str): The domain of the site
- version (str): Version of site.
Return:
- str: output path
"""
start_message()
console.print(f"[bold yellow]Download:[/bold yellow] [red]{site_constant.SITE_NAME}[/red] → [cyan]{select_title.name}[/cyan] \n")
# Get master playlists
video_source = VideoSource(proxy)
master_playlist = video_source.get_m3u8_url(select_title.url)
# Define the filename and path for the downloaded film
title_name = os_manager.get_sanitize_file(select_title.name) + ".mp4"
mp4_path = os.path.join(site_constant.MOVIE_FOLDER, title_name.replace(".mp4", ""))
# Download the film using the m3u8 playlist, and output filename
r_proc = HLS_Downloader(
m3u8_url=master_playlist,
output_path=os.path.join(mp4_path, title_name)
).start()
if r_proc['error'] is not None:
try: os.remove(r_proc['path'])
except: pass
return r_proc['path']