Spaces:
Build error
Build error
| from pathlib import Path | |
| import requests | |
| from rich.console import Console | |
| console = Console() | |
| def download_file(url: str, file_path: Path) -> Path: | |
| console.log(f"π₯ Downloading File from URL: {url}") | |
| response = requests.get(url, stream=True) | |
| if response.status_code == 200: | |
| with file_path.open('wb') as file: | |
| for chunk in response.iter_content(chunk_size=1024): | |
| if chunk: | |
| file.write(chunk) | |
| console.log(f"β File Successfully Downloaded! Path: {file_path}") | |
| else: | |
| console.log(f"π¨ Error downloading file from {url}.") | |
| return file_path | |
| def download_api(url: str, file_path: Path) -> Path: | |
| # Download the video from internet | |
| video_path = file_path + '/video.mp4' | |
| console.log("π Starting the Video Download...") | |
| video_path = download_file(url, video_path) | |
| console.log(f"π Video Download Complete! Path: {video_path}") | |
| return video_path |