Skip to content

Commit

Permalink
Merge pull request #4 from mwood77/feature/twitch
Browse files Browse the repository at this point in the history
Feature/twitch
  • Loading branch information
mwood77 authored Aug 29, 2022
2 parents ad845db + 87c8e04 commit 8ef550f
Show file tree
Hide file tree
Showing 13 changed files with 1,494 additions and 124 deletions.
10 changes: 9 additions & 1 deletion .env.sample
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,13 @@
//
// DO NOT COMMIT THIS FILE TO YOUR SOURCE CONTROL

# PLAYER CONTROLLER
YOUTUBE_CONTROLLER=
TWITCH_CONTROLLER=

# YOUTUBE
LIVE_VIDEO_ID=
API_KEY=
LIVE_VIDEO_ID=

# TWITCH
TWITCH_CHANNEL=
7 changes: 3 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ node_modules/

# Distribution
build/*
resources/*

# Secrets
client_secret.json
Expand All @@ -15,9 +14,9 @@ sixtyforce.app
Super-Mario_64.z64

# macOS BS..
.DH_store
.DS_store
.DH_Store
.DS_Store

# Intellij BS..
.idea
.DS_Store
*.DS
14 changes: 10 additions & 4 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,21 @@
{
"version": "0.3.0",
"version": "0.4.0",
"configurations": [
{
"command": "npm run start-chat-logger",
"name": "run logger",
"command": "npm run start-yt",
"name": "youtube debug",
"request": "launch",
"type": "node-terminal"
},
{
"command": "npm run start-twitch",
"name": "twitch debug",
"request": "launch",
"type": "node-terminal"
},
{
"command": "npm run start-input-mapper",
"name": "run mapper",
"name": "debug input mapper",
"request": "launch",
"type": "node-terminal"
}
Expand Down
90 changes: 68 additions & 22 deletions README.MD
Original file line number Diff line number Diff line change
@@ -1,41 +1,87 @@
## Prerequisites:
# Twitch Vs Youtube
## What this is
This is a collection of applications which integrate with Twitch's IRC server and Youtube's Data V3 API, to provide near real time "player input."

Players participate by sending chat messages through Youtube LIVE or Twitch's chat box. Because of the division between chat parsers, this allows us to assign each platform a different input (controller);
you can have different platforms (or livestreams) play against one another, without any remote code execution.

## What this (guide) isn't
- I strongly advise that you have a basic understanding of JavaScript / Node before you use this
- You must figure out how you plan to interface this with other software (games, interactive software, microcontrollers, etc). There is a basic keyboard event emitter/mapper included.
- This was written with *nix systems in mind. It should be Windows compatible, but I haven't checked.

# Setup
1. Duplicate the `.env.sample` file and rename it to `.env`
- This new `.env` file will be gitignored, but **make sure you do not publicize any data contained in this file!**
1. Assign controllers to the stream/platform.
- Example where player 1 is youtube and player 2 is twitch
```properties
# PLAYER CONTROLLER
YOUTUBE_CONTROLLER=1
TWITCH_CONTROLLER=2
```
1. Install project dependencies:
```shell
npm install
```

## Youtube
1. Get your credentials:
- You'll need an OAuth2 cert from the Google Cloud. [Don't know how? Follow the Prerequisites and Step 1 of this tutorial](https://developers.google.com/youtube/v3/quickstart/nodejs)
- You'll need an OAuth2 cert from Google Cloud. [Don't know how? Follow the Prerequisites and Step 1 of this tutorial](https://developers.google.com/youtube/v3/quickstart/nodejs)
- You'll also need to generate an API key for this Google Cloud project. **Make sure to restrict the key to `YouTube Data API v3`**
2. Copy the cert you downloaded (the json file) in Step 1 to
1. Copy the cert you downloaded (the json file) in Step 1 to
```
~/community-plays/
```
Make sure the cert is named
```
client_secret.json
```
and not something like...
```
client_secret_sjkdhfalkjh2398y4u23ip4.....com.json
```
3. Install dependencies: `npm install`
4. Throw your API key into the `.env` file. See the following example:
- Make sure the cert is named `client_secret.json` and not something like `client_secret_sjkdhfalkjh2398y4u23ip4.....com.json`
1. Throw your API key into the `.env` file.
- See the following example:
```properties
API_KEY=YOUR_YOUTUBE_API_KEY
LIVE_VIDEO_ID=THE_ID_OF_THE_LIVE_VIDEO (ex. 36YnV9STBqc)
```
- The live video id can be taken out of the URL, but **it must be active and a livestream.** The id follows the `v=` parameter in the url.
```sh
Example:
https://www.youtube.com/watch?v=dQw4w9WgXcQ
Here the id is dQw4w9WgXcQ
```
1. Proceed to [Running a parser](#running-a-parser)
## Twitch
1. Get the id of the channel you wish to connect to. You can extract the id from the url.
```sh
Example:
https://www.twitch.tv/twitchplayspokemon
Here the id is twitchplayspokemon
```
API_KEY=YOUR_YOUTUBE_API_KEY
LIVE_VIDEO_ID=THE_ID_OF_THE_LIVE_VIDEO (ex. 36YnV9STBqc)
1. Add the channel id to the `.env` file
```properties
TWITCH_CHANNEL=YOUR_TWITCH_CHANNEL
```
5. Proceed to [Run it](#run-it)
1. Proceed to [Running a parser](#running-a-parser)
# Running a parser
## Run it
## Youtube
> If needed, you can delete your O2Auth token to force a new one.
> The token should be located at: `Users/{YOU}/super-secrets/youtube-nodejs-whatever.json`
> The token should be located at: `Users/{YOUR-USER}/.super-secrets/`
> If this is the first time you're running the application,
> you'll need to authorize it via google cloud. Simply run this application
> as normal, and follow the prompts that appear in your terminal. Make sure you paste the generated activation
> as normal and follow the prompts that appear in your terminal. Make sure you paste the generated activation
> hash back into your active terminal.
1. `npm run start-chat-logger`
1. `npm run start-yt`
* make sure your `LIVE_VIDEO_ID` and `API_KEY` are set in your `.env` file.
2. If prompted to generate new Auth token, do so. By default, this is stored at `Users/{YOUR-USER}/.super-secrets/`
2. If prompted to generate a new Auth token, do so. By default this is stored at `Users/{YOUR-USER}/.super-secrets/`
## Twitch
1. `npm run start-twitch`
## Generate random test data
# Generate random test data
```javascript
const cannedArray = ['LEFT', 'RIGHT', 'ENTER', 'UP', 'DOWN'];
const cannedAuthorArray = ['Aida Oksana 🔺️☆', 'K_A_N_G____ ', 'vaishali', '🌾🎶🎶', 'если не указано кому обращение значит этот вопрос ко всем'];
Expand Down
Loading

0 comments on commit 8ef550f

Please sign in to comment.