Automatically make video compilations of the most viewed Twitch clips, and upload them to YouTube using Python 3.
Example of making a video through terminal
python main.py --data "g Just Chatting, c xQcOW, c Trainwreckstv" --client_id "1hq8ektpki36w5kn37mluioungyqjo" --oauth_token "9f5einm9qtp0bj4m9l1ykevpwdn98o" --duration 10.5 --resolution 1080 1920 --title "Top Just Chatting, xQc and Trainwrecks Twitch Clips Today" --tags "xqc, trainwrecks, twitch clips, xqc twitch, trainwrecks twitch"
g indicates game,
c indicates channel. You can also use
Every parameter that is not specified, will default to an assigned value in
Example of running with only default values:
DATA = ["channel maskenissen"] CLIENT_ID = "1hq8ektpki36w5kn37mluioungyqjo" # Twitch Client ID OAUTH_TOKEN = "9f5einm9qtp0bj4m9l1ykevpwdn98o" # Twitch OAuth Token PERIOD = "day" # day, week, month or all LANGUAGE = "en" # en, es, th etc. LIMIT = 100 # 1-100 ...
You can also run the bot from a Python file like
from time import sleep from twitchtube.video import make_video from twitchtube.utils import get_path while True: make_video( data=["channel xQcOW", "game Just Chatting"], path=get_path(), client_id="1hq8ektpki36w5kn37mluioungyqjo", # example client id (fake) oauth_token="9f5einm9qtp0bj4m9l1ykevpwdn98o", # example token (fake) video_length=10.5, # minutes as float resolution=(1080, 1920), # height x width frames=60, period="day", # most viewed clips today ) sleep(24 * 60 * 60) # make a video daily
These are all the parameters
def make_video( data: list = DATA, blacklist: list = BLACKLIST, # other path: str = get_path(), check_version: bool = CHECK_VERSION, # twitch client_id: str = CLIENT_ID, oauth_token: str = OAUTH_TOKEN, period: str = PERIOD, language: str = LANGUAGE, limit: int = LIMIT, # selenium profile_path: str = ROOT_PROFILE_PATH, sleep: int = SLEEP, headless: bool = HEADLESS, debug: bool = DEBUG, # video options render_video: bool = RENDER_VIDEO, file_name: str = FILE_NAME, resolution: tuple = RESOLUTION, frames: int = FRAMES, video_length: float = VIDEO_LENGTH, resize_clips: bool = RESIZE_CLIPS, enable_intro: bool = ENABLE_INTRO, resize_intro: bool = RESIZE_INTRO, intro_path: str = INTRO_FILE_PATH, enable_transition: bool = ENABLE_TRANSITION, resize_transition: bool = RESIZE_TRANSITION, transition_path: str = TRANSITION_FILE_PATH, enable_outro: bool = ENABLE_OUTRO, resize_outro: bool = RESIZE_OUTRO, outro_path: str = OUTRO_FILE_PATH, # other options save_file: bool = SAVE_TO_FILE, save_file_name: str = SAVE_FILE_NAME, upload_video: bool = UPLOAD_TO_YOUTUBE, delete_clips: bool = DELETE_CLIPS, # youtube title: str = TITLE, description: str = DESCRIPTION, thumbnail: str = THUMBNAIL, tags: list = TAGS, ) -> None: ...
Information about every parameter can be found in
Download the repo as ZIP and unzip it somewhere accessible, or use git.
To install all the packages needed, you have to run this command, by being in the same directory as the
main.py files are.
pip install -r requirements.txt
You can now check if it works by running this command in the terminal:
If geckodriver has been added to PATH, you should now see the current version number and some licensing text.
Set category to "Application Integration" or "Other".
Copy the Client ID and go to
CLIENT_ID and paste it inside apostrophes.
Now head over to https://twitchapps.com/tokengen/ and paste in your Client ID, which you just copied. Scopes does not matter in our case. Click "Connect" and then authorize with Twitch.
Copy your OAuth Token and go to
OAUTH_TOKEN and paste it inside the apostrophes.
Open Firefox and create a new profile for Selenium, (this is not needed, but highly recommended). Go to
about:profiles and click "Create a New profile", name it "Selenium" or whatever.
Copy the "Root Directory" path of that profile and paste it into the
config.py. Now click "Launch profile in new browser". Go to YouTube and login to the account you want to use with twitchtube.
Don't use Selenium as your default profile.
You can now save your
If you're having issues uploading try to update opplast.
pip install --upgrade opplast
Sometimes YouTube is weird, so trying multiple times might work.
headless=False to see what it's actually doing. Increasing
sleep might also work.
If you have configured everything correctly, and are still running into errors, leave a detailed issue here.
Copyright (c) 2020 offish
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.