Download videos from Youtube and other platforms through a Telegram Bot

Overview

ytdl-bot

Download videos from YouTube and other platforms through a Telegram Bot

Usage:

https://t.me/benny_ytdlbot

Send link from YouTube directly to the bot. Any platform supported by youtube-dl will also work.

Feature

  1. fast download and upload. Many thanks to FastTelethon and JasonKhew96's contribution on this!

  2. ads free - I'll never send ads to you, also I don't even print logs that will identify you. So feel free to download any type of video from any website.

  3. support progress bar

How to deploy?

Normal

  1. clone code and update submodule git submodule update --init --recursive
  2. install ffmpeg
  3. install Python 3.6+
  4. pip3 install -r requirements.txt
  5. set environment variables TOKEN, APP_ID and APP_HASH
  6. python3 bot.py
  7. supervisor on your own preference.

docker

see here

Command

start - let's start
about - wanna contribute?
ping - bot running status
help - it's not working?
ytdl - download video in group

Test video

https://www.youtube.com/watch?v=BaW_jenozKc

License

Apache License 2.0

Comments
  • Covert to Audio Button does Not work.

    Covert to Audio Button does Not work.

    Hi,

    It seems like the "Convert to Audio Button" under a downloaded Video doesnt seem to work.

    Screenshot_2022-06-24-16-28-56-02_3d419158bad5872c40592a6c9956e692__01.jpg

    This is the Error Message that gets shown (sry i cant copy it right now so only Screenshot is possible)

    bug 
    opened by oneandonlyjason 16
  • Change Text in Docker and Telegram setMyCommands API

    Change Text in Docker and Telegram setMyCommands API

    Hi, thank you for this Bot!

    is there a way to change the Output of the Texts that the Bot sends in Docker? Like change the Help Text or something like this.

    And maybe you could add the Telegram setMyCommands Method so that the Bot automatically registers its commands with Telegram https://core.telegram.org/bots/api#setmycommands

    opened by oneandonlyjason 9
  • Cached is not working

    Cached is not working

    Traceback (most recent call last): File "/ytdlbot/ytdlbot/tasks.py", line 111, in forward_video res_msg: "Message" = upload_processor(client, bot_msg, url, cached_fid) File "/ytdlbot/ytdlbot/tasks.py", line 357, in upload_processor res_msg = client.send_video(chat_id, vp_or_fid, File "/usr/local/lib/python3.10/site-packages/pyrogram/sync.py", line 78, in async_to_sync_wrap return asyncio.run_coroutine_threadsafe(coroutine, main_loop).result() File "/usr/local/lib/python3.10/concurrent/futures/_base.py", line 458, in result return self.__get_result() File "/usr/local/lib/python3.10/concurrent/futures/_base.py", line 403, in __get_result raise self._exception File "/usr/local/lib/python3.10/site-packages/pyrogram/methods/messages/send_video.py", line 227, in send_video r = await self.send( File "/usr/local/lib/python3.10/site-packages/pyrogram/methods/advanced/send.py", line 77, in send r = await self.session.send( File "/usr/local/lib/python3.10/site-packages/pyrogram/session/session.py", line 362, in send return await self._send(data, timeout=timeout) File "/usr/local/lib/python3.10/site-packages/pyrogram/session/session.py", line 332, in _send RPCError.raise_it(result, type(data)) File "/usr/local/lib/python3.10/site-packages/pyrogram/errors/rpc_error.py", line 80, in raise_it raise getattr( pyrogram.errors.exceptions.bad_request_400.BadRequest: Telegram says: [400 Bad Request] - [400 ENTITY_BOUNDS_INVALID] (caused by "messages.SendMedia") [2022-11-29 10:02:14 tasks.py:127 E] Failed to forward message Telegram says: [400 Bad Request] - [400 ENTITY_BOUNDS_INVALID] (caused by "messages.SendMedia") [2022-11-29 10:02:14 db.py:69 I] Setting metrics: cache_miss

    I try many times always got this error on cached link. Anyone got this ?

    opened by dlcvietnam 8
  • The subscription doesn't work

    The subscription doesn't work

    Error:

    Traceback (most recent call last):
      File "/ytdlbot/ytdlbot/ytdl_bot.py", line 111, in subscribe_handler
        result = vip.subscribe_channel(chat_id, link)
      File "/ytdlbot/ytdlbot/limit.py", line 86, in subscribe_channel
        data = self.get_channel_info(share_link)
      File "/ytdlbot/ytdlbot/limit.py", line 137, in get_channel_info
        channel_id = canonical_link.split("https://www.youtube.com/channel/")[1]
    IndexError: list index out of range
    
    bug 
    opened by Maxdeso 7
  • Docker-compose youtube subscription not working

    Docker-compose youtube subscription not working

    I installed bot using docker-compose, mysql, redis.

    Subscribe to youtube and ping does not work. Tell me, please, what could be the problem?

    Thank you!

    Errors when adding a subscription:

    ytdl_1 | [2022-04-14 17:42:32 limit.py:162 I] Latest video rk3OitqWCog from Alexandr Plushev ytdl_1 | [2022-04-14 17:42:32 dispatcher.py:235 E] (1136, "Column count doesn't match value count at row 1") ytdl_1 | Traceback (most recent call last): ytdl_1 | File "/usr/local/lib/python3.9/site-packages/pyrogram/dispatcher.py", line 224, in handler_worker ytdl_1 | await self.loop.run_in_executor( ytdl_1 | File "/usr/local/lib/python3.9/concurrent/futures/thread.py", line 58, in run ytdl_1 | result = self.fn(*self.args, **self.kwargs) ytdl_1 | File "/ytdlbot/ytdlbot/ytdl_bot.py", line 111, in subscribe_handler ytdl_1 | result = vip.subscribe_channel(chat_id, link) ytdl_1 | File "/ytdlbot/ytdlbot/limit.py", line 95, in subscribe_channel ytdl_1 | self.cur.execute("INSERT INTO subscribe values(%s,%s)", (user_id, channel_id)) ytdl_1 | File "/usr/local/lib/python3.9/site-packages/pymysql/cursors.py", line 148, in execute ytdl_1 | result = self._query(query) ytdl_1 | File "/usr/local/lib/python3.9/site-packages/pymysql/cursors.py", line 310, in _query ytdl_1 | conn.query(q) ytdl_1 | File "/usr/local/lib/python3.9/site-packages/pymysql/connections.py", line 548, in query ytdl_1 | self._affected_rows = self._read_query_result(unbuffered=unbuffered) ytdl_1 | File "/usr/local/lib/python3.9/site-packages/pymysql/connections.py", line 775, in _read_query_result ytdl_1 | result.read() ytdl_1 | File "/usr/local/lib/python3.9/site-packages/pymysql/connections.py", line 1156, in read ytdl_1 | first_packet = self.connection._read_packet() ytdl_1 | File "/usr/local/lib/python3.9/site-packages/pymysql/connections.py", line 725, in _read_packet ytdl_1 | packet.raise_for_error() ytdl_1 | File "/usr/local/lib/python3.9/site-packages/pymysql/protocol.py", line 221, in raise_for_error ytdl_1 | err.raise_mysql_exception(self._data) ytdl_1 | File "/usr/local/lib/python3.9/site-packages/pymysql/err.py", line 143, in raise_mysql_exception ytdl_1 | raise errorclass(errno, errval) ytdl_1 | pymysql.err.OperationalError: (1136, "Column count doesn't match value count at row 1")

    Error when "ping":

    ytdl_1 | [2022-04-14 17:48:36 dispatcher.py:235 E] Telegram says: [400 MESSAGE_TOO_LONG] - The message text is over 4096 characters (caused by "messages.SendMessage") ytdl_1 | Traceback (most recent call last): ytdl_1 | File "/usr/local/lib/python3.9/site-packages/pyrogram/dispatcher.py", line 224, in handler_worker ytdl_1 | await self.loop.run_in_executor( ytdl_1 | File "/usr/local/lib/python3.9/concurrent/futures/thread.py", line 58, in run ytdl_1 | result = self.fn(*self.args, **self.kwargs) ytdl_1 | File "/ytdlbot/ytdlbot/ytdl_bot.py", line 167, in ping_handler ytdl_1 | client.send_message(chat_id, f"{bot_info}") ytdl_1 | File "/usr/local/lib/python3.9/site-packages/pyrogram/sync.py", line 78, in async_to_sync_wrap ytdl_1 | return asyncio.run_coroutine_threadsafe(coroutine, main_loop).result() ytdl_1 | File "/usr/local/lib/python3.9/concurrent/futures/_base.py", line 446, in result ytdl_1 | return self.__get_result() ytdl_1 | File "/usr/local/lib/python3.9/concurrent/futures/_base.py", line 391, in __get_result ytdl_1 | raise self._exception ytdl_1 | File "/usr/local/lib/python3.9/site-packages/pyrogram/methods/messages/send_message.py", line 128, in send_message ytdl_1 | r = await self.send( ytdl_1 | File "/usr/local/lib/python3.9/site-packages/pyrogram/methods/advanced/send.py", line 77, in send ytdl_1 | r = await self.session.send( ytdl_1 | File "/usr/local/lib/python3.9/site-packages/pyrogram/session/session.py", line 362, in send ytdl_1 | return await self._send(data, timeout=timeout) ytdl_1 | File "/usr/local/lib/python3.9/site-packages/pyrogram/session/session.py", line 332, in _send ytdl_1 | RPCError.raise_it(result, type(data)) ytdl_1 | File "/usr/local/lib/python3.9/site-packages/pyrogram/errors/rpc_error.py", line 91, in raise_it ytdl_1 | raise getattr( ytdl_1 | pyrogram.errors.exceptions.bad_request_400.MessageTooLong: Telegram says: [400 MESSAGE_TOO_LONG] - The message text is over 4096 characters (caused by "messages.SendMessage")

    bug question 
    opened by apa4h 6
  • Bot going not well

    Bot going not well

    It seems the bot doesn't run well on my server. I don't know where goes wrong. My server OS is CentOS 8.5,python's version is 3.6.8

    when I send '/about' command ,the bot replies the repo link normally. when send '/ping' command , error message is :

    Telegram says: [400 MESSAGE_TOO_LONG] - The message text is over 4096 characters (caused by "messages.SendMessage")
    

    When send a video link or '/setting' command , error message is as follows:

    [2022-04-07 09:20:54 dispatcher.py:136 I] Started 100 HandlerTasks
    [2022-04-07 09:21:01 dispatcher.py:235 E] module 'six' has no attribute 'ensure_str'
    Traceback (most recent call last):
      File "/usr/local/lib64/python3.6/site-packages/pyrogram/dispatcher.py", line 228, in handler_worker
        *args
      File "/usr/lib64/python3.6/concurrent/futures/thread.py", line 56, in run
        result = self.fn(*self.args, **self.kwargs)
      File "ytdl_bot.py", line 76, in wrapper
        return func(client, message)
      File "ytdl_bot.py", line 265, in download_handler
        red.user_count(chat_id)
      File "/root/ytdlbot/ytdlbot/db.py", line 133, in user_count
        self.r.hincrby("metrics", user_id)
      File "/usr/local/lib/python3.6/site-packages/redis/commands/core.py", line 3717, in hincrby
        return self.execute_command("HINCRBY", name, key, amount)
      File "/usr/local/lib/python3.6/site-packages/redis/client.py", line 1180, in execute_command
        lambda error: self._disconnect_raise(conn, error),
      File "/usr/local/lib/python3.6/site-packages/redis/retry.py", line 45, in call_with_retry
        return do()
      File "/usr/local/lib/python3.6/site-packages/redis/client.py", line 1178, in <lambda>
        conn, command_name, *args, **options
      File "/usr/local/lib/python3.6/site-packages/redis/client.py", line 1152, in _send_command_parse_response
        conn.send_command(*args)
      File "/usr/local/lib/python3.6/site-packages/redis/connection.py", line 796, in send_command
        self.pack_command(*args), check_health=kwargs.get("check_health", True)
      File "/usr/local/lib/python3.6/site-packages/redis/connection.py", line 777, in send_packed_command
        self._sock.sendall(item)
      File "/usr/local/lib/python3.6/site-packages/fakeredis/_server.py", line 836, in sendall
        self._parser.send(data)
      File "/usr/local/lib/python3.6/site-packages/fakeredis/_server.py", line 753, in _parse_commands
        self._process_command(fields)
      File "/usr/local/lib/python3.6/site-packages/fakeredis/_server.py", line 843, in _process_command
        func, func_name = self._name_to_func(fields[0])
      File "/usr/local/lib/python3.6/site-packages/fakeredis/_server.py", line 822, in _name_to_func
        name = six.ensure_str(name, encoding='utf-8', errors='replace')
    AttributeError: module 'six' has no attribute 'ensure_str'
    ^C[2022-04-07 09:21:22 idle.py:77 I] Stop signal received (SIGINT). Exiting...
    [2022-04-07 09:21:23 dispatcher.py:149 I] Stopped 100 HandlerTasks
    [2022-04-07 09:21:23 session.py:269 I] PingTask stopped
    [2022-04-07 09:21:23 connection.py:77 I] Disconnected
    [2022-04-07 09:21:23 session.py:288 I] NetworkTask stopped
    [2022-04-07 09:21:23 session.py:174 I] Session stopped
    
    opened by gtjl12 6
  • Video Resolution Problem

    Video Resolution Problem

    I think the bot sends you the video in compressed form which lowers the video quality, can you provide an option so that the bot send the video uncompressed with the video's highest resolution. Telegram has that default compressing option which compresses the video to go fast but the thing I want is that there should be a option to choose where I want compressed or uncompressed video. Hopefully this will be added!

    opened by AdityaDas5501 6
  • docker image builder fails at

    docker image builder fails at "build and push step"

    /usr/bin/docker buildx build --cache-from type=local,src=/tmp/.buildx-cache --cache-to type=local,dest=/tmp/.buildx-cache-new,mode=max --iidfile /tmp/docker-build-push-GfE4m1/iidfile --platform linux/arm,linux/amd64,linux/arm64 --tag ***/ --tag ghcr.io/ --metadata-file /tmp/docker-build-push-GfE4m1/metadata-file --push .  
    error: invalid tag "***/": invalid reference format  
    Error: buildx failed with: error: invalid tag "***/": invalid reference format
    
    opened by EDM115 5
  • Heroku Support

    Heroku Support

    Hi, I checked a lot of bots that are not working for Dailymotion but only yours is working. Can you please make it possible to deploy to Heroku? As I know nothing python so it's not possible for me to add Heroku support. I don't want to abuse the bot hosted by yourself 😅

    enhancement 
    opened by UsamaKarim 5
  • Timeout connecting to server

    Timeout connecting to server

    I'm trying for setup worker on other vps. Connected to redis broke and mysql public port for testing. But always got error Timeout connecting to server as log Do you have full guide for setup Celery?

    [2022-11-12 01:10:28,335: WARNING/MainProcess] 
    [download]   0.0% of  136.15MiB at  269.70KiB/s ETA 08:44
    [2022-11-12 01:10:36,007: ERROR/MainProcess] Download failed for https://fb.watch/gKe234YysT/ 
    [2022-11-12 01:10:36,008: INFO/MainProcess] Downloading for https://fb.watch/gKe234YysT/ with format bestvideo[vcodec^=avc]+bestaudio[acodec^=mp4a]/best[vcodec^=avc]/best
    [2022-11-12 01:10:38,011: WARNING/MainProcess] 
    [download]   0.0% of  136.15MiB at  323.14KiB/s ETA 07:13
    [2022-11-12 01:10:45,734: ERROR/MainProcess] Download failed for https://fb.watch/gKe234YysT/ 
    [2022-11-12 01:10:45,734: INFO/MainProcess] Downloading for https://fb.watch/gKe234YysT/ with format None
    [2022-11-12 01:10:47,660: WARNING/MainProcess] 
    [download]   0.0% of  136.15MiB at   27.71KiB/s ETA 01:23:55
    [2022-11-12 01:10:55,462: ERROR/MainProcess] Download failed for https://fb.watch/gKe234YysT/ 
    [2022-11-12 01:10:55,462: INFO/MainProcess] https://fb.watch/gKe234YysT/ - {'status': False, 'error': 'Timeout connecting to server', 'filepath': []}
    [2022-11-12 01:10:55,462: INFO/MainProcess] Download complete.
    [2022-11-12 01:10:55,967: INFO/MainProcess] YouTube celery tasks ended.
    
    opened by dlcvietnam 4
  • 400 API_ID_INVALID(api_id/api_hash combination is invalid)

    400 API_ID_INVALID(api_id/api_hash combination is invalid)

    Hi, thanks for offering so amazing bot. Unfortunately I met a problem. I got my api_id and api_hash from https://my.telegram.org/apps, checked many times and I'm sure they are right.

    App api_id:13****** App api_hash:9e7**************************e21 DC 2

    I put them to app.json and ran ytdl_bot.py, finally an error occurred:

    pyrogram.errors.exceptions.bad_request_400.ApiIdInvalid: Telegram says: [400 API_ID_INVALID] - The api_id/api_hash combination is invalid (caused by "auth.ImportBotAuthorization")

    I've googled that, turned out to be Telegram's fault. API ID that over 5 digits may goes wrong in combination. Telegram said they've fixed this problem but not well for me.

    https://github.com/LonamiWebs/Telethon/issues/46 https://github.com/LonamiWebs/Telethon/issues/836 https://github.com/steavy29/Telegram.Net/issues/27

    Is there anything I did wrong?Any suggestions ? By the way, my api_id is 8 digit.

    opened by gtjl12 4
  • parsing youtube-dl flags/parameters/commands

    parsing youtube-dl flags/parameters/commands

    Hi I have a suggestion whcih might be useful! The ability to send flags/commands to youtube-dl to get responses or to get a specific file. for example send -f 1640 --hls-prefer-native -c -o "file.mp4" to get a specific resolution of HLS file or to send -F and get a reply back with list of availbale formats.

    wontfix 
    opened by A5DkjGQUZx 0
  • Add all thumbnail upload support

    Add all thumbnail upload support

    I'm using old TG Bot (https://github.com/Tellybots/Uploader-Bot-V2) and can send all Image thumbnail after download with --write-all-thumbnails option agrument. Can you support it?

    question 
    opened by dlcvietnam 4
Owner
Telegram Bot Collection
Telegram Bot collection developed by @BennyThink
Telegram Bot Collection
Telegram bot to stream videos in telegram voicechat for both groups and channels. Supports live strams, YouTube videos and telegram media.

Telegram bot to stream videos in telegram voicechat for both groups and channels. Supports live strams, YouTube videos and telegram media.

SUBIN 449 Dec 27, 2022
📢 Video Chat Stream Telegram Bot. Can ⏳ Stream Live Videos, Radios, YouTube Videos & Telegram Video Files On Your Video Chat Of Channels & Groups !

Telegram Video Chat Bot (Beta) ?? Video Chat Stream Telegram Bot ?? Can Stream Live Videos, Radios, YouTube Videos & Telegram Video Files On Your Vide

brut✘⁶⁹ // ユスフ 15 Dec 24, 2022
A Telegram bot to download youtube playlists and upload them to telegram. (may be slow becoz youtube limitations)

YTPlaylistDL ?? A Telegram bot to download youtube playlists and upload them to telegram. (may be slow becoz youtube limitations) ?? Follow me and sta

Anjana Madu 43 Dec 28, 2022
Telegram Group Calls Streaming bot with some useful features, written in Python with Pyrogram and Py-Tgcalls. Supporting platforms like Youtube, Spotify, Resso, AppleMusic, Soundcloud and M3u8 Links.

Yukki Music Bot Yukki Music Bot is a Powerful Telegram Music+Video Bot written in Python using Pyrogram and Py-Tgcalls by which you can stream songs,

Team Yukki 996 Dec 28, 2022
Command-line program to download videos from YouTube.com and other video sites

youtube-dl - download videos from youtube.com or other video platforms INSTALLATION DESCRIPTION OPTIONS CONFIGURATION OUTPUT TEMPLATE FORMAT SELECTION

youtube-dl 116.4k Jan 7, 2023
Telegram PHub Bot using ARQ Api and Pyrogram. This Bot can Download and Send PHub HQ videos in Telegram using ARQ API.

Tg_PHub_Bot Telegram PHub Bot using ARQ Api and Pyrogram. This Bot can Download and Send PHub HQ videos in Telegram using ARQ API. OS Support All linu

TheProgrammerCat 13 Oct 21, 2022
Telegram bot to trim and download videos from youtube.

Inline-YouTube-Trim-Bot Telegram bot to trim and download youtube videos Deploy You can deploy this bot anywhere. Demo - YouTubeBot Required Variables

SUBIN 56 Dec 11, 2022
Experimental bridges between Telegram calls and other platforms.

Bridges by Calls Music Experimental bridges between Telegram calls and other platforms. Current bridges Bridge 1 (YouTube, Twitch, Facebook, etc...) B

Calls Music 14 Oct 8, 2022
A simple telegram Bot, Upload Media File| video To telegram using the direct download link. (youtube, Mediafire, google drive, mega drive, etc)

URL-Uploader (Bot) A Bot Upload file|video To Telegram using given Links. Features: ?? Only Auth Users (AUTH_USERS) Can Use The Bot ?? Upload YTDL Sup

Hash Minner 18 Dec 17, 2022
Telegram Userbot to steram youtube live or Youtube vido in telegram vc by help of pytgcalls

TGVCVidioPlayerUB Telegram Userbot to steram youtube live or youtube vidio in telegram vc by help of pytgcalls Commands =>> Vidio Playing ?? stream :

Achu biju 3 Oct 28, 2022
JAKYM, Just Another Konsole YouTube-Music. A command line based Youtube music player written in Python with spotify and youtube playlist support

Just Another Konsole YouTube-Music Overview I wanted to create this application so that I could use the command line to play music easily. I often pla

Mayank Jha 73 Jan 1, 2023
A Telegram Bot to Play Audio in Voice Chats With Youtube and Deezer support. Supports Live streaming from youtube Supports Mega Radio Fm Streamings

Bot To Stream Musics on PyTGcalls with Channel Support. A Telegram Bot to Play Audio in Voice Chats With Supports Live streaming from youtube and Mega

Shamil Habeeb 37 Dec 15, 2022
A Telegram bot to download posts, videos, reels, IGTV and a user profile picture from Instagram!

Telegram Bot A telegram bot to download media from Instagram! No API Key or Login Needed! Requirements You must have python installed (of course) You

Simon Farah 2 Apr 10, 2022
An youtube videos thumbnail downloader telegram bot.

YouTube-Thumbnail-Downloader An youtube videos thumbnail downloader telegram bot. Made with Python3 (C) @FayasNoushad Copyright permission under MIT L

Fayas Noushad 40 Oct 21, 2022
Telegram bot to clip youtube videos

youtube-clipper-bot Telegram bot to clip youtube videos How to deploy? Create a file called config.env BOT_TOKEN: Provide your bot token generated by

Shivam Jha 11 Dec 10, 2022
Python bot for send videos of a Youtube channel to a telegram group , channel or chat

py_youtube_to_telegram Usage: If you want to install ytt and use it, run this command: sudo sh -c "$(curl -fsSL https://raw.githubusercontent.com/nima

Nima Fanniasl 8 Nov 22, 2022
A Telegram bot for Download songs in mp3 format from YouTube and Extract lyrics from Genius.com ❤️

MeudsaMusic A Telegram bot for Download songs in mp3 format from YouTube and Extract lyrics from Genius.com ❤️ Commands Reach @MedusaMusic on Telegram

Bibee 14 Oct 6, 2022
An Telegram Bot By @AsmSafone To Stream Videos in Telegram Voice Chat. This is Also The Source Code of The Bot Which is Being Used In @SafoTheBot Group! ❤️

Telegram Video Player Bot (Beta) An Telegram Bot By @AsmSafone To Stream Videos in Telegram Voice Chat. Special Features Supports Live Streaming From

SAF ONE 206 Jan 3, 2023