Skip to content

Commit

Permalink
Merge pull request #7 from TeddyBear06/choose_subtitles_language
Browse files Browse the repository at this point in the history
Specify subtitles language
  • Loading branch information
NotJoeMartinez committed May 21, 2023
2 parents 97fc551 + bca14f9 commit 859bfee
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,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
Expand Down
8 changes: 5 additions & 3 deletions yt_fts.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand Down Expand Up @@ -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)
Expand All @@ -87,6 +88,7 @@ def download_channel(channel_id):
"--write-auto-sub",
"--convert-subs", "vtt",
"--skip-download",
"--sub-langs", f"{language},-live_chat",
channel_url
])
add_channel_info(channel_id, channel_name, channel_url)
Expand Down

0 comments on commit 859bfee

Please sign in to comment.