From 0b4f9d458c27cdc82ffa1da532587139abed31a2 Mon Sep 17 00:00:00 2001 From: T3d Date: Sat, 20 May 2023 23:06:26 +0200 Subject: [PATCH 1/2] Specify subtitles language Allow the user to specify a subtitles language (defaut to english). --- README.md | 4 ++++ yt_fts.py | 8 +++++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 5e1b0a6..876118f 100644 --- a/README.md +++ b/README.md @@ -52,6 +52,10 @@ If this fails you can manually input the channel id with the `--channel-id` flag ```bash python yt_fts.py download "https://www.youtube.com/@TimDillonShow/videos" --channel-id "UC4woSp8ITBoYDmjkukhEhxg" ``` +You can specify expected subtitles language +```bash +python yt_fts.py download "https://www.youtube.com/@TimDillonShow/videos" --language de +``` ### `list` Will list all of your downloaded channels diff --git a/yt_fts.py b/yt_fts.py index 970d6f6..03aabb1 100644 --- a/yt_fts.py +++ b/yt_fts.py @@ -24,11 +24,12 @@ def list(): @click.command( help='download [channel url]') @click.argument('channel_url', required=True) @click.option('--channel-id', default=None, help='Optional channel id to override the one from the url') -def download(channel_url, channel_id): +@click.option('--language', default="en", help='Language of the subtitles to download') +def download(channel_url, channel_id, language): if channel_id is None: channel_id = get_channel_id(channel_url) if channel_id: - download_channel(channel_id) + download_channel(channel_id, language) else: print("Error finding channel id try --channel-id option") @@ -74,7 +75,7 @@ def delete(channel_id): -def download_channel(channel_id): +def download_channel(channel_id, language): print("Downloading channel") with tempfile.TemporaryDirectory() as tmp_dir: print('Saving vtt files to', tmp_dir) @@ -87,6 +88,7 @@ def download_channel(channel_id): "--write-auto-sub", "--convert-subs", "vtt", "--skip-download", + "--sub-langs", language + ",-live_chat", channel_url ]) add_channel_info(channel_id, channel_name, channel_url) From bca14f9ec8607a3b6f160bfefe5facba83caa521 Mon Sep 17 00:00:00 2001 From: T3d Date: Sat, 20 May 2023 23:14:51 +0200 Subject: [PATCH 2/2] Use f-Strings --- yt_fts.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/yt_fts.py b/yt_fts.py index 03aabb1..079f30c 100644 --- a/yt_fts.py +++ b/yt_fts.py @@ -88,7 +88,7 @@ def download_channel(channel_id, language): "--write-auto-sub", "--convert-subs", "vtt", "--skip-download", - "--sub-langs", language + ",-live_chat", + "--sub-langs", f"{language},-live_chat", channel_url ]) add_channel_info(channel_id, channel_name, channel_url)