Skip to content

Instantly share code, notes, and snippets.

@ArnaudRinquin
Created October 12, 2015 23:54
Show Gist options
  • Save ArnaudRinquin/0b73c5f477aebbb227ad to your computer and use it in GitHub Desktop.
Save ArnaudRinquin/0b73c5f477aebbb227ad to your computer and use it in GitHub Desktop.
periscope-stats

periscope-stats

Store and prepare periscope statistics from live periscope.tv info streams.

Usage

The first step is to get some data from a periscope PUBNUB stream. The easiest way probably is to use peristream. The following examples uses peristream.

var peristream = require('peristream');
var periscopeStats = require('periscope-stats');

var stream = peristream('https://www.periscope.tv/w/########');

stream.connect()
  .then(periscopeStats)
  .then(function(bus){
    
    bus.on(periscopeStats.UPDATE, function(stats){
      
      console.log(stats.hearts.byUser());
      // { mrrobot: 4, "bl@ck warrior_67": 3, ... }

      console.log(stats.hearts.byColor());
      // { orange: 12, teal: 12 }

      //
      console.log(stats.users.list());
      // [{name: 'userName1', joinedAt: ''}, {name: 'jobBob123', ..}]
    });
    
    bus.on(periscopeStats.HEART, function(stats){
      // still access to all stats, but only triggered when
      // on new hearts
    });
    
  });

Stats

  • hearts
  • users
  • comments

Hearts

  • list(): ordered creation data
  • byColor()
  • byUser()
  • fromUser(userId)

Comments

  • list(): ordered creation data
  • forUser(userId)
  • byUser()

User

  • list(): ordered creation data
  • byColor()
  • fromId(id)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment