Skip to content

Commit 91fd4e7

Browse files
fix: bypass bad urls (#1229)
1 parent 46205e8 commit 91fd4e7

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

ui/management/commands/sync_video_key_with_edx.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -80,11 +80,16 @@ def handle(self, *args, **options):
8080

8181
latest_videos_by_created_at = {}
8282
for video in course_videos:
83-
key = (
84-
(video.get("encoded_videos") or [{}])[0]
85-
.get("url", "/")
86-
.split("/")[-2]
87-
)
83+
url = (video.get("encoded_videos") or [{}])[0].get("url", "/")
84+
try:
85+
key = url.split("/")[-2]
86+
except IndexError:
87+
self.stdout.write(
88+
self.style.ERROR(
89+
f"BAD URL: Could not extract video key from URL {url} for video {video.get('client_video_id')}"
90+
)
91+
)
92+
continue
8893

8994
# verify if key is a valid UUID
9095
try:

0 commit comments

Comments
 (0)