aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLev Brekalov <57688959+la-ninpre@users.noreply.github.com>2021-07-12 13:20:27 +0300
committerGitHub <noreply@github.com>2021-07-12 13:20:27 +0300
commit43c88a3cf8f007dd9969ea20b0e5bdabec636ec6 (patch)
treee078145fd03086c69a594a44b8e15e62c7190787
parented3ce881738148ce67b077377991ecc6f65015df (diff)
parent59ad206e53b9eb9f57d2fa445f7920c1900d0575 (diff)
downloadtg2md-43c88a3cf8f007dd9969ea20b0e5bdabec636ec6.tar.gz
tg2md-43c88a3cf8f007dd9969ea20b0e5bdabec636ec6.zip
Merge pull request #2 from progxaker/main
Add UTF-8 support
-rw-r--r--tg2md.py5
1 files 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)