Simple Telegram Bot to Upload videos to Youtube written in Python3.
This is a simple hobby project which i was really curious about to impliment. This is a Telegram bot which uses Youtube Data API v3 to upload videos to Youtube. This bot uses OAuth 2.0 to connect to your Youtube Channel.
Pyrogram
Pyrogram is used to connect the bot with telegram servers.
Google Client API
Google Client API is used to connect the bot with Google and then with Youtube.
❗ This project requires Python3.7 (as this was written and tested with Python 3.7.3, try and see if it works with other versions)
Clone and setup virtual environment
$ git clone https://github.com/odysseusmax/utube.git
$ cd utube
$ virtualenv venv
$ source venv/bin/activate
Setup config.py
-
Head to Manage Apps and get your
API_ID
andAPI_HASH
, and save it at the respective positions inconfig.py
-
Head to Google console, create a new project named
Youtube Uploader
and enableAPI'S AND SERVISES
. Search forYOUTUBE DATA API v3
and enable the API. Go to Credentials page, select your projectYoutube Uploader
create a new credential withother
as type. Copy theCLIENT_ID
andCLIENT_SECRET
and paste them toconfig.py
-
Head to Bot Father, create new bot and paste the bot token to
BOT_TOKEN
-
Paste the bot owner's Telegram id to
BOT_OWNER
and addAUTH_USERS
if you need others to use your bot. -
All the contents of
config.py
must be kept secret as they contain sensitive informations
Install requirements
With all the above procedures done, its time to install our dependencies. Run :
$ pip3 install -r requirements.txt
Run bot
Lets run our bot for the first time!
$ python3 bot.py
If you did everything correctly, the bot should be running. Go do /start
to see if the bot is live or not. Follow the instructions provided by bot to setup authorisation and to start uploading.
Or the easy way of directly deploying to heroku
This project is actively maintained and will continue so until I'm tired of it.
-
With the Youtube Data API you are awarded with 10,000 points of requests. For one video upload it costs 1605 points, regardless of file size, which calculates to about 6 uploads daily. Once you have exhausted your daily points, you have to wait till daily reset. Resets happens at 0:00 PST, i.e. 12:30 IST. So make your uploads count.
-
Uploading copyright contents will leads to immediate blocking of the video, and will not be added to your
MyVideos
section of youtube. But still the video can be played directly through the link provided by the bot. -
All the videos are uploaded as private. You may change it after youtube processes the video.
Video Tutorial
Share the FeedBack and Suggestions with me. You can contact me Here