Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -35,7 +35,7 @@ def get_concat_v_cut(in1, in2):
|
|
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
-
def run_script(url: str, height: int, width: int, check_b):
|
| 39 |
mes_box=[]
|
| 40 |
out_box=[]
|
| 41 |
uid=uuid.uuid4()
|
|
@@ -64,18 +64,22 @@ def run_script(url: str, height: int, width: int, check_b):
|
|
| 64 |
messages = driver.find_elements(By.CLASS_NAME, "message")
|
| 65 |
print (len(messages))
|
| 66 |
mes_blocks=len(messages)%2
|
| 67 |
-
|
| 68 |
-
|
| 69 |
ea = int(ea)
|
| 70 |
ea = (ea*2)-2
|
| 71 |
print (ea)
|
| 72 |
messages[ea].screenshot(f'{ea}-{uid}-tmp.png')
|
| 73 |
messages[ea+1].screenshot(f'{ea+1}-{uid}-tmp.png')
|
| 74 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 75 |
print(f'out_box:: {out_box}')
|
| 76 |
#mes_box.clear()
|
| 77 |
-
|
| 78 |
-
|
| 79 |
'''
|
| 80 |
for i,mes in enumerate(messages):
|
| 81 |
print (mes.text)
|
|
@@ -128,8 +132,9 @@ with gr.Blocks() as app:
|
|
| 128 |
btn= gr.Button()
|
| 129 |
|
| 130 |
with gr.Column():
|
|
|
|
|
|
|
| 131 |
with gr.Row():
|
| 132 |
-
check_b=gr.CheckboxGroup(label="Chatblocks", choices=[1,2,3,4,5,6,7,8,9,10])
|
| 133 |
height=gr.Number(label="Height", value=4096)
|
| 134 |
width=gr.Number(label="Width",value=800)
|
| 135 |
message=gr.HTML('<center>Enter URL')
|
|
@@ -138,5 +143,5 @@ with gr.Blocks() as app:
|
|
| 138 |
outgal=gr.Gallery()
|
| 139 |
outim = gr.Image()
|
| 140 |
|
| 141 |
-
btn.click(run_script,[inp,height,width,check_b],[outim,message,outgal])
|
| 142 |
app.launch()
|
|
|
|
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
+
def run_script(url: str, height: int, width: int, check_b,check_h):
|
| 39 |
mes_box=[]
|
| 40 |
out_box=[]
|
| 41 |
uid=uuid.uuid4()
|
|
|
|
| 64 |
messages = driver.find_elements(By.CLASS_NAME, "message")
|
| 65 |
print (len(messages))
|
| 66 |
mes_blocks=len(messages)%2
|
| 67 |
+
for ea in check_b:
|
| 68 |
+
try:
|
| 69 |
ea = int(ea)
|
| 70 |
ea = (ea*2)-2
|
| 71 |
print (ea)
|
| 72 |
messages[ea].screenshot(f'{ea}-{uid}-tmp.png')
|
| 73 |
messages[ea+1].screenshot(f'{ea+1}-{uid}-tmp.png')
|
| 74 |
+
if check_h:
|
| 75 |
+
head_paste = get_concat_v_cut(f'head-{uid}-tmp.png',f'{ea}-{uid}-tmp.png'))
|
| 76 |
+
out_box.append(get_concat_v_cut(head_paste,f'{ea+1}-{uid}-tmp.png'))
|
| 77 |
+
if not check_h:
|
| 78 |
+
out_box.append(get_concat_v_cut(f'{ea}-{uid}-tmp.png',f'{ea+1}-{uid}-tmp.png'))
|
| 79 |
print(f'out_box:: {out_box}')
|
| 80 |
#mes_box.clear()
|
| 81 |
+
except Exception:
|
| 82 |
+
mes="<center>Some blocks returned an error"
|
| 83 |
'''
|
| 84 |
for i,mes in enumerate(messages):
|
| 85 |
print (mes.text)
|
|
|
|
| 132 |
btn= gr.Button()
|
| 133 |
|
| 134 |
with gr.Column():
|
| 135 |
+
check_h=gr.Checkbox(label="Show Header", value=True)
|
| 136 |
+
check_b=gr.CheckboxGroup(label="Chatblocks", choices=[1,2,3,4,5,6,7,8,9,10], value=[1])
|
| 137 |
with gr.Row():
|
|
|
|
| 138 |
height=gr.Number(label="Height", value=4096)
|
| 139 |
width=gr.Number(label="Width",value=800)
|
| 140 |
message=gr.HTML('<center>Enter URL')
|
|
|
|
| 143 |
outgal=gr.Gallery()
|
| 144 |
outim = gr.Image()
|
| 145 |
|
| 146 |
+
btn.click(run_script,[inp,height,width,check_b,check_h],[outim,message,outgal])
|
| 147 |
app.launch()
|