Simple Telegram Bot to Upload videos to Youtube written in Python3.
This project was initially created by Christy Roys. I have recently modified the code, incorporating additional functions, commands, and ensuring compatibility with the latest versions of libraries.
The project involves the development of a Telegram bot utilizing the Youtube Data API v3. The primary purpose of the bot is to facilitate the seamless uploading of videos to YouTube.
For more details about the original project, you can refer to the GitHub repository.
Note: The modifications made to the code aim to enhance its functionality and ensure compatibility with the most recent library versions.
STEP : 1 Clone the git repository with Runing :
git clone https://github.com/alpha-alexxx/YoutubeUploader
STEP : 2 Go to the repository directory.
cd YoutubeUploader
Now set Environment Variables in root folder with .env file.
STEP : 3 Create environment file to save environments.
cp .env.sample .env
Add the following lines to it, replacing API_ID
, API_HASH
, BOT_TOKEN
,CLIENT_ID
,CLIENT_SECRET
,BOT_OWNER
,AUTH_USERS
,UPLOAD_MODE
& VIDEO_CATEGORY
;
.env File Example:
BOT_TOKEN="YOUR_BOT_TOKEN_HERE"
SESSION_NAME="your_session_name_here"
API_ID="your_api_id_here"
API_HASH="your_api_hash_here"
CLIENT_ID="your_client_id_here"
CLIENT_SECRET="your_client_secret_here"
BOT_OWNER="your_bot_owner_user_id_here"
AUTH_USERS="comma_separated_list_of_user_ids"
VIDEO_DESCRIPTION="This video is uploaded from telegram bot (example)"
VIDEO_CATEGORY="your_video_category_id_here(specific if you needed)"
UPLOAD_MODE="your_upload_mode_here"
BOT_TOKEN
(Required) - Get your bot token from Bot Father.SESSION_NAME
(optional) - Your bot's username.API_ID
(Required) - Your telegram api id, get from Manage Apps.API_HASH
(Required) - Your telegram api hash, get from Manage Apps.CLIENT_ID
(Required) - Your google client id.CLIENT_SECRET
(Required) - Your google client secret.BOT_OWNER
(Required) - Telegram id of bot owner.AUTH_USERS
(optional) - Telegram id's of authorised users, separated by,
.VIDEO_DESCRIPTION
(optional) - Any default description to be aded to the video.VIDEO_CATEGORY
(optional) - YouTube's video category id. If not specified or specified id is invalid, category id will be selected randomly.VIDEO_TITLE_PREFIX
(optional) - Any prefix to be added to the video's title.VIDEO_TITLE_SUFFIX
(optional) - Any suffix to be added to the video's title.UPLOAD_MODE
(optional) - The video's privacy status. Valid values for this property are:private
,public
,unlisted
.DEBUG
(optional) - Whether to set logging level to DEBUG. If set logging will be set to DEBUG level, else INFO level.
Getting your CLIENT_ID
and CLIENT_SECRET
- 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 withdesktop
as type. Copy theCLIENT_ID
andCLIENT_SECRET
. - You have to verify your application with google, only then you can make the uploaded videos public. YouTube changed its developer policy, and videos uploaded using unverfied applications will be kept private.
Step : 4 Install requirements with running below command:
pip3 install -r requirements.txt
Step : 5 Run bot
Lets run our bot for the first time!
python3 -m bot
Certainly! Here's a more professional version:
Upon successful completion of the setup, the bot should be operational. Execute the /start
command to verify the bot's live status. Follow the instructions provided by the bot to establish authorization and commence the uploading process.
🚀 Active Development: I am currently actively working on this project, implementing new features, fixing issues, and making continuous improvements. Your contributions and feedback are always welcome!
-
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.
-
By default, all the videos are uploaded as private with random category id unless you provide
UPLOAD_MODE
andVIDEO_CATEGORY
. You may change it after youtube processes the video.
Edit the bot in BotFather with command /help
⮞ /mybots
⮞ choose your bot by the username ⮞ click on Edit bot ⮞ click on edit commands ⮞ copy the below code and paste there and save it.
start - Start the bot.
login - Log in to the bot
upload - Initiate the upload process of video
help - Get assistance or command information
logout - Log out from the bot
refresh - Refresh or update auth token
- Creator - - Christy Roys
- Contributor - - Ankit Kumar
Code released under GNU General Public License v3.0.