Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -120,9 +120,16 @@ def move_segment(segments, old_index, new_index):
|
|
| 120 |
def parse_segments(segments: pd.DataFrame) -> List[Tuple[int, int]]:
|
| 121 |
parsed_segments = []
|
| 122 |
for segment in segments['Segment']:
|
| 123 |
-
|
| 124 |
-
|
| 125 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 126 |
return parsed_segments
|
| 127 |
|
| 128 |
def process_video(video_url, segments, combine, progress=gr.Progress()):
|
|
|
|
| 120 |
def parse_segments(segments: pd.DataFrame) -> List[Tuple[int, int]]:
|
| 121 |
parsed_segments = []
|
| 122 |
for segment in segments['Segment']:
|
| 123 |
+
if not isinstance(segment, str) or '-' not in segment:
|
| 124 |
+
continue
|
| 125 |
+
try:
|
| 126 |
+
start, end = segment.split('-')
|
| 127 |
+
start_seconds = sum(int(i) * 60 ** j for j, i in enumerate(reversed(start.split(':'))) if i)
|
| 128 |
+
end_seconds = sum(int(i) * 60 ** j for j, i in enumerate(reversed(end.split(':'))) if i)
|
| 129 |
+
if start_seconds < end_seconds:
|
| 130 |
+
parsed_segments.append((start_seconds, end_seconds))
|
| 131 |
+
except ValueError:
|
| 132 |
+
continue # Skip invalid segments
|
| 133 |
return parsed_segments
|
| 134 |
|
| 135 |
def process_video(video_url, segments, combine, progress=gr.Progress()):
|