[go: nahoru, domu]

Skip to content

Commit

Permalink
Move function
Browse files Browse the repository at this point in the history
  • Loading branch information
WyattBlue committed Nov 25, 2023
1 parent d3f9f71 commit 12461cb
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 14 deletions.
17 changes: 13 additions & 4 deletions auto_editor/formats/json.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
color,
natural,
number,
src,
threshold,
)

Expand All @@ -35,11 +34,21 @@ def __init__(self, name: str, *attrs: tuple[str, Any, Any]):
self.attrs = attrs


def make_src(val: str) -> int | str:
try:
if int(val) > 0:
return int(val)
except ValueError:
pass

return val


video_builder = cAttrs(
"video",
("start", natural, Required),
("dur", natural, Required),
("src", src, Required),
("src", make_src, Required),
("offset", natural, 0),
("speed", number, 1),
("stream", natural, 0),
Expand All @@ -48,7 +57,7 @@ def __init__(self, name: str, *attrs: tuple[str, Any, Any]):
"audio",
("start", natural, Required),
("dur", natural, Required),
("src", src, Required),
("src", make_src, Required),
("offset", natural, 0),
("speed", number, 1),
("volume", threshold, 1),
Expand All @@ -58,7 +67,7 @@ def __init__(self, name: str, *attrs: tuple[str, Any, Any]):
"image",
("start", natural, Required),
("dur", natural, Required),
("src", src, Required),
("src", make_src, Required),
("x", int, "50%"),
("y", int, "50%"),
("opacity", threshold, 1),
Expand Down
3 changes: 3 additions & 0 deletions auto_editor/render/audio.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,9 @@ def make_new_audio(

for c, clip in enumerate(layer):
if f"{clip.src}-{clip.stream}" not in samples:
if clip.src not in tl.sources:
log.error(f"Unknown source: {clip.src}")

audio_path = ensure.audio(
f"{tl.sources[clip.src].path.resolve()}",
clip.src,
Expand Down
10 changes: 0 additions & 10 deletions auto_editor/utils/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,16 +84,6 @@ def speed(val: str) -> float:
return _s


def src(val: str) -> int | str:
try:
if int(val) > 0:
return int(val)
except ValueError:
pass

return val


def threshold(val: str | float) -> float:
num = number(val)
if num > 1 or num < 0:
Expand Down

0 comments on commit 12461cb

Please sign in to comment.