diff options
| author | Eduard Mielieshkin <acronised68@gmail.com> | 2021-07-09 12:37:42 +0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-07-09 12:37:42 +0300 |
| commit | 59ad206e53b9eb9f57d2fa445f7920c1900d0575 (patch) | |
| tree | e078145fd03086c69a594a44b8e15e62c7190787 | |
| parent | ed3ce881738148ce67b077377991ecc6f65015df (diff) | |
| download | tg2md-59ad206e53b9eb9f57d2fa445f7920c1900d0575.tar.gz tg2md-59ad206e53b9eb9f57d2fa445f7920c1900d0575.zip | |
Add UTF-8 support
| -rw-r--r-- | tg2md.py | 5 |
1 files changed, 2 insertions, 3 deletions
@@ -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) |
