telegram_media_downloader

tangyohaMIT更新放缓

跨平台 Telegram 媒体下载器,可抓取会话、群组和频道中的视频与文件,单文件最大 2GiB,支持 Web 查看进度和 Bot 指令下载。

基于Dineshkarthik的项目, 电报视频下载,电报资源下载,跨平台,支持web查看下载进度 ,支持bot下发指令下载,支持下载已经加入的私有群但是限制下载的资源, telegram media download,Download media files from a telegram conversation/chat/channel up to 2GiB per file

v2.2.5发布于 2025-01-06 15:59 UTC5,657star +10 / 7 天661fork同步于 2026-11-11 05:33 UTC

怎么上手

由 README 提炼,执行前请确认
git clone https://github.com/tangyoha/telegram_media_downloader.git
cd telegram_media_downloader
make install
硬件要求按 README 说明

README 未说明

有 Docker 镜像
下载:源码 zip·GitHub Releases(安装包)本站不镜像安装包

项目说明

由 README 自动翻译提炼

从 Telegram 会话、群组和频道批量下载媒体文件,支持 Web 查看进度和 Bot 指令

跨平台 Telegram 媒体下载器,可抓取会话、群组和频道中的视频与文件,单文件最大 2GiB,支持 Web 查看进度和 Bot 指令下载。

核心能力

  • 按媒体类型和文件格式过滤下载内容
  • 用 download_filter 按消息日期范围筛选
  • 下载后可通过 rclone 或 aligo 上传到云盘
  • Web 页面查看下载进度并支持登录密码
  • Bot 下发 download 或 forward 指令触发下载

容易踩的坑

需要先在 my.telegram.org/apps 申请 api_id 和 api_hash 并填入 config.yaml;Web 页面默认只监听 127.0.0.1:5000,远程访问需把 web_host 改为 0.0.0.0;Docker 首次启动必须前台运行以输入手机号和验证码完成登录

内容由模型根据 README 生成,可能不完整或不准确,以官方文档为准。看原文 README

最近发版

5 个版本v2.2.5
  1. v2.2.5v2.2.5, 2025-01-07最新正式版2025-01-06 · 2025-01-06 15:59 UTC

    这个版本没有写更新说明。

  2. v2.2.4v2.2.4,2024-07-152024-07-15 · 2024-07-15 14:38 UTC

    这个版本没有写更新说明。

  3. v2.2.3v2.2.3,2023-10-302023-10-30 · 2023-10-30 12:07 UTC
    查看更新说明

    修复

    • 修复 listen_forward 转发问题
    • 修复 download 下载问题

    Fix

    • Fix /listen_forward forwarding problem
    • Fix /download download problem

    Full Changelog: https://github.com/tangyoha/telegram_media_downloader/compare/v2.2.2...v2.2.3

  4. v2.2.2v2.2.2,2023-10-302023-10-30 · 2023-10-30 03:16 UTC
    查看更新说明

    新功能

    • 添加reply_to_message_id 过滤条件
    • 隐藏转发源信息 #68
    • 支持完整转发一组媒体
    • 支持限制每分钟转发数量,请查阅 forward_limit
    • 支持机器人停止转发,下载,监听转发等任务
    • 支持没有音频的媒体组转发
    • 支持高延迟网络登录tdl
    • 添加机器人上传telegram进度显示
    • 支持评论区资源下载

    修复

    • 修复rclone存在空格无法创建文件问题
    • 修复window打包程序无法访问网页
    • 修复机器人下载时候,过滤器配置无法正常生效
    • 修复转发逻辑问题 #112
    • 修复转发范围设置问题 #99

    Feat

    • Add reply_to_message_id filter condition
    • Hide forwarding source information #68
    • Support complete forwarding of a group of media
    • Supports limiting the number of forwards per minute, please check forward_limit
    • Support robots to stop forwarding, downloading, monitoring forwarding and other tasks
    • Support media group forwarding without audio
    • Support high-latency network login tdl
    • Add robot upload telegram progress display *Support downloading resources in the comment area

    Fix

    • Fixed the problem that rclone cannot create files due to spaces.
    • Fixed the problem that the window packager cannot access the web page *Fixed the problem that the filter configuration cannot take effect normally when the robot is downloaded
    • Fix forwarding logic issue #112
    • Fix forwarding range setting issue #99

    What's Changed

    New Contributors

    Full Changelog: https://github.com/tangyoha/telegram_media_downloader/compare/v2.2.1...v2.2.2

  5. v2.2.1v2.2.1,2023-08-292023-08-29 · 2023-08-29 06:02 UTC
    查看更新说明

    新功能

    • 支持window打包,自动打包 #51
    • 支持sender_id,sender_name 过滤下载 #95
    • 增加web界面登录保护

    修复

    • 修复web界面暂停按钮失效问题
    • 修复web登录报错
    • 修复pyyaml导致无法生成docker镜像

    Feat

    • Support window packaging, automatic packaging #51
    • Support sender_id, sender_name filter download #95
    • Add web interface login protection

    fix

    • Fixed the failure of the pause button on the web interface
    • Fix web login error
    • Fix pyyaml cause docker image cannot be generated

    What's Changed

    Full Changelog: https://github.com/tangyoha/telegram_media_downloader/compare/v2.2.0...v2.2.1

用户点评

登录用户的真实使用记录,可按版本和硬件筛选
共 0 条

    还没有人点评。第一个说出真实体验的人最有价值。

    README 原文

    未翻译

    Overview

    Support two default running

    • The robot is running, and the command download or forward is issued from the robot

    • Download as a one-time download tool

    UI

    Web page

    After running, open a browser and visit localhost:5000 If it is a remote machine, you need to configure web_host: 0.0.0.0

    Robot

    Need to configure bot_token, please refer to Documentation

    Support

    CategorySupport
    LanguagePython 3.7 and above
    Download media typesaudio, document, photo, video, video_note, voice

    Version release plan

    Installation

    For *nix os distributions with make availability

    git clone https://github.com/tangyoha/telegram_media_downloader.git
    cd telegram_media_downloader
    make install
    

    For Windows which doesn't have make inbuilt

    git clone https://github.com/tangyoha/telegram_media_downloader.git
    cd telegram_media_downloader
    pip3 install -r requirements.txt
    

    Docker

    For more detailed installation tutorial, please check the wiki

    Make sure you have docker and docker-compose installed

    docker pull tangyoha/telegram_media_downloader:latest
    mkdir -p ~/app && mkdir -p ~/app/log/ && cd ~/app
    wget https://raw.githubusercontent.com/tangyoha/telegram_media_downloader/master/docker-compose.yaml -O docker-compose.yaml
    wget https://raw.githubusercontent.com/tangyoha/telegram_media_downloader/master/config.yaml -O config.yaml
    wget https://raw.githubusercontent.com/tangyoha/telegram_media_downloader/master/data.yaml -O data.yaml
    # vi config.yaml and docker-compose.yaml
    vi config.yaml
    
    # The first time you need to start the foreground
    # enter your phone number and code, then exit(ctrl + c)
    docker-compose run --rm telegram_media_downloader
    
    # After performing the above operations, all subsequent startups will start in the background
    docker-compose up -d
    
    # Upgrade
    docker pull tangyoha/telegram_media_downloader:latest
    cd ~/app
    docker-compose down
    docker-compose up -d
    

    Upgrade installation

    cd telegram_media_downloader
    pip3 install -r requirements.txt
    

    Configuration

    All the configurations are passed to the Telegram Media Downloader via config.yaml file.

    Getting your API Keys: The very first step requires you to obtain a valid Telegram API key (API id/hash pair):

    1. Visit https://my.telegram.org/apps and log in with your Telegram Account.
    2. Fill out the form to register a new Telegram application.
    3. Done! The API key consists of two parts: api_id and api_hash.

    Getting chat id:

    1. Using web telegram:

    1. Open https://web.telegram.org/?legacy=1#/im

    2. Now go to the chat/channel and you will see the URL as something like

      • https://web.telegram.org/?legacy=1#/im?p=u853521067_2449618633394 here 853521067 is the chat id.
      • https://web.telegram.org/?legacy=1#/im?p=@somename here somename is the chat id.
      • https://web.telegram.org/?legacy=1#/im?p=s1301254321_6925449697188775560 here take 1301254321 and add -100 to the start of the id => -1001301254321.
      • https://web.telegram.org/?legacy=1#/im?p=c1301254321_6925449697188775560 here take 1301254321 and add -100 to the start of the id => -1001301254321.

    2. Using bot:

    1. Use @username_to_id_bot to get the chat_id of
      • almost any telegram user: send username to the bot or just forward their message to the bot
      • any chat: send chat username or copy and send its joinchat link to the bot
      • public or private channel: same as chats, just copy and send to the bot
      • id of any telegram bot

    config.yaml

    api_hash: your_api_hash
    api_id: your_api_id
    chat:
    - chat_id: telegram_chat_id
      last_read_message_id: 0
      download_filter: message_date >= 2022-12-01 00:00:00 and message_date <= 2023-01-17 00:00:00
    - chat_id: telegram_chat_id_2
      last_read_message_id: 0
    # note we remove ids_to_retry to data.yaml
    ids_to_retry: []
    media_types:
    - audio
    - document
    - photo
    - video
    - voice
    - animation #gif
    file_formats:
      audio:
      - all
      document:
      - pdf
      - epub
      video:
      - mp4
    save_path: D:\telegram_media_downloader
    file_path_prefix:
    - chat_title
    - media_datetime
    upload_drive:
      # required
      enable_upload_file: true
      # required
      remote_dir: drive:/telegram
      # required
      upload_adapter: rclone
      # option,when config upload_adapter rclone then this config are required
      rclone_path: D:\rclone\rclone.exe
      # option
      before_upload_file_zip: True
      # option
      after_upload_file_delete: True
    hide_file_name: true
    file_name_prefix:
    - message_id
    - file_name
    file_name_prefix_split: ' - '
    max_download_task: 5
    web_host: 127.0.0.1
    web_port: 5000
    language: EN
    web_login_secret: 123
    allowed_user_ids:
    - 'me'
    date_format: '%Y_%m'
    enable_download_txt: false
    
    • api_hash - The api_hash you got from telegram apps
    • api_id - The api_id you got from telegram apps
    • bot_token - Your bot token
    • chat - Chat list
      • chat_id - The id of the chat/channel you want to download media. Which you get from the above-mentioned steps.
      • download_filter - Download filter, see How to use Filter
      • last_read_message_id - If it is the first time you are going to read the channel let it be 0 or if you have already used this script to download media it will have some numbers which are auto-updated after the scripts successful execution. Don't change it.
      • ids_to_retry - Leave it as it is. This is used by the downloader script to keep track of all skipped downloads so that it can be downloaded during the next execution of the script.
    • media_types - Type of media to download, you can update which type of media you want to download it can be one or any of the available types.
    • file_formats - File types to download for supported media types which are audio, document and video. Default format is all, downloads all files.
    • save_path - The root directory where you want to store downloaded files.
    • file_path_prefix - Store file subfolders, the order of the list is not fixed, can be randomly combined.
      • chat_title - Channel or group title, it will be chat id if not exist title.
      • media_datetime - Media date.
      • media_type - Media type, also see media_types.
    • upload_drive - You can upload file to cloud drive.
      • enable_upload_file - Enable upload file, default false.
      • remote_dir - Where you upload, like drive_id/drive_name.
      • upload_adapter - Upload file adapter, which can be rclone, aligo. If it is rclone, it supports all rclone servers that support uploading. If it is aligo, it supports uploading Ali cloud disk.
      • rclone_path - RClone exe path, see How to use rclone
      • before_upload_file_zip - Zip file before upload, default false.
      • after_upload_file_delete - Delete file after upload success, default false.
    • file_name_prefix - Custom file name, use the same as file_path_prefix
      • message_id - Message id
      • file_name - File name (may be empty)
      • caption - The title of the message (may be empty)
    • file_name_prefix_split - Custom file name prefix symbol, the default is -
    • max_download_task - The maximum number of task download tasks, the default is 5.
    • hide_file_name - Whether to hide the web interface file name, default false
    • web_host - Web host
    • web_port - Web port
    • language - Application language, the default is English (EN), optional ZH(Chinese),RU,UA
    • web_login_secret - Web page login password, if not configured, no login is required to access the web page
    • log_level - see logging._nameToLevel.
    • forward_limit - Limit the number of forwards per minute, the default is 33, please do not modify this parameter by default.
    • allowed_user_ids - Who is allowed to use the robot? The default login account can be used. Please add single quotes to the name with @.
    • date_format Support custom configuration of media_datetime format in file_path_prefix.see python-datetime
    • enable_download_txt Enable download txt file, default false

    Execution

    python3 media_downloader.py
    

    All downloaded media will be stored at the root of save_path. The specific location reference is as follows:

    The complete directory of video download is: save_path/chat_title/media_datetime/media_type. The order of the list is not fixed and can be randomly combined. If the configuration is empty, all files are saved under save_path.

    Proxy

    socks4, socks5, http proxies are supported in this project currently. To use it, add the following to the bottom of your config.yaml file

    proxy:
      scheme: socks5
      hostname: 127.0.0.1
      port: 1234
      username: your_username(delete the line if none)
      password: your_password(delete the line if none)
    

    If your proxy doesn’t require authorization you can omit username and password. Then the proxy will automatically be enabled.

    Contributing

    Contributing Guidelines

    Read through our contributing guidelines to learn about our submission process, coding rules and more.

    Want to Help?

    Want to file a bug, contribute some code, or improve documentation? Excellent! Read up on our guidelines for contributing.

    Code of Conduct

    Help us keep Telegram Media Downloader open and inclusive. Please read and follow our Code of Conduct.

    Sponsor

    PayPal

    Star History

    Star History Chart