Add subtitle metadata and improve downloader UI
Expose subtitle information in the API and update the frontend to use it: backend adds subtitle_languages and has_subtitles to the downloader serializer/response (computed from subtitles and automatic_captions). Generated TypeScript models (public & private) now include these fields. Downloader UI: gather available subtitle languages, show a select when languages exist, provide contextual input/placeholder when only auto-captions exist, and disable/annotate embed controls when subtitles or thumbnails are unavailable. These changes enable subtitle selection/embedding and surface thumbnail availability to users.
This commit is contained in:
16
backend/thirdparty/downloader/views.py
vendored
16
backend/thirdparty/downloader/views.py
vendored
@@ -96,6 +96,13 @@ class Downloader(APIView):
|
||||
child=serializers.CharField(),
|
||||
help_text="List of available audio format options"
|
||||
),
|
||||
"subtitle_languages": serializers.ListField(
|
||||
child=serializers.CharField(),
|
||||
help_text="List of manually available subtitle language codes (e.g., 'en', 'cs')"
|
||||
),
|
||||
"has_subtitles": serializers.BooleanField(
|
||||
help_text="True if any subtitles or auto-captions are available"
|
||||
),
|
||||
}
|
||||
),
|
||||
help_text="Array of video information (single video for individual URLs, multiple for playlists)"
|
||||
@@ -177,13 +184,20 @@ class Downloader(APIView):
|
||||
# If thumbnail fetch fails, just continue without it
|
||||
pass
|
||||
|
||||
subtitles_data = video_data.get("subtitles") or {}
|
||||
auto_captions = video_data.get("automatic_captions") or {}
|
||||
subtitle_languages = sorted(subtitles_data.keys())
|
||||
has_subtitles = bool(subtitles_data) or bool(auto_captions)
|
||||
|
||||
return {
|
||||
"id": video_data.get("id", ""),
|
||||
"title": video_data.get("title", ""),
|
||||
"duration": video_data.get("duration"),
|
||||
"thumbnail": thumbnail_blob, # Now a base64 blob instead of URL
|
||||
"thumbnail": thumbnail_blob,
|
||||
"video_resolutions": video_resolutions,
|
||||
"audio_resolutions": audio_resolutions,
|
||||
"subtitle_languages": subtitle_languages,
|
||||
"has_subtitles": has_subtitles,
|
||||
}
|
||||
|
||||
# Check if this is a playlist
|
||||
|
||||
Reference in New Issue
Block a user