Repository navigation
feat: apply FC-0118 ADRs to youtube transcripts APIs #39100
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
Merged
Faraz32123
merged 5 commits into
master
from
feat/apply_fc_0118_ADRs_to_youtube_transcript_endpoints
Oct 9, 2026
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
67256cd
feat: apply FC-0118 ADRs to youtube transcripts APIs
Faraz32123 a93340c
Merge remote-tracking branch 'origin/master' into feat/apply_fc_0118_…
Faraz32123 d0c94cb
fix: address review feedback on the youtube transcripts APIs
Faraz32123 6fd7add
fix: stop registering error types in the youtube transcripts service
Faraz32123 7b12715
docs: note why a YouTube failure is a 400 in the transcripts service
Faraz32123 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| """Contentstore API v1 authoring URLs.""" | ||
|
|
||
| from django.urls import path | ||
|
|
||
| from cms.djangoapps.contentstore.rest_api.v1.views import ( | ||
| YoutubeTranscriptChecksViewSet, | ||
| YoutubeTranscriptImportsViewSet, | ||
| ) | ||
|
|
||
| app_name = "authoring_v1" | ||
|
|
||
| urlpatterns = [ | ||
| path( | ||
| "courses/<course_key:course_key>/youtube_transcript_checks/", | ||
| YoutubeTranscriptChecksViewSet.as_view({"get": "list"}), | ||
| name="youtube_transcript_check_list", | ||
| ), | ||
| path( | ||
| "courses/<course_key:course_key>/youtube_transcript_imports/", | ||
| YoutubeTranscriptImportsViewSet.as_view({"post": "create"}), | ||
| name="youtube_transcript_import_list", | ||
| ), | ||
| ] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
120 changes: 120 additions & 0 deletions
120
cms/djangoapps/contentstore/rest_api/v1/serializers/youtube_transcripts.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,120 @@ | ||
| """API Serializers for YouTube transcripts.""" | ||
|
|
||
| from rest_framework import serializers | ||
|
|
||
|
|
||
| class YoutubeTranscriptVideoSerializer(serializers.Serializer): | ||
| """One entry of the video list identifying a source to inspect or import from.""" | ||
|
|
||
| type = serializers.CharField( | ||
| help_text=( | ||
| 'Source kind. "youtube" names a YouTube video id, "edx_video_id" names a ' | ||
| "video in the video pipeline, and any other value is treated as an HTML5 source." | ||
| ), | ||
| ) | ||
| video = serializers.CharField( | ||
| help_text="Identifier of the source, interpreted according to the type field.", | ||
| ) | ||
| mode = serializers.CharField( | ||
| required=False, | ||
| allow_blank=True, | ||
| help_text='Playback mode of an HTML5 source, such as "mp4" or "webm".', | ||
| ) | ||
|
|
||
| class Meta: | ||
| ref_name = "YoutubeTranscriptVideo" | ||
|
|
||
|
|
||
| class YoutubeTranscriptCheckRequestSerializer(serializers.Serializer): | ||
| """Input identifying the video block whose transcript state is requested.""" | ||
|
|
||
| locator = serializers.CharField( | ||
| help_text="Usage key of the video block to inspect.", | ||
| ) | ||
| videos = YoutubeTranscriptVideoSerializer( | ||
| many=True, | ||
| help_text="Video sources declared on the block, used to decide which transcripts to compare.", | ||
| ) | ||
|
|
||
| class Meta: | ||
| ref_name = "YoutubeTranscriptCheckRequest" | ||
|
|
||
|
|
||
| class YoutubeTranscriptImportRequestSerializer(serializers.Serializer): | ||
| """Input identifying the video block to import a YouTube transcript into.""" | ||
|
|
||
| locator = serializers.CharField( | ||
| help_text="Usage key of the video block to import the transcript into.", | ||
| ) | ||
| videos = YoutubeTranscriptVideoSerializer( | ||
| many=True, | ||
| help_text='Video sources declared on the block. An entry of type "youtube" is required.', | ||
| ) | ||
|
|
||
| def validate_videos(self, value): | ||
| """Require the YouTube source the transcript is imported from.""" | ||
| if not any(video.get("type") == "youtube" for video in value): | ||
| raise serializers.ValidationError('An entry of type "youtube" is required.') | ||
| return value | ||
|
|
||
| class Meta: | ||
| ref_name = "YoutubeTranscriptImportRequest" | ||
|
|
||
|
|
||
| class YoutubeTranscriptCheckResultSerializer(serializers.Serializer): | ||
| """Transcript availability of one video block, across its declared sources.""" | ||
|
|
||
| html5_local = serializers.ListField( | ||
| child=serializers.CharField(), | ||
| help_text="Identifiers of the HTML5 sources that already have a transcript stored for this course.", | ||
| ) | ||
| html5_equal = serializers.BooleanField( | ||
| help_text="Whether exactly two HTML5 sources were found and their stored transcripts are identical.", | ||
| ) | ||
| is_youtube_mode = serializers.BooleanField( | ||
| help_text="Whether the block declares a YouTube source, which takes priority over HTML5 sources.", | ||
| ) | ||
| youtube_local = serializers.BooleanField( | ||
| help_text="Whether a transcript for the YouTube source is already stored for this course.", | ||
| ) | ||
| youtube_server = serializers.BooleanField( | ||
| help_text="Whether YouTube is currently serving a transcript for the video.", | ||
| ) | ||
| youtube_diff = serializers.BooleanField( | ||
| help_text="Whether the transcript on YouTube differs from the stored one.", | ||
| ) | ||
| current_item_subs = serializers.CharField( | ||
| required=False, | ||
| allow_null=True, | ||
| help_text="Name of the transcript currently attached to the block, or null when none is attached.", | ||
| ) | ||
| status = serializers.CharField( | ||
| help_text='Outcome of the check: "Success" when the block could be inspected.', | ||
| ) | ||
| command = serializers.CharField( | ||
| help_text=( | ||
| "Action the caller should take next: replace, found, import, choose, " | ||
| "use_existing, or not_found." | ||
| ), | ||
| ) | ||
|
|
||
| class Meta: | ||
| ref_name = "YoutubeTranscriptCheckResult" | ||
|
|
||
|
|
||
| class YoutubeTranscriptImportResultSerializer(serializers.Serializer): | ||
| """Outcome of importing a YouTube transcript into a video block.""" | ||
|
|
||
| edx_video_id = serializers.CharField( | ||
| allow_null=True, | ||
| help_text=( | ||
| "Video pipeline identifier the transcript was attached to. Null when the block " | ||
| "lives in a content library, where transcripts are stored on the block itself." | ||
| ), | ||
| ) | ||
| status = serializers.CharField( | ||
| help_text='Outcome of the import: "Success" when the transcript was stored.', | ||
| ) | ||
|
|
||
| class Meta: | ||
| ref_name = "YoutubeTranscriptImportResult" | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.