Skip to content

armgit / wger

Public Imported from GitHub
0

Self hosted FLOSS fitness/workout, nutrition and weight tracker

Fix synchronization script for videos

Roland Geider5bd8b8f4ce67
diff --git a/wger/exercises/management/commands/download-exercise-videos.py b/wger/exercises/management/commands/download-exercise-videos.py
index a134cb34d..d8282669c 100644
--- a/wger/exercises/management/commands/download-exercise-videos.py
+++ b/wger/exercises/management/commands/download-exercise-videos.py
@@ -92,11 +92,10 @@ class Command(BaseCommand):
for video_data in result['results']:
video_uuid = video_data['uuid']
-
self.stdout.write(f'Processing video {video_uuid}')
try:
- exercise_base = ExerciseBase.objects.get(id=video_data['exercise_base'])
+ exercise_base = ExerciseBase.objects.get(uuid=video_data['exercise_base_uuid'])
except ExerciseBase.DoesNotExist:
self.stdout.write(' Remote exercise base not found in local DB, skipping...')
continue
@@ -132,12 +131,12 @@ class Command(BaseCommand):
img_temp.write(retrieved_video.content)
img_temp.flush()
- video.image.save(
- os.path.basename(os.path.basename(video_data['image'])),
+ video.video.save(
+ os.path.basename(os.path.basename(video_data['video'])),
File(img_temp),
)
video.save()
- self.stdout.write(self.style.SUCCESS(' successfully saved'))
+ self.stdout.write(self.style.SUCCESS(' saved successfully'))
if result['next']:
page += 1
diff --git a/wger/exercises/models/video.py b/wger/exercises/models/video.py
index dd9b68a9f..d9b5724a3 100644
--- a/wger/exercises/models/video.py
+++ b/wger/exercises/models/video.py
@@ -158,7 +158,7 @@ class ExerciseVideo(AbstractLicenseModel, models.Model):
"""
Save metadata about the video if ffmpeg is installed
"""
- if ffmpeg and not self.pk:
+ if ffmpeg and not self.pk and hasattr(self.video.file, 'temporary_file_path'):
probe_result = ffmpeg.probe(self.video.file.temporary_file_path())
self.size = probe_result['format']['size']
self.duration = probe_result['format']['duration']