This project was to create a self hosted pdf library based on the pdf and news sent on the telegram channel and there is no need of any external service dependencies. The script downloads the media that is sent in the channels and saves it in the specified location. However it also check for the media content that's already been downloaded to avoid duplicate files. I run it on my Raspberry Pi 3 based NAS and the media\books can be viewed from any device in the home. The script was developed on windows and is being used on Linux(Debian)
-
To start with you have to create your own telegram app config and get token thru https://my.telegram.org/auth (you can google it)
-
Update the script with Telegram Username, App api_id, App api_hash from step 1
-
Make sure you are using Python3 and install following modules
pip3 install cryptg (depreciated) pip3 install telethon pip3 install asyncio
-
Update the Channel name without @ against : channel_name
-
Mention the path against : download_path
-
Number of media files to be downloaded can be restricted using : **msg_limit **
-
Place it in the accessible folder with required permissions.
-
Execute it using a crontab and the media will be downloaded as per schedule.
-
Cron Tab details 0 1 * * * python3 pytele.py books_and_magazines 0 0 * * * python3 pytele.py Marvel_DC_Comics_Book 30 1 * * * /usr/bin/find /media/USB/ -type f -mtime +20 -exec rm {} +