From 59ad206e53b9eb9f57d2fa445f7920c1900d0575 Mon Sep 17 00:00:00 2001 From: Eduard Mielieshkin Date: Fri, 9 Jul 2021 12:37:42 +0300 Subject: Add UTF-8 support --- tg2md.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/tg2md.py b/tg2md.py index ac2f201..706ee85 100644 --- a/tg2md.py +++ b/tg2md.py @@ -204,7 +204,6 @@ def main(): bunch of markdown posts ready to use with jekyll') parser.add_argument( 'json', metavar='json_file', - type=open, help='result.json file from telegram export') parser.add_argument( '--out-dir', metavar='out_dir', @@ -239,7 +238,7 @@ def main(): # load json file try: - with args.json as f: + with open(args.json, 'r', encoding='utf-8') as f: data = json.load(f) except FileNotFoundError: sys.exit('result.json not found.\nPlease, specify right file') @@ -256,7 +255,7 @@ def main(): post_filename = str(post_date.date()) + '-' + str(post_id) + '.md' post_path = os.path.join(args.out_dir, post_filename) - with open(post_path, 'w') as f: + with open(post_path, 'w', encoding='utf-8') as f: print(print_default_post_header( post_id, post_date, None), file=f) print(parse_post(post, args.photo_dir, args.media_dir), file=f) -- cgit v1.2.3