Skip to content
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

Change default subtitle encoding to utf8 #1125

Merged
merged 2 commits into from
Jun 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ Changelog
^^^^^
**release date:** *not released*

* Change default encoding of downloaded subtitle to 'utf-8' (not the original encoding)
* Switch podnapisi provider to use JSON API
* Add support for episodes with season 0 in podnapisi provider
* Disabled addic7ed provider due to required captcha for authentication
Expand Down
17 changes: 16 additions & 1 deletion subliminal/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,14 @@ def cache(ctx: click.Context, clear_subliminal: bool) -> None:
'--encoding',
type=click.STRING,
metavar='ENC',
help='Subtitle file encoding, default is to preserve original encoding.',
default='utf-8',
help='Force subtitle file encoding, default is utf-8.',
)
@click.option(
'--original-encoding',
is_flag=True,
default=False,
help='Preserve original subtitle file encoding.',
)
@click.option(
'-s',
Expand Down Expand Up @@ -354,6 +361,7 @@ def download(
age: timedelta | None,
directory: str | None,
encoding: str | None,
original_encoding: bool,
single: bool,
force: bool,
hearing_impaired: bool,
Expand All @@ -374,6 +382,13 @@ def download(
# process parameters
language_set = set(language)

# preserve original encoding
if original_encoding:
encoding = None
# no encoding specified, default to utf-8
elif encoding is None:
encoding = 'utf-8'

debug = obj.get('debug', False)
if debug:
verbose = 3
Expand Down