Skip to content

Commit 7cddcb0

Browse files
committed
misc: specify encoding for sub download
1 parent 96e98e2 commit 7cddcb0

2 files changed

Lines changed: 2 additions & 2 deletions

File tree

api/src/anipy_api/download.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ def download_sub(self, stream: "ProviderStream", download_path: Path):
279279

280280
suffix = f".{s.shortcode}.{s.codec}"
281281
path = download_path.with_suffix(suffix)
282-
with path.open("w") as fp:
282+
with path.open("w", encoding="utf-8") as fp:
283283
fp.write(res.text)
284284

285285
def download(

api/src/anipy_api/player/base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ def _get_media_sub(stream: "ProviderStream"):
8484
if stream.subtitle:
8585
for name, sub in stream.subtitle.items():
8686
suffix = f".{sub.shortcode}.{sub.codec}"
87-
subtitle_file = tempfile.NamedTemporaryFile("w+", delete=False, suffix=suffix)
87+
subtitle_file = tempfile.NamedTemporaryFile("w+", delete=False, suffix=suffix, encoding="utf-8")
8888
req = requests.get(sub.url, headers={"Referer": stream.referrer})
8989
subtitle_file.write(req.text)
9090
subtitles[name] = subtitle_file.name

0 commit comments

Comments
 (0)