Spaces:
Runtime error
Runtime error
File size: 2,280 Bytes
7f88dd7 b4d7fed 11a28b8 56afb5e e793092 6957020 e793092 7f88dd7 46fd8e8 e793092 34d9197 a0ef9d6 8690dda f4858c1 34d9197 2a7ed74 19fa55a 8690dda 77889fa b187599 8690dda 56afb5e fde2ec3 84a96b1 fde2ec3 d64e162 e25c521 d14169a b187599 34d9197 6ef6ed7 34d9197 77889fa 7f88dd7 2a7ed74 3cf9cd9 e793092 77889fa 3cf9cd9 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 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
import gradio as gr
import yt_dlp
import os
import binascii
import json
def dl_user(inp):
out_json={}
os.system(f'yt-dlp "{inp}" --write-info-json --skip-download --cookies-from-browser chrome -o "{inp_out}"')
try:
with open(f"{inp_out}.info.json", "r") as f:
f_out = f.read()
print(f_out)
json_object = json.loads(f_out)
out_json = json.dumps(json_object, indent=4)
print (out_json)
except Exception as e:
print (e)
return out_json
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.read()
print(f_out)
#for line in f_out:
# print (line)
# json_line.append(line)
#dec_line = line.decode('utf-8', 'backslashreplace')
#out_line = binascii.hexlify(eval(dec_line))
#print (out_line)
json_object = json.loads(f_out)
out_json = json.dumps(json_object, indent=4)
print (out_json)
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()
with gr.Row():
#btn=gr.Button("Search")
go_btn = gr.Button("Run")
with gr.Row():
with gr.Column():
outp_vid=gr.Video()
with gr.Column():
outp_files=gr.Files()
out_json = gr.JSON()
#btn.click(dl,inp_url,out_json)
go_btn.click(dl,inp_url,[outp_vid,outp_files,out_json])
app.launch()
|