Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -3,10 +3,24 @@ import yt_dlp
|
|
3 |
import os
|
4 |
import binascii
|
5 |
import json
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
6 |
def dl(inp):
|
7 |
out = None
|
8 |
out_file=[]
|
9 |
-
|
10 |
try:
|
11 |
inp_out=inp.replace("https://","")
|
12 |
inp_out=inp_out.replace("/","_").replace(".","_")
|
@@ -43,12 +57,17 @@ def dl(inp):
|
|
43 |
|
44 |
with gr.Blocks() as app:
|
45 |
inp_url = gr.Textbox()
|
46 |
-
go_btn = gr.Button()
|
47 |
with gr.Row():
|
48 |
-
|
|
|
|
|
|
|
|
|
|
|
49 |
with gr.Column():
|
50 |
outp_files=gr.Files()
|
51 |
out_json = gr.JSON()
|
|
|
52 |
go_btn.click(dl,inp_url,[outp_vid,outp_files,out_json])
|
53 |
|
54 |
app.launch()
|
|
|
3 |
import os
|
4 |
import binascii
|
5 |
import json
|
6 |
+
|
7 |
+
def dl_user(inp):
|
8 |
+
out_json={}
|
9 |
+
os.system(f'yt-dlp "{inp}" --write-info-json --skip-download -o "{inp_out}"')
|
10 |
+
try:
|
11 |
+
with open(f"{inp_out}.info.json", "r") as f:
|
12 |
+
f_out = f.read()
|
13 |
+
print(f_out)
|
14 |
+
json_object = json.loads(f_out)
|
15 |
+
out_json = json.dumps(json_object, indent=4)
|
16 |
+
print (out_json)
|
17 |
+
except Exception as e:
|
18 |
+
print (e)
|
19 |
+
return out_json
|
20 |
def dl(inp):
|
21 |
out = None
|
22 |
out_file=[]
|
23 |
+
out_json={}
|
24 |
try:
|
25 |
inp_out=inp.replace("https://","")
|
26 |
inp_out=inp_out.replace("/","_").replace(".","_")
|
|
|
57 |
|
58 |
with gr.Blocks() as app:
|
59 |
inp_url = gr.Textbox()
|
|
|
60 |
with gr.Row():
|
61 |
+
btn=gr.Button("Search")
|
62 |
+
go_btn = gr.Button("Run")
|
63 |
+
|
64 |
+
with gr.Row():
|
65 |
+
with gr.Column():
|
66 |
+
outp_vid=gr.Video()
|
67 |
with gr.Column():
|
68 |
outp_files=gr.Files()
|
69 |
out_json = gr.JSON()
|
70 |
+
btn.click(dl,inp_url,out_json)
|
71 |
go_btn.click(dl,inp_url,[outp_vid,outp_files,out_json])
|
72 |
|
73 |
app.launch()
|