Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -2,8 +2,22 @@ import gradio as gr
|
|
2 |
import yt_dlp
|
3 |
import os
|
4 |
import json
|
5 |
-
|
6 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
7 |
|
8 |
def dl(inp):
|
9 |
out = None
|
@@ -25,7 +39,7 @@ def dl(inp):
|
|
25 |
out = None
|
26 |
return out
|
27 |
|
28 |
-
with gr.Blocks() as
|
29 |
inp_url = gr.Textbox()
|
30 |
go_btn = gr.Button("Run")
|
31 |
with gr.Row():
|
@@ -33,6 +47,9 @@ with gr.Blocks() as appy:
|
|
33 |
outp_vid=gr.Video()
|
34 |
with gr.Column():
|
35 |
outp_file=gr.Textbox()
|
|
|
|
|
|
|
36 |
go_btn.click(dl,inp_url,outp_file)
|
37 |
-
|
38 |
-
|
|
|
2 |
import yt_dlp
|
3 |
import os
|
4 |
import json
|
5 |
+
load_js = """
|
6 |
+
function(text_input, url_params) {
|
7 |
+
console.log(text_input, url_params);
|
8 |
+
const params = new URLSearchParams(window.location.search);
|
9 |
+
url_params = Object.fromEntries(params);
|
10 |
+
return [text_input, url_params]
|
11 |
+
}
|
12 |
+
"""
|
13 |
+
def predict(text, url_params):
|
14 |
+
mod_url=""
|
15 |
+
mod=gr.HTML("")
|
16 |
+
out = None
|
17 |
+
valid=gr.update(visible=False)
|
18 |
+
mod_url = url_params.get('url')
|
19 |
+
print (mod_url)
|
20 |
+
return ["" + text + "", mod_url]
|
21 |
|
22 |
def dl(inp):
|
23 |
out = None
|
|
|
39 |
out = None
|
40 |
return out
|
41 |
|
42 |
+
with gr.Blocks() as app:
|
43 |
inp_url = gr.Textbox()
|
44 |
go_btn = gr.Button("Run")
|
45 |
with gr.Row():
|
|
|
47 |
outp_vid=gr.Video()
|
48 |
with gr.Column():
|
49 |
outp_file=gr.Textbox()
|
50 |
+
with gr.Row(visible=False):
|
51 |
+
text_input=gr.Textbox()
|
52 |
+
text_output=gr.Textbox()
|
53 |
go_btn.click(dl,inp_url,outp_file)
|
54 |
+
app.load(fn=predict, inputs=[text_input,url_params], outputs=[text_output,text_input],_js=load_js)
|
55 |
+
app.launch()
|