Browse Source

Support entries without video

main
gabriel becker 10 months ago
parent
commit
141fde05a6
  1. 9
      open_workout_coach/load_exercises.py
  2. 4
      open_workout_coach/map_yaml_to_database.py

9
open_workout_coach/load_exercises.py

@ -27,11 +27,14 @@ def load_file_and_media_links(file_path):
exercises = yaml.safe_load(file)
for ex in exercises['exercises']:
name = ex['name']
video_url = ex['video']
start = ex['start']
end = ex['end']
video_url = ex.get('video')
start = ex.get('start')
end = ex.get('end')
if video_url:
video_path = get_video(video_url)
gif = create_gif_from_video_and_timestamps(video_path, start, end)
ex['gif_path'] = gif
else:
ex['gif_path'] = None
return exercises

4
open_workout_coach/map_yaml_to_database.py

@ -18,6 +18,8 @@ def get_all_media_from_db_by_type(db, media_type):
for workout_item in session['workoutItems']:
media.append(workout_item[item_key])
media = list(set(media))
if None in media:
media.remove(None)
return media
@ -46,7 +48,7 @@ def refactor_media_paths_in_db(db):
db_name = db['name']
for session in db['workoutSessions']:
for workout_item in session['workoutItems']:
item_has_video = workout_item['videoPath'] != ''
item_has_video = workout_item['videoPath'] not in ('', None)
if item_has_video:
new_formatted_path = get_remote_formatted_media_path(
media_type='video',

Loading…
Cancel
Save