Spaces:
Build error
Build error
Update download.py
Browse files9 unmodified lines10111213141516331 unmodified lines3483493503513523533543553563573583593603613623633643653663673683693703713723733743753769 unmodified linesfrom typing import Optional, Callable, Dict, Any, Union# ConfigurationMAX_FILE_SIZE = 40 * 1024 * 1024 # 40 MB (increased from your original 100MB)FILE_TOO_LARGE_MESSAGE = "The audio file exceeds the 40MB size limit. Please try a shorter video clip or select a lower quality option."MAX_RETRIES = 3RETRY_DELAY = 2 # seconds331 unmodified linesreturn infoexcept Exception as e:logger.error(f"Error getting video info: {str(e)}")raise DownloadError(f"Could not retrieve video information: {str(e)}")# Example usageif __name__ == "__main__":# Example progress callbackdef print_progress(msg):print(msg)try:# Example: Download audio from a YouTube URLurl = "https://www.youtube.com/watch?v=dQw4w9WgXcQ"audio_path = download_video_audio(url,output_dir="./downloads",audio_format="mp3",progress_callback=print_progress)print(f"Downloaded to: {audio_path}")# Clean upif audio_path:delete_download(audio_path)except DownloadError as e:print(f"Download failed: {e}")9 unmodified lines10111213141516331 unmodified lines3483493503519 unmodified linesfrom typing import Optional, Callable, Dict, Any, Union# ConfigurationMAX_FILE_SIZE = 40 * 1024 * 1024 # 40 MBFILE_TOO_LARGE_MESSAGE = "The audio file exceeds the 40MB size limit. Please try a shorter video clip or select a lower quality option."MAX_RETRIES = 3RETRY_DELAY = 2 # seconds331 unmodified linesreturn infoexcept Exception as e:logger.error(f"Error getting video info: {str(e)}")raise DownloadError(f"Could not retrieve video information: {str(e)}")
download.py+2-27