Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
offish authored Dec 5, 2020
1 parent 445e033 commit 141ad56
Showing 1 changed file with 31 additions and 34 deletions.
65 changes: 31 additions & 34 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@
[![Donate PayPal](https://img.shields.io/badge/donate-paypal-blue.svg)](https://www.paypal.me/0ffish)


Automatically make video compilations of the most viewed Twitch clips and upload it to YouTube using Python 3.
Automatically make video compilations of the most viewed Twitch clips and upload them to YouTube using Python 3.


## Installation
Download the repo as ZIP and unpack it somewhere accessible.
Download the repo as ZIP and unzip it somewhere accessible.

To install all the packages needed you need to run this command (has to be in
the right directory).
Expand All @@ -27,15 +27,14 @@ pip install -r requirements.txt
### Creating your Twitch Application
Go to https://dev.twitch.tv/console and register a new application.
The name of the application does not matter. Set "OAuth Redirect URLs" to https://twitchapps.com/tokengen/
Set category to Application Integration or Other.
Set category to "Application Integration" or "Other".
You will now see your Client ID, copy this ID.
Go to config.py under dist, find CLIENT_ID and paste it inside apostrophes.
Go to [`config.py`](twitchtube/config.py), find CLIENT_ID and paste it inside apostrophes.

### Getting your OAuth Token
Now head over to https://twitchapps.com/tokengen/
Paste in your Client ID, scopes does not matter in our case.
Click "Connect" and then authorize with Twitch.
Copy your OAuth Token, go to config.py, find OAUTH_TOKEN and paste it inside the apostrophes.
Now head over to https://twitchapps.com/tokengen/ and paste in your Client ID.
Scopes does not matter in our case. Click "Connect" and then authorize with Twitch.
Copy your OAuth Token, go to [`config.py`](twitchtube/config.py), find `OAUTH_TOKEN` and paste it inside the apostrophes.

### Creating your Google Project
Go to https://console.cloud.google.com/ and create a new project.
Expand All @@ -48,7 +47,7 @@ Search for "YouTube Data API v3" and click the first result.
Enable this API.

### Getting your client_secret
When you've clicked enable you should now be on the "Overview" tab.
When you have clicked "Enable" you should now be under the "Overview" tab.
Click "Credentials" and then "+ Create Credentials".
You will now see 3 options, click "OAuth client ID".
Now you might need to configure consent screen.
Expand All @@ -57,27 +56,25 @@ Write something in the application name field, might be wise to name it somethin
"YouTube Twitch Bot".
Now you will see your application, go to "Credentials" again and click "+ Create Credentials" and then "OAuth client ID".
Set application type to Desktop app and name it whatever.
Click Ok, and click the download icon.
Open the JSON file that gets downloaded, select everything and paste it into the client_secret file under dist.
Click "Ok", and then click the download icon.
Open the JSON file that gets downloaded, select everything in this fiel and paste it into the [`client_secret.json`](twitchtube/client_secret.json) file.

### Adding/removing games
If you want to add a game/category, you simply write the name of the game how it appears on Twitch inside the GAMES list in [`config.py`](twitchtube/config.py).
If you want to add Just Chatting for example GAMES should look like this:
If you want to add a game/category, you simply write the name of the game how it appears on Twitch inside the `GAMES` list in [`config.py`](twitchtube/config.py).
If you want to add Rust for example, `GAMES` should look like this:

```python
GAMES = ['Rust', 'Just Chatting', 'Team Fortress 2']
```

Last entry in the list must not have a comma.
Last entry in the list should not have a comma.

If only want to have 1 game/category GAMES, in this case Just Chatting it should look like this:
If you only want to have 1 game/category, `GAMES` should look like this:

```python
GAMES = ['Just Chatting']
```

**EVERY ENTRY IN GAMES MUST ALSO BE FOUND IN TAGS AND DESCRIPTIONS**

Example:

```python
Expand All @@ -94,20 +91,25 @@ DESCRIPTIONS = {

Counter-Strike: Global Offensive is currently not supported since folders can't include colons in their folder name.

## How it works
The script starts by checking every game listed in the config. It will then create a folder with
the current date as the name and inside of this folder it will create another folder for the
first game in the list (also specified in the config). It will send a request to Twitch's API
and ask for the top 100 clips for that game that day. It will then save this data in a JSON
file named `clips.json`. It will simply loop through the clip URLs and download each clip
till it reaches the limit specifed in the config. When the limit it reached (the video is
long enough) it will take all the mp4 files and concatenate these into 1 video. When this
video is done rendering, it will upload it to YouTube. When the video is uploaded it will
create a new folder for the next game in the list (if any) with the game title as folder
name and redo the process written above.
## Explanation
The script starts off by checking every game listed in the config. It will then create a folder with
the current date as folder name and inside this folder, it will create another folder for the
with the current game as folder name. It will send a request to Twitch's Kraken API
and ask for the top 100 clips. It will then save this data in a JSON
file called `clips.json`. It will loop through the clip URLs and download each clip
till it reaches the limit specifed in the config. When the limit is reached, which means the video is
long enough it will take all the mp4 files in the game folder and doncatenete these clips into one
video (if specified). If time limit given is too big, it will just continue anyways. When the video is
done rendering, it will upload it to YouTube (if specified). When the video is uploaded it will delete
the clips (if specified) and create a new folder for the next game in the `GAMES` list (if any) and
redo the process written above.

## Running
To run the script run `python main.py` in command prompt (must be in the correct folder).
To run the script run this command (must be in the correct folder).

```
python main.py
```

## Example
[Here](https://www.youtube.com/channel/UCd0wttXr03lIcTLv38U5d-w) is an example of how the videos look like on YouTube. Majority of these videos are made using
Expand Down Expand Up @@ -138,8 +140,3 @@ 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.





0 comments on commit 141ad56

Please sign in to comment.