Spaces:
Running
Running
Lazarus
commited on
Commit
·
fe3cb9d
1
Parent(s):
2c2188f
fix: command parsing
Browse files- functions.py +16 -19
functions.py
CHANGED
@@ -69,9 +69,8 @@ class CommandBuilder:
|
|
69 |
# comp.label,
|
70 |
# comp,
|
71 |
# )
|
72 |
-
comp.
|
73 |
-
|
74 |
-
)
|
75 |
|
76 |
def reset(self):
|
77 |
self.output_dict = {"vf": {}, "af": {}}
|
@@ -115,7 +114,7 @@ class CommandBuilder:
|
|
115 |
else "".join(component_label).strip(": ").lower().split()
|
116 |
)
|
117 |
label += "".join(_).title()
|
118 |
-
key = newoutputMap.get(label)
|
119 |
lst_extra, vf, af = ([] for _ in range(3))
|
120 |
if new_value not in [None, "Source", "Auto", "", "None", "none", 0]:
|
121 |
self.set_vf(label, new_value)
|
@@ -138,7 +137,8 @@ class CommandBuilder:
|
|
138 |
self.vf = f"-vf '{vf}'" if vf else ""
|
139 |
self.af = f"-af '{af}'" if af else ""
|
140 |
self.extra = " ".join(lst_extra)
|
141 |
-
self.commands = f"{self.vf} {self.af} {self.extra}"
|
|
|
142 |
|
143 |
print(self.vf, self.af, self.extra)
|
144 |
|
@@ -158,14 +158,14 @@ class CommandBuilder:
|
|
158 |
else:
|
159 |
self.output_dict["vf"].update({key: key})
|
160 |
|
161 |
-
def set_f(self, label, new_value):
|
162 |
"""Sets Extra filters
|
163 |
Args:
|
164 |
label : label of components
|
165 |
newValue : value of component
|
166 |
"""
|
167 |
if newoutputMap.get(label):
|
168 |
-
key = newoutputMap.get(label)
|
169 |
if label in ["video", "audio"]:
|
170 |
codec_label = codecs.get(label)
|
171 |
value = (
|
@@ -179,7 +179,7 @@ class CommandBuilder:
|
|
179 |
value = "".join(
|
180 |
[
|
181 |
i.get("value", "None")
|
182 |
-
for i in data.get(label)
|
183 |
if i.get("name", None) == new_value
|
184 |
]
|
185 |
)
|
@@ -200,11 +200,10 @@ class CommandBuilder:
|
|
200 |
for comp in self._component:
|
201 |
# print(comp, "comp")
|
202 |
comp.change(
|
203 |
-
lambda: gr.
|
204 |
[],
|
205 |
[component],
|
206 |
-
|
207 |
-
)
|
208 |
|
209 |
def _get_component_instance(self, inputs: gr.Row | gr.Column) -> List[Component]:
|
210 |
"""
|
@@ -228,7 +227,8 @@ class CommandBuilder:
|
|
228 |
# print(gr.components.get_component_instance(i, render=True))
|
229 |
res += [gr.components.get_component_instance(i, render=True)]
|
230 |
# print(res)
|
231 |
-
elif hasattr(i, "children"):
|
|
|
232 |
# if isinstance(i, gr.Blocks):
|
233 |
res += self._get_component_instance(i)
|
234 |
# print(res)
|
@@ -508,10 +508,10 @@ def change_clipbox(choice: str) -> List[Component]:
|
|
508 |
]
|
509 |
|
510 |
|
511 |
-
def updateOutput(file: _TemporaryFileWrapper) -> Component:
|
512 |
-
|
513 |
-
|
514 |
-
|
515 |
|
516 |
|
517 |
def get_component_instance(inputs: gr.Blocks) -> List[Component]:
|
@@ -537,9 +537,6 @@ class Clear(CommandBuilder):
|
|
537 |
def __str__(self):
|
538 |
return f"{self._component} __clear__ class"
|
539 |
|
540 |
-
def __repr__(self):
|
541 |
-
return self._component
|
542 |
-
|
543 |
def __init__(self, *input_component: gr.Row | gr.Column) -> None:
|
544 |
"""
|
545 |
Parameters:
|
|
|
69 |
# comp.label,
|
70 |
# comp,
|
71 |
# )
|
72 |
+
state = gr.State(value=comp.label)
|
73 |
+
comp.change(fn=self.changefunc, inputs=[state, comp], outputs=[])
|
|
|
74 |
|
75 |
def reset(self):
|
76 |
self.output_dict = {"vf": {}, "af": {}}
|
|
|
114 |
else "".join(component_label).strip(": ").lower().split()
|
115 |
)
|
116 |
label += "".join(_).title()
|
117 |
+
key = newoutputMap.get(label, "")
|
118 |
lst_extra, vf, af = ([] for _ in range(3))
|
119 |
if new_value not in [None, "Source", "Auto", "", "None", "none", 0]:
|
120 |
self.set_vf(label, new_value)
|
|
|
137 |
self.vf = f"-vf '{vf}'" if vf else ""
|
138 |
self.af = f"-af '{af}'" if af else ""
|
139 |
self.extra = " ".join(lst_extra)
|
140 |
+
self.commands = " ".join(f"{self.vf} {self.af} {self.extra}".strip().split())
|
141 |
+
# self.commands = " ".join(filter(None, [self.vf, self.af, self.extra]))
|
142 |
|
143 |
print(self.vf, self.af, self.extra)
|
144 |
|
|
|
158 |
else:
|
159 |
self.output_dict["vf"].update({key: key})
|
160 |
|
161 |
+
def set_f(self, label: str, new_value: "str| int"):
|
162 |
"""Sets Extra filters
|
163 |
Args:
|
164 |
label : label of components
|
165 |
newValue : value of component
|
166 |
"""
|
167 |
if newoutputMap.get(label):
|
168 |
+
key = newoutputMap.get(label, "")
|
169 |
if label in ["video", "audio"]:
|
170 |
codec_label = codecs.get(label)
|
171 |
value = (
|
|
|
179 |
value = "".join(
|
180 |
[
|
181 |
i.get("value", "None")
|
182 |
+
for i in data.get(label, [])
|
183 |
if i.get("name", None) == new_value
|
184 |
]
|
185 |
)
|
|
|
200 |
for comp in self._component:
|
201 |
# print(comp, "comp")
|
202 |
comp.change(
|
203 |
+
lambda: gr.update(value=f"$ {self.commands}"),
|
204 |
[],
|
205 |
[component],
|
206 |
+
).then(lambda: gr.update(value=f"$ {self.commands}"), [], [component])
|
|
|
207 |
|
208 |
def _get_component_instance(self, inputs: gr.Row | gr.Column) -> List[Component]:
|
209 |
"""
|
|
|
227 |
# print(gr.components.get_component_instance(i, render=True))
|
228 |
res += [gr.components.get_component_instance(i, render=True)]
|
229 |
# print(res)
|
230 |
+
# elif hasattr(i, "children"):
|
231 |
+
else:
|
232 |
# if isinstance(i, gr.Blocks):
|
233 |
res += self._get_component_instance(i)
|
234 |
# print(res)
|
|
|
508 |
]
|
509 |
|
510 |
|
511 |
+
# def updateOutput(file: _TemporaryFileWrapper) -> Component:
|
512 |
+
# if file:
|
513 |
+
# print(file.name)
|
514 |
+
# return gr.update(value=file.name)
|
515 |
|
516 |
|
517 |
def get_component_instance(inputs: gr.Blocks) -> List[Component]:
|
|
|
537 |
def __str__(self):
|
538 |
return f"{self._component} __clear__ class"
|
539 |
|
|
|
|
|
|
|
540 |
def __init__(self, *input_component: gr.Row | gr.Column) -> None:
|
541 |
"""
|
542 |
Parameters:
|