mimbres commited on
Commit
d18b082
1 Parent(s): f84a254

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -9
app.py CHANGED
@@ -77,15 +77,10 @@ def prepare_media(source_path_or_url: os.PathLike,
77
  # subprocess.run(['ffmpeg', '-i', mp4_file, '-ac', '1', audio_file])
78
  # os.remove(mp4_file)
79
  with open(log_file, 'w') as lf:
80
- # Try alternative
81
- # print(f"Failed with PyTube, error: {e}. Trying yt-dlp...")
82
  audio_file = './downloaded/yt_audio'
83
  # subprocess.run(['yt-dlp', '-x', source_path_or_url, '-f', 'bestaudio',
84
  # '-o', audio_file, '--audio-format', 'mp3', '--restrict-filenames',
85
  # '--force-overwrites', '--cookies', 'amt/src/extras/c.txt'])
86
- # subprocess.run(['yt-dlp', '-x', source_path_or_url, '-f', 'bestaudio',
87
- # '-o', audio_file, '--audio-format', 'mp3', '--restrict-filenames',
88
- # '--force-overwrites', '--cookies', 'amt/src/extras/c.txt'])
89
  command = ['yt-dlp', '-x', source_path_or_url, '-f', 'bestaudio',
90
  '-o', audio_file, '--audio-format', 'mp3', '--restrict-filenames',
91
  '--force-overwrites', '--username', 'oauth2', '--password', '', '-v']
@@ -98,8 +93,8 @@ def prepare_media(source_path_or_url: os.PathLike,
98
  # Filter out unnecessary messages
99
  if "www.google.com/device" in line:
100
  hl_text = line.replace("https://www.google.com/device", "\033[93mhttps://www.google.com/device\x1b[0m").split()
101
- hl_text[-1] = "\x1b[31;1m" + words[-1] + "\x1b[0m"
102
- lf.write(' '.join(hl_line)); lf.flush()
103
  process.stdout.close()
104
  process.wait()
105
 
@@ -141,6 +136,9 @@ def play_video(youtube_url):
141
  return None
142
  return create_html_youtube_player(youtube_url)
143
 
 
 
 
144
 
145
  AUDIO_EXAMPLES = glob.glob('examples/*.*', recursive=True)
146
  YOUTUBE_EXAMPLES = ["https://youtu.be/5vJBhdjvVcE?si=s3NFG_SlVju0Iklg",
@@ -243,8 +241,10 @@ with gr.Blocks(theme=theme, css=css) as demo:
243
  youtube_player = gr.HTML(render=True)
244
 
245
  with gr.Column(scale=4):
246
- # Submit button
247
- transcribe_video_button = gr.Button("Transcribe", variant="primary")
 
 
248
  with gr.Column(scale=1):
249
  # Transcribe
250
  output_tab2 = gr.HTML(render=True)
@@ -252,6 +252,8 @@ with gr.Blocks(theme=theme, css=css) as demo:
252
  transcribe_video_button.click(process_video, inputs=youtube_url, outputs=output_tab2)
253
  # Play
254
  play_video_button.click(play_video, inputs=youtube_url, outputs=youtube_player)
 
 
255
  with gr.Column(scale=1):
256
  Log(log_file, dark=True, xterm_font_size=12, elem_id='mylog')
257
  demo.launch(debug=True)
 
77
  # subprocess.run(['ffmpeg', '-i', mp4_file, '-ac', '1', audio_file])
78
  # os.remove(mp4_file)
79
  with open(log_file, 'w') as lf:
 
 
80
  audio_file = './downloaded/yt_audio'
81
  # subprocess.run(['yt-dlp', '-x', source_path_or_url, '-f', 'bestaudio',
82
  # '-o', audio_file, '--audio-format', 'mp3', '--restrict-filenames',
83
  # '--force-overwrites', '--cookies', 'amt/src/extras/c.txt'])
 
 
 
84
  command = ['yt-dlp', '-x', source_path_or_url, '-f', 'bestaudio',
85
  '-o', audio_file, '--audio-format', 'mp3', '--restrict-filenames',
86
  '--force-overwrites', '--username', 'oauth2', '--password', '', '-v']
 
93
  # Filter out unnecessary messages
94
  if "www.google.com/device" in line:
95
  hl_text = line.replace("https://www.google.com/device", "\033[93mhttps://www.google.com/device\x1b[0m").split()
96
+ hl_text[-1] = "\x1b[31;1m" + hl_text[-1] + "\x1b[0m"
97
+ lf.write(' '.join(hl_text)); lf.flush()
98
  process.stdout.close()
99
  process.wait()
100
 
 
136
  return None
137
  return create_html_youtube_player(youtube_url)
138
 
139
+ def oauth_google():
140
+ return create_html_oauth()
141
+
142
 
143
  AUDIO_EXAMPLES = glob.glob('examples/*.*', recursive=True)
144
  YOUTUBE_EXAMPLES = ["https://youtu.be/5vJBhdjvVcE?si=s3NFG_SlVju0Iklg",
 
241
  youtube_player = gr.HTML(render=True)
242
 
243
  with gr.Column(scale=4):
244
+ with gr.Row():
245
+ # Submit button
246
+ transcribe_video_button = gr.Button("Transcribe", variant="primary")
247
+ oauth_button = gr.Button("google.com/device", variant="primary")
248
  with gr.Column(scale=1):
249
  # Transcribe
250
  output_tab2 = gr.HTML(render=True)
 
252
  transcribe_video_button.click(process_video, inputs=youtube_url, outputs=output_tab2)
253
  # Play
254
  play_video_button.click(play_video, inputs=youtube_url, outputs=youtube_player)
255
+ # Authetification
256
+ oauth_button.click(oauth_google, outputs=youtube_player)
257
  with gr.Column(scale=1):
258
  Log(log_file, dark=True, xterm_font_size=12, elem_id='mylog')
259
  demo.launch(debug=True)