Self hosted FLOSS fitness/workout, nutrition and weight tracker
Some improvements to the video handling of the read-exercise-cleanup.py script
Roland Geidera55da880be4d
diff --git a/wger/exercises/management/commands/read-exercise-cleanup.py b/wger/exercises/management/commands/read-exercise-cleanup.pyindex 653cae3b4..fb4945177 100644--- a/wger/exercises/management/commands/read-exercise-cleanup.py+++ b/wger/exercises/management/commands/read-exercise-cleanup.py@@ -42,7 +42,7 @@ from wger.utils.constants import DEFAULT_LICENSE_IDUUID_NEW = 'NEW'VIDEO_AUTHOR = 'Goulart'VIDEO_PATH = pathlib.Path('videos-tmp')-VIDEO_EXTENSION = '.webm'+VIDEO_EXTENSIONS = ('.MP4', '.MOV')class Command(BaseCommand):@@ -156,18 +156,26 @@ class Command(BaseCommand):# but that is too much work for this script that will be used only once.if base_video and options['process_videos']:for video_name in base_video.split('/'):- path = VIDEO_PATH / pathlib.Path(video_name.strip() + VIDEO_EXTENSION)- with path.open('rb') as video_file:- video = ExerciseVideo()- video.exercise_base = base- video.license = default_license- video.license_author = VIDEO_AUTHOR- video.video.save(- path.name,- File(video_file),- )- video.save()- self.stdout.write(f'Saving video {video.video}\n')+ video_processed = True++ for extension in VIDEO_EXTENSIONS:+ path = VIDEO_PATH / pathlib.Path(video_name.strip() + extension)++ if video_processed or not path.exists():+ continue++ with path.open('rb') as video_file:+ video = ExerciseVideo()+ video.exercise_base = base+ video.license = default_license+ video.license_author = VIDEO_AUTHOR+ video.video.save(+ path.name,+ File(video_file),+ )+ video.save()+ self.stdout.write(f'Saving video {path}\n')+ video_processed = True## Process the translations and create new exercises if necessary