IBM/rotisserie

Name: rotisserie

Owner: International Business Machines

Description: automagically view the most interesting PlayerUnknown's Battlegrounds streams on Twitch.

Created: 2017-07-05 16:15:00.0

Updated: 2018-05-22 17:37:48.0

Pushed: 2018-05-23 15:39:44.0

Homepage: https://rotisserie.tv

Size: 4037

Language: JavaScript

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

rotisserie

Build Status License

Read this in other languages: ??.

LIVE NOW

rotisserie takes the concept of the red zone in American football and applies it to the popular online battle royale game PLAYERUNKNOWN'S BATTLEGROUNDS. The idea is to always be viewing the most popular PUBG twitch stream with the least amount of people alive in-game.

Included Component
Featured Technologies

Prerequisite

The following pieces of software are required to run rotisserie locally:

You can install these dependencies with one of the two following commands, depending on your os:

sudo apt-get install tesseract-ocr ffmpeg imagemagick
pip install livestreamer
brew install tesseract ffmpeg imagemagick
pip install livestreamer

Create a Kubernetes cluster with either Minikube for local testing, or with IBM Bluemix Container Service to deploy in cloud. The code here is regularly tested against Kubernetes Cluster from Bluemix Container Service using Travis.

Steps

  1. Get an OAuth Token for livestreamer
  2. Setting up Environment Variables
  3. Build the images
  4. Deploy locally
  5. Deploy using Docker
  6. Deploy using Kubernetes
1. Getting an OAuth Token for Twitch
  1. On a machine with a browser installed, run the following:
livestreamer --twitch-oauth-authenticate
  1. A browser window will open, and prompt you to authorize livestreamer to use your twitch account. Click Authorize.

  2. Your browser will refresh, and a page saying “SORRY, this page does not exist yet” will appear. Ignore this. In your address bar, there will be a callback URL with access_token=<TOKEN>. This is your OAuth token, copy it down and proceed to the next section.

2. Setting up Environment Variables
export docker_username="YOUR_DOCKER_USERNAME"
export token="YOUR_OAUTH_TOKEN"

You must create an app in your Twitch account using the developer mode (https://dev.twitch.tv/) to retrieve the clientID

export clientID="YOUR_CLIENT_ID"
export ROTISSERIE_OCR_SERVICE_HOST="localhost"
export ROTISSERIE_OCR_SERVICE_PORT="3001"
3. Build the Images
it clone https://github.com/IBM/rotisserie.git
d rotisserie
cker build -t $docker_username/rotisserie-ocr -f deploy/images/ocr.Dockerfile .
cker build -t $docker_username/rotisserie-app -f deploy/images/app.Dockerfile .
cker push $docker_username/rotisserie-ocr
cker push $docker_username/rotisserie-app
4. Running It Locally
npm install .
node ocr.js 2>&1 >/dev/null &
node app.js

Now you can open a browser and navigate to http://localhost:3000 to watch rotisserie.

5. Running in a Container

You can also run rotisserie in a docker container.

docker run -d -p 3001:3001 --name rotisserie-ocr $docker_username/rotisserie-ocr
docker run -d -p 3000:3000 --name rotisserie-app -e ROTISSERIE_OCR_SERVICE_HOST=$ROTISSERIE_OCR_SERVICE_HOST -e ROTISSERIE_OCR_SERVICE_PORT=$ROTISSERIE_OCR_SERVICE_PORT -e token=$token -e clientID=$clientID $docker_username/rotisserie-app

Now you can open a browser and navigate to http://localhost:3000 to watch rotisserie.

6. Running in Kubernetes

note: Ensure your $OCR_HOST environment variable is set to the cluster_public_ip:3001.

  1. Create a Kubernetes Secret for your OAuth token. You will need to encode the data you want in Base64 for the Kubernetes Secret.
ho -n "YOUR_OAUTH_TOKEN" | base64
  1. Modify the rotisserie-secrets.yaml file to use your token

:
ken: YOUR_OAUTH_TOKEN_IN_BASE64
  1. Finally, create the Kubernetes Secret.
bectl create -f rotisserie-secrets.yaml
  1. Modify the rotisserie-app.yaml and rotisserie-ocr.yaml yaml files to use your image.

containers:
- name: rotisserie-app
  image: <docker_username>/rotisserie-app
  1. Deploy the OCR service then the main application.
bectl apply -f rotisserie-ocr.yaml
bectl apply -f rotisserie-app.yaml
r clusters provisioned with Bluemix
 cs workers YOUR_CLUSTER_NAME

r Minikube
nikube ip
Production Detail

The production version of rotisserie has slightly different operational procedures. The production kubernetes manifest is located in the deploy directory. It is typically interacted with via the provided Makefile. Major differences between the production rotisserie and the one used in the developer journey are use of ingress controllers in kuberenetes and adding Letsencrypt.

There are a few commands we can use to work with the deployment.

To deploy without letsencrypt use make roll

 roll

To deploy with letsencrypt use make full-roll

 full-roll

To redeploy the deployments, without removing svc/ing/other, use make redeploy

 redeploy

To delete the entire deployment we can use make purge

 purge

Note: this depends on you deploying with a unique sha. See the 'make-rev' rule in the Makefile. In most cases git pull; make roll should work. In cases where a roll failed or the app failed for reasons not connected to the code, a dummy commit might need to be added before re-rolling. Please only roll from master.

Whitelisting and Blacklisting streamers

To whitelist simply set an environment variable called ROTISSERIE_WHITELIST to a string with space separated usernames. Same with blacklisting, but with the environment variable ROTISSERIE_BLACKLIST.

License

rotisserie is currently licensed under the Apache 2.0 License.


This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.