diff --git a/danmaku/youtube-live-chat-danmaku-ass.py b/danmaku/youtube-live-chat-danmaku-ass.py index bb62377..2421ff1 100755 --- a/danmaku/youtube-live-chat-danmaku-ass.py +++ b/danmaku/youtube-live-chat-danmaku-ass.py @@ -380,12 +380,12 @@ def _load_mapped_emoji(self): path = self._get_mapped_emoji_path() if not os.path.isfile(path): return {} - with open(path) as f: + with open(path, encoding='utf-8') as f: return json.loads(f.read()) def _save_mapped_emoji(self): path = self._get_mapped_emoji_path() - with open(path, 'w') as f: + with open(path, 'w', encoding='utf-8') as f: f.write(json.dumps(self._url_by_emoji)) def _get_mapped_emoji_path(self): @@ -547,8 +547,8 @@ def update_common_props(renderer): def main(): - input_buffer = sys.stdin if sys.argv[1] == '-' else open(sys.argv[1], 'r') - output_buffer = sys.stdout if sys.argv[2] == '-' else open(sys.argv[2], 'w') + input_buffer = sys.stdin if sys.argv[1] == '-' else open(sys.argv[1], 'r', encoding="utf-8") + output_buffer = sys.stdout if sys.argv[2] == '-' else open(sys.argv[2], 'w', encoding="utf-8") ass_generator = DanmakuASSGenerator() parser = YoutubeLiveChatReplayParser()