Merge pull request #2 from progxaker/main Add UTF-8 support
Lev Brekalov 57688959+la-ninpre@users.noreply.github.com
Mon, 12 Jul 2021 13:20:27 +0300
1 files changed,
2 insertions(+),
3 deletions(-)
jump to
M
tg2md.py
→
tg2md.py
@@ -204,7 +204,6 @@ description='Convert exported Telegram channel data json to \
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 @@ pass
# 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 @@ post_id = post['id']
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)