add download range

This commit is contained in:
Ghost 2024-02-06 19:11:15 +01:00
parent e228254499
commit 9ba3997c40
4 changed files with 21 additions and 24 deletions

View File

@ -145,15 +145,26 @@ def main_dw_tv(tv_id, tv_name, version, domain):
for ep in eps:
console.print(f"[green]Ep: [blue]{ep['n']} [green]=> [purple]{ep['name']}")
index_ep_select = str(msg.ask("\n[green]Insert ep [red]number [green]or [red](*) [green]to download all ep: "))
index_ep_select = str(msg.ask("\n[green]Insert ep [red]number [yellow]or [red](*) [green]to download all ep [yellow]or [red][1-2] [green]for a range of ep: "))
if index_ep_select != "*":
# Download range []
if "[" in index_ep_select:
start, end = map(int, index_ep_select[1:-1].split('-'))
result = list(range(start, end + 1))
for n_randge_ep in result:
index_ep_select = int(n_randge_ep)
dw_single_ep(tv_id, eps, n_randge_ep-1, domain, token, tv_name, season_select)
# Download single ep
elif index_ep_select != "*":
if 1 <= int(index_ep_select) <= len(eps):
index_ep_select = int(index_ep_select) - 1
dw_single_ep(tv_id, eps, index_ep_select, domain, token, tv_name, season_select)
else:
console.print("[red]Wrong index for ep")
# Download all
else:
for ep in eps:
dw_single_ep(tv_id, eps, int(ep['n'])-1, domain, token, tv_name, season_select)

View File

@ -1,5 +1,5 @@
__title__ = 'Streaming_community'
__version__ = 'v0.8.2'
__version__ = 'v0.8.3'
__author__ = 'Ghost6446'
__description__ = 'A command-line program to download film'
__license__ = 'MIT License'

View File

@ -178,24 +178,13 @@ class M3U8Downloader:
self.join_audio()
def join_audio(self):
command = [
"ffmpeg",
"-y",
"-i", self.video_path,
"-i", self.audio_path,
"-c", "copy",
"-map", "0:v:0",
"-map", "1:a:0",
"-shortest",
"-strict", "experimental",
self.video_path + ".mp4"
]
output_path = self.video_path + ".mp4"
try:
out = subprocess.run(command, check=True, stderr=subprocess.PIPE)
console.print("\n[green]Merge completed successfully.")
except subprocess.CalledProcessError as e:
print("ffmpeg output:", e.stderr.decode())
video_stream = ffmpeg.input(self.video_path)
audio_stream = ffmpeg.input(self.audio_path)
ffmpeg.output(video_stream, audio_stream, output_path, vcodec="copy", acodec="copy").global_args('-map', '0:v:0', '-map', '1:a:0', '-shortest', '-strict', 'experimental').run(overwrite_output=True)
except ffmpeg.Error as e:
print("ffmpeg error:", e.stderr)
os.remove(self.video_path)
os.remove(self.audio_path)

5
run.py
View File

@ -10,10 +10,7 @@ from Src.Upload.update import main_update
from Src.Util.FFmpeg.installer import check_ffmpeg
from Src.Util.Helper.os import remove_folder
# General import
import sys
# [ main ]
def initialize():
remove_folder("tmp")