Spaces:
Runtime error
Runtime error
File size: 1,483 Bytes
7f88dd7 b4d7fed 11a28b8 7f88dd7 46fd8e8 77889fa 34d9197 a0ef9d6 8690dda f4858c1 34d9197 2a7ed74 19fa55a 8690dda 77889fa b187599 8690dda b187599 7731a3a d64e162 b187599 34d9197 6ef6ed7 34d9197 77889fa 7f88dd7 2a7ed74 77889fa 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 46 47 48 |
import gradio as gr
import yt_dlp
import os
import binascii
def dl(inp):
out = None
out_file=[]
out_json={}
try:
inp_out=inp.replace("https://","")
inp_out=inp_out.replace("/","_").replace(".","_")
os.system(f'yt-dlp "{inp}" --write-description --skip-download -o "{inp_out}"')
os.system(f'yt-dlp "{inp}" --write-info-json --skip-download -o "{inp_out}"')
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")
out_json=f'{inp_out}.info.json'
try:
with open(f"{inp_out}.info.json", "r") 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,out_json
with gr.Blocks() as app:
inp_url = gr.Textbox()
go_btn = gr.Button()
with gr.Row():
outp_vid=gr.Video()
with gr.Column():
outp_files=gr.Files()
out_json = gr.JSON()
go_btn.click(dl,inp_url,[outp_vid,outp_files,out_json])
app.launch()
|