Add domain ...

This commit is contained in:
Lovi 2024-06-13 16:25:11 +02:00
parent 2b2317705b
commit f3090c330c
5 changed files with 44 additions and 37 deletions

View File

@ -45,7 +45,8 @@ class GetSerieInfo:
try:
# Make an HTTP request to the series URL
response = httpx.get(self.url, headers=self.headers)
print(self.url)
response = httpx.get(self.url, headers=self.headers, timeout=10)
response.raise_for_status()
# Parse HTML content of the page

View File

@ -62,6 +62,7 @@ def donwload_video(scape_info_serie: GetSerieInfo, index_season_selected: int, i
output_filename = os.path.join(mp4_path, mp4_name)
).start()
def donwload_episode(scape_info_serie: GetSerieInfo, index_season_selected: int, donwload_all: bool = False) -> None:
"""
Download all episodes of a season.
@ -101,7 +102,6 @@ def donwload_episode(scape_info_serie: GetSerieInfo, index_season_selected: int,
donwload_video(scape_info_serie, index_season_selected, i_episode)
def download_series(dict_serie: MediaItem) -> None:
# Start message and set up video source

View File

@ -28,7 +28,9 @@ table_show_manager = TVShowManager()
# Config
SITE_NAME = "guardaserie"
ROOT_PATH = config_manager.get('DEFAULT', 'root_path')
DOMAIN_NOW = config_manager.get('SITE', SITE_NAME)
@ -38,7 +40,7 @@ def title_search(word_to_search) -> int:
"""
# Send request to search for titles
response = httpx.get(f"https://guardaserie.ceo/?story={word_to_search}&do=search&subaction=search", headers={'user-agent': get_headers()})
response = httpx.get(f"https://guardaserie.{DOMAIN_NOW}/?story={word_to_search}&do=search&subaction=search", headers={'user-agent': get_headers()})
response.raise_for_status()
# Create soup and find table

View File

@ -31,22 +31,24 @@ REQUEST_TIMEOUT = config_manager.get_float('REQUESTS', 'timeout')
def MP4_downloader(url: str, path: str, referer: str, add_desc: str):
if not os.path.exists(path):
console.log("[cyan]Video [red]already exists.")
sys.exit(0)
# Make request to get content of video
logging.info(f"Make request to fetch mp4 from: {url}")
response = httpx.get(url, stream=True, headers={'Referer': referer, 'user-agent': get_headers()}, verify=REQUEST_VERIFY, timeout=REQUEST_TIMEOUT)
total = int(response.headers.get('content-length', 0))
headers = {'Referer': referer, 'user-agent': get_headers()}
with httpx.Client(verify=REQUEST_VERIFY, timeout=REQUEST_TIMEOUT) as client:
with client.stream("GET", url, headers=headers) as response:
total = int(response.headers.get('content-length', 0))
# Create bar format
if TQDM_USE_LARGE_BAR:
bar_format=f"{Colors.YELLOW}Downloading {Colors.WHITE}({add_desc}{Colors.WHITE}): {Colors.RED}{{percentage:.2f}}% {Colors.MAGENTA}{{bar}} {Colors.WHITE}[ {Colors.YELLOW}{{n_fmt}}{Colors.WHITE} / {Colors.RED}{{total_fmt}} {Colors.WHITE}] {Colors.YELLOW}{{elapsed}} {Colors.WHITE}< {Colors.CYAN}{{remaining}} {Colors.WHITE}| {Colors.YELLOW}{{rate_fmt}}{{postfix}} {Colors.WHITE}]"
bar_format = (f"{Colors.YELLOW}Downloading {Colors.WHITE}({add_desc}{Colors.WHITE}): "
f"{Colors.RED}{{percentage:.2f}}% {Colors.MAGENTA}{{bar}} {Colors.WHITE}[ "
f"{Colors.YELLOW}{{n_fmt}}{Colors.WHITE} / {Colors.RED}{{total_fmt}} {Colors.WHITE}] "
f"{Colors.YELLOW}{{elapsed}} {Colors.WHITE}< {Colors.CYAN}{{remaining}} {Colors.WHITE}| "
f"{Colors.YELLOW}{{rate_fmt}}{{postfix}} {Colors.WHITE}]")
else:
bar_format=f"{Colors.YELLOW}Proc{Colors.WHITE}: {Colors.RED}{{percentage:.2f}}% {Colors.WHITE}| {Colors.CYAN}{{remaining}}{{postfix}} {Colors.WHITE}]"
bar_format = (f"{Colors.YELLOW}Proc{Colors.WHITE}: {Colors.RED}{{percentage:.2f}}% "
f"{Colors.WHITE}| {Colors.CYAN}{{remaining}}{{postfix}} {Colors.WHITE}]")
# Create progress bar
progress_bar = tqdm(
@ -58,17 +60,18 @@ def MP4_downloader(url: str, path: str, referer: str, add_desc: str):
unit_divisor=1024
)
# Download file
with open(path, 'wb') as file, progress_bar as bar:
for data in response.iter_content(chunk_size=1024):
size = file.write(data)
for chunk in response.iter_bytes(chunk_size=1024):
if chunk:
size = file.write(chunk)
bar.update(size)
# Get summary
console.print(Panel(
f"[bold green]Download completed![/bold green]\n"
f"File size: [bold red]{format_size(os.path.getsize(path))}[/bold red]\n"
f"Duration: [bold]{print_duration_table(path, show=False)}[/bold]",
title=f"{os.path.basename(path.replace('.mp4', ''))}", border_style="green"))
title=f"{os.path.basename(path.replace('.mp4', ''))}",
border_style="green"
))

View File

@ -45,6 +45,7 @@
"SITE": {
"streamingcommunity": "foo",
"animeunity": "to",
"altadefinizione": "vodka"
"altadefinizione": "vodka",
"guardaserie": "ceo"
}
}