Support entries without video
This commit is contained in:
parent
15ecdfc658
commit
141fde05a6
@ -27,11 +27,14 @@ def load_file_and_media_links(file_path):
|
|||||||
exercises = yaml.safe_load(file)
|
exercises = yaml.safe_load(file)
|
||||||
for ex in exercises['exercises']:
|
for ex in exercises['exercises']:
|
||||||
name = ex['name']
|
name = ex['name']
|
||||||
video_url = ex['video']
|
video_url = ex.get('video')
|
||||||
start = ex['start']
|
start = ex.get('start')
|
||||||
end = ex['end']
|
end = ex.get('end')
|
||||||
video_path = get_video(video_url)
|
if video_url:
|
||||||
gif = create_gif_from_video_and_timestamps(video_path, start, end)
|
video_path = get_video(video_url)
|
||||||
ex['gif_path'] = gif
|
gif = create_gif_from_video_and_timestamps(video_path, start, end)
|
||||||
|
ex['gif_path'] = gif
|
||||||
|
else:
|
||||||
|
ex['gif_path'] = None
|
||||||
|
|
||||||
return exercises
|
return exercises
|
||||||
|
@ -18,6 +18,8 @@ def get_all_media_from_db_by_type(db, media_type):
|
|||||||
for workout_item in session['workoutItems']:
|
for workout_item in session['workoutItems']:
|
||||||
media.append(workout_item[item_key])
|
media.append(workout_item[item_key])
|
||||||
media = list(set(media))
|
media = list(set(media))
|
||||||
|
if None in media:
|
||||||
|
media.remove(None)
|
||||||
return media
|
return media
|
||||||
|
|
||||||
|
|
||||||
@ -46,7 +48,7 @@ def refactor_media_paths_in_db(db):
|
|||||||
db_name = db['name']
|
db_name = db['name']
|
||||||
for session in db['workoutSessions']:
|
for session in db['workoutSessions']:
|
||||||
for workout_item in session['workoutItems']:
|
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:
|
if item_has_video:
|
||||||
new_formatted_path = get_remote_formatted_media_path(
|
new_formatted_path = get_remote_formatted_media_path(
|
||||||
media_type='video',
|
media_type='video',
|
||||||
|
Loading…
x
Reference in New Issue
Block a user