Spaces:
Runtime error
Runtime error
Commit
•
aafa630
1
Parent(s):
b604e28
Update app.py
Browse files
app.py
CHANGED
@@ -11,16 +11,17 @@ SIMBALS_MAIN_DATABASE = 2
|
|
11 |
embed_html1 = '<iframe width="560" height="315" src="https://www.youtube.com/embed/'
|
12 |
embed_html2 = '" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>'
|
13 |
|
|
|
|
|
|
|
|
|
|
|
|
|
14 |
|
15 |
def download_audio(id_video):
|
16 |
-
video = YouTube(id_video,use_oauth=True, allow_oauth_cache=True)
|
17 |
id = id_video.split("?v=")[-1][:11]
|
18 |
-
|
19 |
-
|
20 |
-
audio_stream = audio_streams[0]
|
21 |
-
audio_file = audio_stream.download()
|
22 |
-
audio_parts = audio_file.split('/')[-1]
|
23 |
-
audio_title = '.'.join(audio_parts.split('.')[:-1])
|
24 |
embed_html_all = embed_html1 + id +embed_html2
|
25 |
return audio_file, audio_file, embed_html_all
|
26 |
|
|
|
11 |
embed_html1 = '<iframe width="560" height="315" src="https://www.youtube.com/embed/'
|
12 |
embed_html2 = '" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>'
|
13 |
|
14 |
+
def download_audio_(link):
|
15 |
+
with yt_dlp.YoutubeDL({'extract_audio': True, 'format': 'bestaudio', 'outtmpl': '%(title)s.mp3'}) as video:
|
16 |
+
info_dict = video.extract_info(link, download = True)
|
17 |
+
video_title = info_dict['title']
|
18 |
+
video.download(link)
|
19 |
+
return video_title
|
20 |
|
21 |
def download_audio(id_video):
|
|
|
22 |
id = id_video.split("?v=")[-1][:11]
|
23 |
+
audio_file = download_audio_(id_video)
|
24 |
+
audio_file = audio_file+'.mp3'
|
|
|
|
|
|
|
|
|
25 |
embed_html_all = embed_html1 + id +embed_html2
|
26 |
return audio_file, audio_file, embed_html_all
|
27 |
|