in generate_side_by_side.py [0:0]
def find_videos(artifact_dir, original=False):
# Find the cold/warm browsertime.json files
cold_path = ""
warm_path = ""
for path in pathlib.Path(artifact_dir).rglob("*-browsertime.json"):
if "cold" in str(path):
cold_path = path
elif "warm" in str(path):
warm_path = path
if not cold_path:
raise Exception("Cannot find a browsertime.json file for the cold pageloads.")
if not warm_path:
raise Exception("Cannot find a browsertime.json file for the warm pageloads.")
with cold_path.open() as f:
cold_data = json.load(f)
with warm_path.open() as f:
warm_data = json.load(f)
return {
"cold": [
str(pathlib.Path(cold_path.parents[0], file)).replace(
".mp4", "-original.mp4"
)
if original
else str(pathlib.Path(cold_path.parents[0], file))
for file in cold_data[0]["files"]["video"]
],
"warm": [
str(pathlib.Path(warm_path.parents[0], file)).replace(
".mp4", "-original.mp4"
)
if original
else str(pathlib.Path(warm_path.parents[0], file))
for file in warm_data[0]["files"]["video"]
],
}