Extract prompt from video filename by removing extensions and special characters Args: filename: Video filename Returns: Extracted prompt string
(filename: str)
| 6 | |
| 7 | |
| 8 | def get_prompt_from_filename(filename: str) -> str: |
| 9 | """ |
| 10 | Extract prompt from video filename by removing extensions and special characters |
| 11 | |
| 12 | Args: |
| 13 | filename: Video filename |
| 14 | |
| 15 | Returns: |
| 16 | Extracted prompt string |
| 17 | """ |
| 18 | # Remove file extension |
| 19 | name = Path(filename).stem |
| 20 | |
| 21 | # Remove common suffixes like "-0", "-1", etc. |
| 22 | name = re.sub(r'-\d+$', '', name) |
| 23 | |
| 24 | # Replace underscores and hyphens with spaces |
| 25 | name = re.sub(r'[_-]', ' ', name) |
| 26 | |
| 27 | # Clean up multiple spaces |
| 28 | name = re.sub(r'\s+', ' ', name).strip() |
| 29 | |
| 30 | return name.lower() |
| 31 | |
| 32 | |
| 33 | def save_json(data: Union[Dict, List], filepath: str) -> None: |
nothing calls this directly
no outgoing calls
no test coverage detected