maryna7679 commited on
Commit
0b014ac
·
1 Parent(s): d94db10
Files changed (2) hide show
  1. Functions/temp.py +13 -0
  2. app.py +4 -3
Functions/temp.py ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import urllib
2
+
3
+
4
+ def youtube_link_to_id(link):
5
+ try:
6
+ from urllib.parse import urlparse, parse_qs
7
+ parsed = urlparse(link)
8
+ return parse_qs(parsed.query)['v'][0]
9
+ except (KeyError, IndexError):
10
+ raise ValueError(f"Invalid YouTube URL: {link}")
11
+
12
+
13
+ print(youtube_link_to_id("https://www.youtube.com/watch?v=tkMg8g8vVUo&ab_channel=ASLTHAT"))
app.py CHANGED
@@ -121,8 +121,6 @@ with gr.Blocks(css=css, head=yt_init_js) as main_page:
121
  current_captions_full = gr.DataFrame(value=start_captions_full, visible=False, interactive=False)
122
  selected_row_idx = gr.Number(value=-1, visible=False)
123
 
124
- main_page.load(get_username, outputs=current_user) # Disabled when auth is disabled
125
-
126
  # @gr.render(inputs=current_user)
127
  # def render_page(logged_in_user):
128
  # if logged_in_user is None:
@@ -203,7 +201,8 @@ with gr.Blocks(css=css, head=yt_init_js) as main_page:
203
  # Handle save entry
204
  save_entry_button.click(
205
  fn=save_entry,
206
- inputs=[caption_editor, start_time_input, text_input, end_time_input, selected_row_idx, current_video_id, current_captions_full],
 
207
  outputs=[caption_editor, editing_panel, save_result]
208
  )
209
 
@@ -235,4 +234,6 @@ with gr.Blocks(css=css, head=yt_init_js) as main_page:
235
  }"""
236
  )
237
 
 
 
238
  main_page.launch(share=True, ssr_mode=False)
 
121
  current_captions_full = gr.DataFrame(value=start_captions_full, visible=False, interactive=False)
122
  selected_row_idx = gr.Number(value=-1, visible=False)
123
 
 
 
124
  # @gr.render(inputs=current_user)
125
  # def render_page(logged_in_user):
126
  # if logged_in_user is None:
 
201
  # Handle save entry
202
  save_entry_button.click(
203
  fn=save_entry,
204
+ inputs=[caption_editor, start_time_input, text_input, end_time_input,
205
+ selected_row_idx, current_video_id, current_captions_full],
206
  outputs=[caption_editor, editing_panel, save_result]
207
  )
208
 
 
234
  }"""
235
  )
236
 
237
+ main_page.load(get_username, outputs=current_user) # Disabled when auth is disabled
238
+
239
  main_page.launch(share=True, ssr_mode=False)