Add subtitle-only download for already-downloaded videos
- download_subs_only(): yt-dlp --skip-download to fetch just .vtt sidecar
- POST /by-yt/{ytId}/download-subs endpoint
- CC chip now visible on downloaded videos; clicking checks YouTube,
shows lang picker with "Add subtitles" button separate from re-download
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -384,6 +384,22 @@ def fetch_channel_links(channel_id: str) -> list[str]:
|
||||
return list(channel_ids)
|
||||
|
||||
|
||||
def download_subs_only(video_id: str, subtitle_langs: str) -> bool:
|
||||
"""Download subtitle files only (no video) for an already-downloaded video."""
|
||||
url = f"https://www.youtube.com/watch?v={video_id}"
|
||||
output_template = str(Path(settings.download_path) / f"{video_id}.%(ext)s")
|
||||
_, _, code = _run([
|
||||
"yt-dlp", url,
|
||||
"--skip-download", "--no-playlist",
|
||||
"--write-subs", "--write-auto-subs",
|
||||
"--sub-langs", subtitle_langs,
|
||||
"--convert-subs", "vtt",
|
||||
"-o", output_template,
|
||||
*_cookie_args(),
|
||||
], timeout=60)
|
||||
return code == 0
|
||||
|
||||
|
||||
def fetch_available_subs(video_id: str) -> dict:
|
||||
"""Return subtitle languages available on YouTube for a video.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user