File size: 1,386 Bytes
7f88dd7
b4d7fed
 
11a28b8
7f88dd7
 
46fd8e8
34d9197
 
 
f4858c1
cffef39
f4858c1
 
34d9197
2a7ed74
19fa55a
cffef39
2a7ed74
b187599
11a28b8
b187599
7731a3a
11a28b8
 
7783c55
11a28b8
b187599
 
34d9197
6ef6ed7
34d9197
46fd8e8
7f88dd7
 
 
 
 
2a7ed74
 
 
 
7f88dd7
 
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
40
41
42
43
44
45
import gradio as gr 
import yt_dlp
import os 
import binascii
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 --write-description -o "{inp_out}.description"')  
        os.system(f'yt-dlp "{inp}" --trim-filenames 100 --write-info-json -o "{inp_out}.info.json"')  

        os.system(f'yt-dlp "{inp}" --trim-filenames 100 -o "{inp_out}.mp4"')  
        out = f"{inp_out}.mp4"
        out_file.append(out)
        out_file.append(f"{inp_out}.description")
        out_file.append(f"{inp_out}.info.json")
        
        try:
            with open(f"{inp_out}.info.json", "rb") as f:
                f_out = f.readlines()
                for line in f_out:
                    #print (line)
                    dec_line = line.decode('utf-8', 'backslashreplace')
                    out_line = binascii.hexlify(eval(dec_line))
                    print (out_line)
        except Exception as e:
            print (e)
    except Exception as e:
        print (e)
        out = None
    return out,out_file


with gr.Blocks() as app:
    inp_url = gr.Textbox()
    go_btn = gr.Button()
    with gr.Row():
        outp_vid=gr.Video()
        outp_files=gr.Files()
    go_btn.click(dl,inp_url,[outp_vid,outp_files])

app.launch()