Skip to main content

Telegram media downloader library

Project description

TgLoader

Python library for downloading media from Telegram channels and chats.

Installation

pip install tgloader

Setup

  1. Go to my.telegram.org → API Development Tools → Create application
  2. Create .env file:
api_id=12345678
api_hash=your_api_hash_here

First Run: You'll need to authorize via phone number/code when you run it first time.
Files: Downloaded media saved to current directory in folders like Name_ID/
Formats: Supports photos (jpg), videos (mp4), audio (mp3)

Usage

from tgloader import TgLoader

# Create instance
loader = TgLoader()

# Show all available channels/chats
loader.print_all()

# Download by ID or @username
loader.run("-1001234567890")  # by ID
loader.run("@username")       # by username

# Download with date range
loader.run("-1001234567890", from_date="2025-01-01", to_date="NOW")

# Using config file
loader.run_conf("config.yaml")

Date/ID Format

Dates:

  • "OLDEST" - from the beginning
  • "NOW" - current moment
  • "2025-01-01" - specific date
  • "NOW-3D" - 3 days ago
  • "NOW-12H" - 12 hours ago
  • "NOW-30m" - 30 minutes ago

Message IDs:

  • "12345" - specific message ID
  • "100" to "200" - ID range

Examples:

# Last week
loader.run("@name", from_date="NOW-7D", to_date="NOW")

# Specific month
loader.run("@name", from_date="2024-01-01", to_date="2025-01-31")

# Last 24 hours
loader.run("@name", from_date="NOW-1D", to_date="NOW")

# Message ID range
loader.run("@name", from_date="1000", to_date="2000")

# From specific message to now
loader.run("@name", from_date="12345", to_date="NOW")

Config File (config.yaml)

download_this:
  -1001234567890:
    from: "2025-01-01"
    to: "NOW"
    print_content: true
  
  "@username":
    from: "OLDEST"
    to: "NOW"

TgLoader

Python библиотека для скачивания медиа из Telegram каналов и чатов.

Установка

pip install tgloader

Настройка

  1. Зайдите на my.telegram.org → API Development Tools → Создать приложение
  2. Создайте файл .env:
api_id=12345678
api_hash=ваш_api_hash_здесь

Первый запуск: Потребуется авторизация через номер телефона/код при первом запуске.
Файлы: Скачанные медиа сохраняются в текущую директорию в папки вида Имя_ID/
Форматы: Поддерживает фото (jpg), видео (mp4), аудио (mp3)

Использование

from tgloader import TgLoader

# Создать экземпляр
loader = TgLoader(lang='ru')

# Показать все доступные каналы/чаты
loader.print_all()

# Скачать по ID или @имени
loader.run("-1001234567890")  # по ID
loader.run("@имя")           # по имени

# Скачать с диапазоном дат
loader.run("-1001234567890", from_date="2025-01-01", to_date="NOW")

# Использовать конфиг файл
loader.run_conf("config.yaml")

Формат дат/ID

Даты:

  • "OLDEST" - с самого начала
  • "NOW" - текущий момент
  • "2025-01-01" - конкретная дата
  • "NOW-3D" - 3 дня назад
  • "NOW-12H" - 12 часов назад
  • "NOW-30m" - 30 минут назад

ID сообщений:

  • "12345" - конкретный ID сообщения
  • "100" до "200" - диапазон ID

Примеры:

# Последняя неделя
loader.run("@имя", from_date="NOW-7D", to_date="NOW")

# Конкретный месяц
loader.run("@имя", from_date="2025-01-01", to_date="2025-01-31")

# Последние 24 часа
loader.run("@имя", from_date="NOW-1D", to_date="NOW")

# Диапазон ID сообщений
loader.run("@имя", from_date="1000", to_date="2000")

# От конкретного сообщения до сейчас
loader.run("@имя", from_date="12345", to_date="NOW")

Конфиг файл (config.yaml)

download_this:
  -1001234567890:
    from: "2025-01-01"
    to: "NOW"
    print_content: true
  
  "@имя":
    from: "OLDEST"
    to: "NOW"

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

tgloader-0.0.1.tar.gz (12.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

tgloader-0.0.1-py3-none-any.whl (11.2 kB view details)

Uploaded Python 3

File details

Details for the file tgloader-0.0.1.tar.gz.

File metadata

  • Download URL: tgloader-0.0.1.tar.gz
  • Upload date:
  • Size: 12.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.9

File hashes

Hashes for tgloader-0.0.1.tar.gz
Algorithm Hash digest
SHA256 028b923abd67f07876d4d46fb1334609648f88044127f61ce2a43cfb637d40c8
MD5 a5f269b3b88a796fbe41623e71c8a074
BLAKE2b-256 a92c708fe539c5afcb37bf402464ff0e45daefff959872b870338282a2907df1

See more details on using hashes here.

File details

Details for the file tgloader-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: tgloader-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 11.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.9

File hashes

Hashes for tgloader-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 bccebf7491c1807b831516f23559d92b8a74a25bf03637c0d50fb540fb39eec8
MD5 e33cea425e92c7fa1e2a32b5b47ebeff
BLAKE2b-256 1adc643f132b013876d1c60ed44121ec44d5ec77a9c7f5347cf87da2e6dc8f0f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page