Created
June 19, 2023 09:33
This Python script sets all videos in ProShow Producer to "Lock slide time to video length" mode
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import re | |
from pathlib import Path | |
project_path = input('Please paste path to the ProShow Producer project:\n') | |
with open(project_path) as file: | |
lines = [line.rstrip() for line in file] | |
project_text = '\n'.join(lines) | |
cell_re = r"cell\[(\d+)]\.images\[0]\.isVideo=1" | |
cell_matches = re.findall(cell_re, project_text, re.MULTILINE) | |
for match in cell_matches: | |
match: re.Match | |
video_name = None | |
for line in lines: | |
video_name = re.match(rf"cell\[{match}]\.images\[0]\.image=(.*?)$", line, re.MULTILINE) | |
if video_name is not None: break | |
if video_name: | |
print(f'Found video {video_name.group(1)} on {match}') | |
if not any(filter(lambda x: x.startswith(f"cell[{match}].images[0].videoTimeLocked=1"), lines)): | |
for i in range(len(lines)): | |
if lines[i].startswith(f'cell[{match}].images[0].videoVolume'): | |
lines.insert(i + 1, f'cell[{match}].images[0].videoTimeLocked=1') | |
print(f'Set {match} video to auto length!') | |
break | |
else: | |
print(f'{match} video length is already auto length!') | |
else: | |
print(f'Error for {match}') | |
p = Path(project_path) | |
for i in range(1, 1000): | |
try: | |
p.rename(Path(p.parent, f"{p.stem}_orig ({i}){p.suffix}")) | |
break | |
except FileExistsError: | |
pass | |
print(str(p)) | |
with open(project_path, 'w') as file: | |
file.write('\n'.join(lines)) | |
print(f'Saved to "{project_path}"!') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment