Coder Social home page Coder Social logo

odysseusmax / utube Goto Github PK

View Code? Open in Web Editor NEW
266.0 11.0 671.0 1009 KB

Telegram Bot for Youtube upload

Home Page: https://tx.me/youtubeitbot

License: GNU General Public License v3.0

Python 100.00%
telegram telegram-bot youtube youtube-upload python pyrogram uploader python37

utube's Introduction

Simple Telegram Bot to Upload videos to Youtube written in Python3.

Contents

Info

This is a simple hobby project which I was really curious about to implement. This is a Telegram bot which uses Youtube Data API v3 to upload videos to Youtube.

Libraries Used

Setup

โ— This project requires Python3.6 or higher

Clone and setup virtual environment

$ git clone https://github.com/odysseusmax/utube.git

$ cd utube

$ python3 -m venv venv

$ source venv/bin/activate

Environment Variables

  • 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 enable API'S AND SERVISES. Search for YOUTUBE DATA API v3 and enable the API. Go to Credentials page, select your project Youtube Uploader create a new credential with desktop as type. Copy the CLIENT_ID and CLIENT_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.

Install requirements

Run :

$ pip3 install -r requirements.txt

Run bot

Lets run our bot for the first time!

$ python3 -m bot

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

Deploy

Development Status

This project is actively maintained and will continue so until I'm tired of it.

Special notes

  • 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 and VIDEO_CATEGORY. You may change it after youtube processes the video.

Screenshots

Upload

Video Tutorial

Here's a YouTube tutorial video for deploying the bot on Heroku. Video Link.

Contact

You can contact me @odysseusmax.

License

Code released under GNU General Public License v3.0.

utube's People

Contributors

odysseusmax avatar spechide avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

utube's Issues

Fix the ERROR

-----> Building on the Heroku-22 stack
-----> Using buildpack: heroku/python
-----> Python app detected
-----> Using Python version specified in runtime.txt
! Requested runtime 'python-3.9.5' is not available for this stack (heroku-22).
! For supported versions, see: https://devcenter.heroku.com/articles/python-support
! Push rejected, failed to compile Python app.
! Push failed

Its a feature request

Kindly add link download support. Because, Telegram has only 2GB file limit. Somtimes, its not possible to upload a high resolution movie in youtube. If you can add direct link download support, it would be very helpful.
I mean the bot will download from a direct download link then upload it to YouTube. I think you understood my request.๐Ÿ˜…๐Ÿ™

--- Logging error ---

Traceback (most recent call last):
File "/app/.heroku/python/lib/python3.9/logging/init.py", line 1100, in emit
msg = self.format(record)
File "/app/.heroku/python/lib/python3.9/logging/init.py", line 943, in format
return fmt.format(record)
File "/app/.heroku/python/lib/python3.9/logging/init.py", line 678, in format
record.message = record.getMessage()
File "/app/.heroku/python/lib/python3.9/logging/init.py", line 368, in getMessage
msg = msg % self.args
TypeError: not all arguments converted during string formatting

Feature request: Upload reels.

There has been a nuclear increase in the popularity of reels. Would be great if this feature is implemented in the bot.

error pyrogram

Traceback (most recent call last): File "/nix/store/xf54733x4chbawkh1qvy9i1i4mlscy1c-python3-3.10.11/lib/python3.10/runpy.py", line 196, in _run_module_as_main return _run_code(code, main_globals, None, File "/nix/store/xf54733x4chbawkh1qvy9i1i4mlscy1c-python3-3.10.11/lib/python3.10/runpy.py", line 86, in _run_code exec(code, run_globals) File "/home/runner/utube/bot/__main__.py", line 13, in <module> UtubeBot().run() File "/home/runner/utube/.pythonlibs/lib/python3.10/site-packages/pyrogram/methods/utilities/run.py", line 84, in run self.start() File "/home/runner/utube/.pythonlibs/lib/python3.10/site-packages/pyrogram/sync.py", line 66, in async_to_sync_wrap return loop.run_until_complete(coroutine) File "/nix/store/xf54733x4chbawkh1qvy9i1i4mlscy1c-python3-3.10.11/lib/python3.10/asyncio/base_events.py", line 649, in run_until_complete return future.result() File "/home/runner/utube/.pythonlibs/lib/python3.10/site-packages/pyrogram/methods/utilities/start.py", line 58, in start is_authorized = await self.connect() File "/home/runner/utube/.pythonlibs/lib/python3.10/site-packages/pyrogram/methods/auth/connect.py", line 40, in connect await self.load_session() File "/home/runner/utube/.pythonlibs/lib/python3.10/site-packages/pyrogram/client.py", line 637, in load_session await Auth( File "/home/runner/utube/.pythonlibs/lib/python3.10/site-packages/pyrogram/session/auth.py", line 274, in create raise e File "/home/runner/utube/.pythonlibs/lib/python3.10/site-packages/pyrogram/session/auth.py", line 89, in create res_pq = await self.invoke(raw.functions.ReqPqMulti(nonce=nonce)) File "/home/runner/utube/.pythonlibs/lib/python3.10/site-packages/pyrogram/session/auth.py", line 67, in invoke return self.unpack(response) File "/home/runner/utube/.pythonlibs/lib/python3.10/site-packages/pyrogram/session/auth.py", line 60, in unpack return TLObject.read(b) File "/home/runner/utube/.pythonlibs/lib/python3.10/site-packages/pyrogram/raw/core/tl_object.py", line 33, in read return cast(TLObject, objects[int.from_bytes(b.read(4), "little")]).read(b, *args) KeyError: 0

Upload and rename at the same time

you know it's a very important feature to be add in your boat cause we upload videos on YouTube and title is the most important thing in YouTube so intelligence a video maybe in default and its origin name and with file extension so if he can rename the file name and edit the title before uploading it would be a great thing so please consider it

ValueError: Unknown storage engine

Has somebody solved this error before?

File "/usr/local/lib/python3.10/runpy.py", line 196, in _run_module_as_main
return _run_code(code, main_globals, None,
File "/usr/local/lib/python3.10/runpy.py", line 86, in _run_code
exec(code, run_globals)
File "/home/ankitinter9/bot/main.py", line 13, in
UtubeBot().run()
File "/home/ankitinter9/bot/utubebot.py", line 8, in init
super().init(
File "/home/ankitinter9/venv/lib/python3.10/site-packages/pyrogram/client.py", line 243, in init
raise ValueError("Unknown storage engine")
ValueError: Unknown storage engine
(venv) 12:27 ~ $ SESSION_NAME=lethargic_Charge
(venv) 12:27 ~ $ python -m bot
Traceback (most recent call last):
File "/usr/local/lib/python3.10/runpy.py", line 196, in _run_module_as_main
return _run_code(code, main_globals, None,
File "/usr/local/lib/python3.10/runpy.py", line 86, in _run_code
exec(code, run_globals)
File "/home/ankitinter9/bot/main.py", line 13, in
UtubeBot().run()
File "/home/ankitinter9/bot/utubebot.py", line 8, in init
super().init(
File "/home/ankitinter9/venv/lib/python3.10/site-packages/pyrogram/client.py", line 243, in init
raise ValueError("Unknown storage engine")
ValueError: Unknown storage engine

Termux support

Hi.. can i setup virtual env on termux?...For that should i download your git as zip...(im a noob
Screenshot_2019-08-12-10-59-13

Crashing

The app is keep crashing while im trying to upload larger files.
Can you guys add uploading status bar to show up the uploding prograss

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.