aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorla-ninpre <leobrekalini@gmail.com>2020-12-10 20:28:18 +0300
committerla-ninpre <leobrekalini@gmail.com>2020-12-10 20:28:18 +0300
commited3ce881738148ce67b077377991ecc6f65015df (patch)
tree76bbd758ce04fb923f5f3c2318f79aeda6b163b8
parent4c57d96e545b73e0423566f22695179f58341abf (diff)
downloadtg2md-ed3ce881738148ce67b077377991ecc6f65015df.tar.gz
tg2md-ed3ce881738148ce67b077377991ecc6f65015df.zip
update readme
oops, forgot to change name of script there
-rw-r--r--README.md23
-rw-r--r--tg2md.py6
2 files changed, 15 insertions, 14 deletions
diff --git a/README.md b/README.md
index 959d9b3..ab3a163 100644
--- a/README.md
+++ b/README.md
@@ -19,25 +19,28 @@ only photos, voice messages and audio files.
In format menu you should specify 'Machine-readable JSON' file and then
locate to directory of your desire.
-To convert your posts to markdown files you need to copy `parse.py` file into
-your export folder and run it there.
+To convert your posts to markdown files you need to run `tg2md.py` program
+which takes path to your `result.json` file as first argument.
```console
-$ cp parse.py /path/to/export/dir
-$ cd /path/to/export/dir
-$ python parse.py
+$ python tg2md.py path/to/result.json
```
-Currently there's no way to change name of ouput folder other than directly
-editing the script. By default it's creating directory `formatted_posts` with
-markdown files in there.
+By default it will create `formatted_posts` directory in your current directory
+and populate it with markdown files. If you want to specify other location,
+use `--out-dir` flag
+
+```console
+$ python tg2md.py result.json --out-dir path/to/post/output
+```
Also if your jekyll directory storing media files in folders other than `photos`
-and `files`, you should change `photo_dir` and `media_dir` variables.
+and `files`, you should specify their location with `--photo-dir` and
+`--media-dir` flags respectively. Note that they only change links in the
+markdown files.
## todo's
-- use argparse module instead of crap
- replies
- single/muliple tags
- forwarded posts
diff --git a/tg2md.py b/tg2md.py
index 90e219d..ac2f201 100644
--- a/tg2md.py
+++ b/tg2md.py
@@ -10,14 +10,13 @@
# - custom post header
import os
-import sys
import argparse
import json
from datetime import datetime
-
def print_default_post_header(post_title, post_date, post_tag):
+
'''
returns default post header
'''
@@ -259,8 +258,7 @@ def main():
with open(post_path, 'w') as f:
print(print_default_post_header(
- post_id, post_date, None),
- file=f)
+ post_id, post_date, None), file=f)
print(parse_post(post, args.photo_dir, args.media_dir), file=f)