Fix run and update discord link

This commit is contained in:
Ghost 2024-04-12 18:05:35 +02:00
parent f91d734b8e
commit cb6d5837f2
5 changed files with 42 additions and 22 deletions

View File

@ -7,11 +7,10 @@
This repository provide a simple script designed to facilitate the downloading of films and series from a popular streaming community platform. The script allows users to download individual films, entire series, or specific episodes, providing a seamless experience for content consumers.
## Join us
You can chat, help improve this repo, or just hang around for some fun in the **Git_StreamingCommunity** Discord [Server](https://discord.gg/we8n4tfxFs)
You can chat, help improve this repo, or just hang around for some fun in the **Git_StreamingCommunity** Discord [Server](https://discord.gg/PtMX28v5)
# Table of Contents
* [INSTALLATION](#installation)
* [Requirement](#requirement)
* [Usage](#usage)
* [Update](#update)

View File

@ -149,7 +149,7 @@ def test_site(domain: str) -> str:
try:
response = requests.get(site_url, headers={'user-agent': get_headers()})
console.print(f"[green]Request response [white]=> [red]{response.status_code} \n")
response.raise_for_status() # Raise an error if request fails
response.raise_for_status()
if response.ok:
return response.text

View File

@ -566,7 +566,7 @@ class Downloader():
m3u8_index_obj = parse_class_m3u8.get_best_quality()
# Get URI of the best quality and codecs parameters
console.log(f"[cyan]Select resolution: [red]{m3u8_index_obj.get('width')}")
console.log(f"[cyan]Find resolution: [red]{m3u8_index_obj.get('width')}")
m3u8_index = m3u8_index_obj.get('uri')
# Fix URL if it is not complete with http:\\site_name.domain\...
@ -588,7 +588,7 @@ class Downloader():
# Get obj codec
self.codec: M3U8_Codec = parse_class_m3u8.codec
logging.info(f"Get codeds: {self.codec}")
console.log(f"[cyan]Use codecs: [red]({self.codec.video_codec_name};{self.codec.audio_codec_name})")
console.log(f"[cyan]Find codecs: [red]({self.codec.video_codec_name};{self.codec.audio_codec_name})")
def manage_subtitle(self):
"""

View File

@ -170,7 +170,7 @@ def download_ffmpeg():
# Generate install directory path
install_dir = os.path.join(INSTALL_DIR, 'FFMPEG')
console.print(f"[cyan]f'Making install directory: [red]{install_dir!r}")
console.print(f"[cyan]Making install directory: [red]{install_dir!r}")
logging.info(f'Making install directory {install_dir!r}')
os.makedirs(install_dir, exist_ok=True)
@ -210,6 +210,7 @@ def check_ffmpeg() -> bool:
console.print("[green]Checking FFmpeg...")
try:
# Try running the FFmpeg command to check if it exists
subprocess.run(["ffmpeg", "-version"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
console.print("[blue]FFmpeg is installed. \n")
@ -235,6 +236,5 @@ def check_ffmpeg() -> bool:
# If unable to download or add FFmpeg to the PATH
console.print("[red]Unable to download or add FFmpeg to the PATH.[/red]")
console.print(f"Error: {e}")
raise
return False
return False

49
run.py
View File

@ -4,6 +4,7 @@ import sys
import logging
import platform
import argparse
from typing import Callable
# Internal utilities
@ -91,9 +92,9 @@ def initialize():
temp_config_manager.add_variable('Requirements', 'ffmpeg', True)
def main():
def main_film_series():
"""
Main function of the application.
Main function of the application for film and series.
"""
# Get site domain and version
@ -134,9 +135,9 @@ def main():
console.print("\n[red]Done")
def main_switch():
def main_anime():
"""
Main function for anime unity
Main function of the application for anime unity
"""
# Get site domain and version
@ -169,7 +170,15 @@ def main_switch():
else:
console.print("[red]Cant find a single element")
def run_function(func, close_console=False):
def run_function(func: Callable[..., None], close_console: bool = False) -> None:
"""
Run a given function indefinitely or once, depending on the value of close_console.
Parameters:
func (Callable[..., None]): The function to run.
close_console (bool, optional): Whether to close the console after running the function once. Defaults to False.
"""
if close_console:
while 1:
func()
@ -177,7 +186,9 @@ def run_function(func, close_console=False):
func()
if __name__ == '__main__':
def main():
# Create instance of logger
logger = Logger()
# Parse command line arguments
@ -187,16 +198,26 @@ if __name__ == '__main__':
args = parser.parse_args()
if args.anime:
run_function(main_switch, CLOSE_CONSOLE)
run_function(main_anime, CLOSE_CONSOLE)
elif args.film:
run_function(main, CLOSE_CONSOLE)
run_function(main_film_series, CLOSE_CONSOLE)
else:
# If no arguments are provided, ask the user to input the category
category = input("Insert category (0: Film/series, 1: Anime) : ")
# If no arguments are provided, ask the user to input the category, if nothing insert return 0
category = msg.ask("[cyan]Insert category [white]([red]0[white]: [bold magenta]Film/Series[white], [red]1[white]: [bold magenta]Anime[white])[white]:[/cyan]", choices={"0": "", "1": ""}, default="0")
if category == '0':
run_function(main, CLOSE_CONSOLE)
run_function(main_film_series, CLOSE_CONSOLE)
elif category == '1':
run_function(main_switch, CLOSE_CONSOLE)
run_function(main_anime, CLOSE_CONSOLE)
else:
console.print("[red]Invalid category")
sys.exit(0)
console.print("[red]Invalid category, you need to insert 0 or 1.")
sys.exit(0)
if __name__ == '__main__':
main()