Spaces:
Sleeping
Sleeping
Commit
·
69eed8c
1
Parent(s):
0f9ca51
Update app.py
Browse files
app.py
CHANGED
@@ -3,7 +3,7 @@ import time
|
|
3 |
import json
|
4 |
import os
|
5 |
import gradio as gr
|
6 |
-
|
7 |
|
8 |
YT_embed_html1 = '<iframe width="560" height="315" src="https://www.youtube.com/embed/'
|
9 |
YT_embed_html2 = '" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>'
|
@@ -14,17 +14,18 @@ SIMBALS_MAIN_DATABASE = 2
|
|
14 |
embed_html1 = '<iframe src="https://open.spotify.com/embed/track/'
|
15 |
embed_html2 = '" width="300" height="380" frameborder="0" allowtransparency="true" allow="encrypted-media"></iframe>'
|
16 |
|
|
|
|
|
|
|
|
|
|
|
|
|
17 |
|
18 |
def download_audio(id_video):
|
19 |
-
video = YouTube(id_video,use_oauth=True, allow_oauth_cache=True)
|
20 |
id = id_video.split("?v=")[-1][:11]
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
audio_file = audio_stream.download()
|
25 |
-
audio_parts = audio_file.split('/')[-1]
|
26 |
-
audio_title = '.'.join(audio_parts.split('.')[:-1])
|
27 |
-
embed_html_all = YT_embed_html1 + id + YT_embed_html2
|
28 |
return audio_file, audio_file, embed_html_all
|
29 |
|
30 |
def process_url(input_path):
|
|
|
3 |
import json
|
4 |
import os
|
5 |
import gradio as gr
|
6 |
+
import yt_dlp
|
7 |
|
8 |
YT_embed_html1 = '<iframe width="560" height="315" src="https://www.youtube.com/embed/'
|
9 |
YT_embed_html2 = '" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>'
|
|
|
14 |
embed_html1 = '<iframe src="https://open.spotify.com/embed/track/'
|
15 |
embed_html2 = '" width="300" height="380" frameborder="0" allowtransparency="true" allow="encrypted-media"></iframe>'
|
16 |
|
17 |
+
def download_audio_(link):
|
18 |
+
with yt_dlp.YoutubeDL({'extract_audio': True, 'format': 'bestaudio', 'outtmpl': '%(title)s.mp3'}) as video:
|
19 |
+
info_dict = video.extract_info(link, download = True)
|
20 |
+
video_title = info_dict['title']
|
21 |
+
video.download(link)
|
22 |
+
return video_title
|
23 |
|
24 |
def download_audio(id_video):
|
|
|
25 |
id = id_video.split("?v=")[-1][:11]
|
26 |
+
audio_file = download_audio_(id_video)
|
27 |
+
audio_file = audio_file+'.mp3'
|
28 |
+
embed_html_all = embed_html1 + id +embed_html2
|
|
|
|
|
|
|
|
|
29 |
return audio_file, audio_file, embed_html_all
|
30 |
|
31 |
def process_url(input_path):
|