File size: 1,105 Bytes
7f88dd7
b4d7fed
 
56afb5e
a3a5434
5c2867b
e793092
7f88dd7
 
46fd8e8
34d9197
 
 
c173614
34d9197
b187599
8690dda
fde2ec3
e25c521
 
b187599
 
34d9197
6ef6ed7
34d9197
05af1d5
7f88dd7
a3a5434
7f88dd7
0078576
e793092
 
 
77889fa
c173614
 
f361bcf
a3a5434
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import gradio as gr 
import yt_dlp
import os 
import json
import params
#params.app.load()

def dl(inp):
    out = None
    out_file=[]
    try:
        inp_out=inp.replace("https://","")
        inp_out=inp_out.replace("/","_").replace(".","_")
        os.system(f'yt-dlp "{inp}" --trim-filenames 100 -o "{inp_out}.mp4"')  
        out = f"{inp_out}.mp4"
        try:
            with open(f"{inp_out}.info.json", "r") as f:
                f_out = f.read()
            json_object = json.loads(f_out)
            out_json = json.dumps(json_object, indent=4)
        except Exception as e:
            print (e)
    except Exception as e:
        print (e)
        out = None
    return out

with gr.Blocks() as appy:
    inp_url = gr.Textbox()
    go_btn = gr.Button("Run")
    with gr.Row():
        with gr.Column():
            outp_vid=gr.Video()
        with gr.Column():
            outp_file=gr.Textbox()
    go_btn.click(dl,inp_url,outp_file)
    appy.load(fn=params.predict, inputs=[params.text_input,params.url_params], outputs=[params.text_output,outp_file],_js=params.load_js)
appy.launch()