Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,6 +1,9 @@
|
|
|
|
|
|
|
|
1 |
import streamlit as st
|
2 |
from audio_recorder_streamlit import audio_recorder
|
3 |
-
|
4 |
import msoffcrypto
|
5 |
import docx
|
6 |
import pptx
|
@@ -375,9 +378,21 @@ class AudioProcessor:
|
|
375 |
raise e"""
|
376 |
|
377 |
class VideoProcessor:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
378 |
def __init__(self):
|
379 |
self.supported_formats = ['.mp4', '.avi', '.mov', '.mkv']
|
380 |
self.ydl_opts = {
|
|
|
381 |
'format': 'bestaudio/best',
|
382 |
'postprocessors': [{
|
383 |
'key': 'FFmpegExtractAudio',
|
@@ -405,10 +420,33 @@ class VideoProcessor:
|
|
405 |
except Exception:
|
406 |
return None
|
407 |
|
408 |
-
def download_youtube_audio(self, url: str) -> str:
|
409 |
with yt_dlp.YoutubeDL(self.ydl_opts) as ydl:
|
410 |
ydl.download([url])
|
411 |
-
return 'temp_audio.mp3'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
412 |
|
413 |
def extract_audio_from_video(self, video_path: str) -> str:
|
414 |
try:
|
|
|
1 |
+
import os
|
2 |
+
os.system('yt-dlp --cookies-from-browser chromium')
|
3 |
+
|
4 |
import streamlit as st
|
5 |
from audio_recorder_streamlit import audio_recorder
|
6 |
+
|
7 |
import msoffcrypto
|
8 |
import docx
|
9 |
import pptx
|
|
|
378 |
raise e"""
|
379 |
|
380 |
class VideoProcessor:
|
381 |
+
"""def __init__(self):
|
382 |
+
self.supported_formats = ['.mp4', '.avi', '.mov', '.mkv']
|
383 |
+
self.ydl_opts = {
|
384 |
+
'format': 'bestaudio/best',
|
385 |
+
'postprocessors': [{
|
386 |
+
'key': 'FFmpegExtractAudio',
|
387 |
+
'preferredcodec': 'mp3',
|
388 |
+
'preferredquality': '192',
|
389 |
+
}],
|
390 |
+
'outtmpl': 'temp_audio.%(ext)s'
|
391 |
+
}"""
|
392 |
def __init__(self):
|
393 |
self.supported_formats = ['.mp4', '.avi', '.mov', '.mkv']
|
394 |
self.ydl_opts = {
|
395 |
+
'cookiesfrombrowser': ('chromium',),
|
396 |
'format': 'bestaudio/best',
|
397 |
'postprocessors': [{
|
398 |
'key': 'FFmpegExtractAudio',
|
|
|
420 |
except Exception:
|
421 |
return None
|
422 |
|
423 |
+
"""def download_youtube_audio(self, url: str) -> str:
|
424 |
with yt_dlp.YoutubeDL(self.ydl_opts) as ydl:
|
425 |
ydl.download([url])
|
426 |
+
return 'temp_audio.mp3' """
|
427 |
+
def download_youtube_audio(self, url: str) -> str:
|
428 |
+
"""
|
429 |
+
Télécharge une vidéo YouTube en utilisant les cookies du navigateur.
|
430 |
+
"""
|
431 |
+
ydl_opts = {
|
432 |
+
'cookiesfrombrowser': ('chromium',), # Utilise Chromium pour les cookies
|
433 |
+
'format': 'bestaudio/best',
|
434 |
+
'postprocessors': [
|
435 |
+
{
|
436 |
+
'key': 'FFmpegExtractAudio',
|
437 |
+
'preferredcodec': 'mp3',
|
438 |
+
}
|
439 |
+
],
|
440 |
+
'outtmpl': 'temp_audio_with_cookies.%(ext)s'
|
441 |
+
}
|
442 |
+
|
443 |
+
try:
|
444 |
+
with yt_dlp.YoutubeDL(ydl_opts) as ydl:
|
445 |
+
ydl.download([url])
|
446 |
+
return 'temp_audio_with_cookies.mp3'
|
447 |
+
except Exception as e:
|
448 |
+
st.error(f"Erreur lors du téléchargement de la vidéo avec cookies : {str(e)}")
|
449 |
+
raise
|
450 |
|
451 |
def extract_audio_from_video(self, video_path: str) -> str:
|
452 |
try:
|