Ubuntu commited on
Commit
162a7ae
·
1 Parent(s): 02b5df3

update lgic for id

Browse files
Files changed (1) hide show
  1. app.py +3 -1
app.py CHANGED
@@ -15,7 +15,7 @@ def download_youtube_audio(url: str, output_dir: Optional[str] = None) -> str:
15
  output_dir = tempfile.gettempdir()
16
 
17
  yt_dlp_command = [
18
- "/home/ubuntu/miniconda3/envs/gradio_whisper/bin/yt-dlp",
19
  "-f", "bestaudio/best",
20
  "-x", # Extract audio
21
  "--audio-format", "mp3",
@@ -80,6 +80,8 @@ def embed_youtube(youtube_url):
80
  try:
81
  #video_id = YoutubeDL().extract_info(youtube_url, download=False)['id']\
82
  video_id = youtube_url.split("v=")[1]
 
 
83
  print(video_id)
84
  embed_html = f'<iframe width="560" height="315" src="https://www.youtube.com/embed/{video_id}" frameborder="0" allow="autoplay; encrypted-media" allowfullscreen></iframe>'
85
  return gr.update(value=embed_html, visible=True), "", None
 
15
  output_dir = tempfile.gettempdir()
16
 
17
  yt_dlp_command = [
18
+ "yt-dlp",
19
  "-f", "bestaudio/best",
20
  "-x", # Extract audio
21
  "--audio-format", "mp3",
 
80
  try:
81
  #video_id = YoutubeDL().extract_info(youtube_url, download=False)['id']\
82
  video_id = youtube_url.split("v=")[1]
83
+ if 'shorts' in youtube_url:
84
+ video_id = youtube_url.split('/')[-1]
85
  print(video_id)
86
  embed_html = f'<iframe width="560" height="315" src="https://www.youtube.com/embed/{video_id}" frameborder="0" allow="autoplay; encrypted-media" allowfullscreen></iframe>'
87
  return gr.update(value=embed_html, visible=True), "", None