From ed3ce881738148ce67b077377991ecc6f65015df Mon Sep 17 00:00:00 2001 From: la-ninpre Date: Thu, 10 Dec 2020 20:28:18 +0300 Subject: update readme oops, forgot to change name of script there --- README.md | 23 +++++++++++++---------- tg2md.py | 6 ++---- 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) -- cgit v1.2.3