Giter Club home page Giter Club logo

sphere_streams's Introduction

SphereWeb CMS: Streams Plugin

Online streams plugin for SphereWeb CMS.

Instalation

Add to src/component/plugins dir as sphere_streams folder. Plugin will be available by path /streams/view

How to use

Configure config.php file.

Twitch

  1. Get access token and client id for your twich app.
  2. Setup credentials to config.php
        "twitch" => [
            "access_token" => "YOUR_ACCESS_TOKEN",
            "client_id" => "YOUR_CLIENT_ID",
  1. Add streamers to list
            "streamers" => [
                [
                    "username" => "TWITCH_USERNAME_FROM_URL",
                    "sphere_user_id" => 0 // used to give rewards
                ],

Youtube

  1. Get api key for your youtube project.
  2. Setup credentials to config.php
        "youtube" => [
            "api_key" => "YOUR_API_KEY",
  1. Add streamers to list. You can get chnnel_id using this instruction
            "streamers" => [
                [
                    "username" => "NAME_THAT_WILL_BE_IN_WEB",
                    "channel_id" => "YOUTUBE_CHANNEL_ID",
                    "sphere_user_id" => 6
                ],

Trovo

  1. Request adding your web domain to white list: rules.
  2. Get client id for your trovo app.
  3. Setup credentials to config.php
        "trovo" => [
            "client_id" => "YOUR_CLIENT_ID",
  1. Add streamers to list
            "streamers" => [
                [
                    "username" => "TROVO_USERNAME_FROM_URL",
                    "sphere_user_id" => 8
                ],

Rewards

Configure rewards for streaming in config.php

[
    "id" => 0, // unique id for reward record
    "server_id" => 1, // server id for reward apply
    "threshold" => [
        "duration_min" => 60, // min time to get reward(in mins)
        "viewers" => 5, // min viewvers to get reward
    ],
    // user will get rewards into sphere inventory
    "items" => [
        [
            "id" => 57,
            "count" => 1000,
            "enchant" => 0,
        ],
        [
            "id" => 4357,
            "count" => 1,
            "enchant" => 0,
        ],
    ]
],

If streamer pass reward threshold he will receive reward items to SphwereWeb inventory. User and admins will be notified about it throught the /user/notification tab.

Cron job

Streaming service API has many restrictions and coz of that we use caching as main data source.

Cron used as schedule mechanism for cache update and rewards processing. To make it all works you MUST setup this.

Add cron job

  1. Type the following command to edit the crontab file:
crontab -e
  1. This will open the crontab file for editing. Add the following line to the file:
* * * * * php /path/to/sphere/src/component/plugins/sphere_streams/cronjob.php > /dev/null 2>&1

example:

* * * * * php /home/root/web/l2.ru/public_html/src/component/plugins/sphere_streams/cronjob.php > /dev/null 2>&1
  1. Save the file and exit the editor.

After saving the crontab file, the cron job will be scheduled and start running automatically every minute.

sphere_streams's People

Contributors

projackl2 avatar

Watchers

 avatar

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.