Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: an issue where changing the transcript language code #34479

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions xmodule/video_block/video_handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -467,6 +467,7 @@ def validate_transcript_upload_data(self, data):

return error

# pylint: disable=too-many-statements
@XBlock.handler
def studio_transcript(self, request, dispatch):
"""
Expand Down Expand Up @@ -534,6 +535,10 @@ def studio_transcript(self, request, dispatch):
'edx_video_id': edx_video_id,
'language_code': new_language_code
}
# If a new transcript is added, then both new_language_code and
# language_code fields will have the same value.
if language_code != new_language_code:
self.transcripts.pop(language_code, None)
Comment on lines +540 to +541
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you have the same check in the add_or_update_transcripts function, why do you duplicate it here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dyudyunov Right, thanks for noticing this redundant code. Initially, I wanted to do it through a separate function. But then I realized that it was redundant. And after moving the logic to studio_transcript I forgot to delete add_or_update_transcripts.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I removed the add_or_update_transcripts function.

self.transcripts[new_language_code] = f'{edx_video_id}-{new_language_code}.srt'
response = Response(json.dumps(payload), status=201)
except (TranscriptsGenerationException, UnicodeDecodeError):
Expand Down
Loading