all repos — tg2md @ ed3ce881738148ce67b077377991ecc6f65015df

converter from telegram json to jekyll md

update readme

oops, forgot to change name of script there
la-ninpre leobrekalini@gmail.com
Thu, 10 Dec 2020 20:28:18 +0300
commit

ed3ce881738148ce67b077377991ecc6f65015df

parent

4c57d96e545b73e0423566f22695179f58341abf

2 files changed, 15 insertions(+), 14 deletions(-)

jump to
M README.mdREADME.md

@@ -19,25 +19,28 @@

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
M tg2md.pytg2md.py

@@ -10,13 +10,12 @@ # - forwarded posts

# - 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 @@ post_path = os.path.join(args.out_dir, post_filename)

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)