Spaces:
Sleeping
Sleeping
Update utils/file_utils.py
Browse files10 unmodified lines111213141516172 unmodified lines2021222324259 unmodified lines3536373839404110 unmodified lines# Utw贸rz tymczasowy katalogtemp_dir = tempfile.mkdtemp()# Konfiguracja yt-dlpydl_opts = {'format': 'bestaudio/best','outtmpl': os.path.join(temp_dir, '%(title)s.%(ext)s'),2 unmodified lines'preferredcodec': 'mp3','preferredquality': '192',}],}# Pobieranie pliku9 unmodified linesreturn downloaded_file, Noneexcept Exception as e:return None, f"B艂膮d podczas pobierania: {str(e)}"def validate_and_process_file(file_path):"""10 unmodified lines111213141516172 unmodified lines20212223242526272829303132333435363738399 unmodified lines495051525354555657585960616263646566676869707172737475767710 unmodified lines# Utw贸rz tymczasowy katalogtemp_dir = tempfile.mkdtemp()# Rozszerzona konfiguracja yt-dlpydl_opts = {'format': 'bestaudio/best','outtmpl': os.path.join(temp_dir, '%(title)s.%(ext)s'),2 unmodified lines'preferredcodec': 'mp3','preferredquality': '192',}],# Dodatkowe opcje do omini臋cia ogranicze艅'no_warnings': True,'quiet': True,'extract_flat': False,'force_generic_extractor': False,'sleep_interval': 2, # Czekaj 2 sekundy mi臋dzy pr贸bami'max_sleep_interval': 5,'sleep_interval_requests': 1,'extractor_args': {'youtube': {'player_skip': ['js', 'dash', 'hls'],'skip': ['hls', 'dash'],}}}# Pobieranie pliku9 unmodified linesreturn downloaded_file, Noneexcept Exception as e:error_msg = str(e)if "Sign in to confirm" in error_msg:# Spr贸buj jeszcze raz z innymi opcjamitry:ydl_opts.update({'force_generic_extractor': True,'extractor_args': {'generic': {'extract_flat': True,}}})with YoutubeDL(ydl_opts) as ydl:ydl.download([youtube_url])downloaded_files = [f for f in os.listdir(temp_dir) if f.endswith('.mp3')]if downloaded_files:downloaded_file = os.path.join(temp_dir, downloaded_files[0])return downloaded_file, Noneexcept:passreturn None, f"B艂膮d podczas pobierania: {error_msg}"def validate_and_process_file(file_path):"""
utils/file_utils.py+38-2