all repos — tg2md @ main

converter from telegram json to jekyll md

ab90cef7
fix try except pass thingy.
la-ninpre leobrekalini@gmail.com
Sat, 17 Jul 2021 12:49:03 +0300
5e15940d
add short variants of command line flags
la-ninpre leobrekalini@gmail.com
Fri, 16 Jul 2021 23:38:19 +0300
856df0ec
add support for other file types (to be improved)

currently images that were sent as files are supported, but their files
land in `files` directory.

text file and additional image used for test are stored as symlinks now,
because i don't want them to consume too much space.
la-ninpre leobrekalini@gmail.com
Wed, 14 Jul 2021 19:35:12 +0300

tg2md

This script parses output from Telegram channel and converts each post to jekyll-applicable post in markdown.

Telegram Desktop creates JSON file, as well as different directories containing multimedia, photos, etc. This script creates new directory and populates it with formatted posts ready to publish.

basic usage

Firstly you need to export your channel history from Telegram Desktop app. This could be done from three dots menu. Then popup menu appears, where you can choose what data you want to export. The script currently supports only photos, voice messages and audio files.

tg-export

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 run tg2md.py program which takes path to your result.json file as first argument.

$ python tg2md.py path/to/result.json

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

$ 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 specify their location with --photo-dir and --media-dir flags respectively. Note that they only change links in the markdown files.

todo’s

clone
git clone https://git.aaoth.xyz/tg2md