npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

twitch-user-streaming-info

v0.1.0

Published

Get the live information of twitch user (scraping).

Downloads

2

Readme

Information

This package is for getting the current livestream information of the twitch streamer.

  • Simple and easy
  • Fast and efficient
  • Decent information

Please consider using the original API or making your own scraper for extensive use.

Sample

Input:

const getTwitchUserInfo = require("twitch-user-streaming-info");

getTwitchUserInfo("esl_csgo").then(console.log).catch(console.error);

Output:

{
  success: true,
  error: null,
  live: true,
  name: 'ESL_CSGO - Twitch',
  title: 'RERUN: NaVi vs. AGO - Map 2 [Mirage] - ESL Pro League Season 15 - Group D',
  embedURL: 'https://player.twitch.tv/?channel=esl_csgo&player=facebook&autoplay=true&parent=meta.tag',
  thumbnails: [
    'https://static-cdn.jtvnw.net/previews-ttv/live_user_esl_csgo-80x45.jpg',
    'https://static-cdn.jtvnw.net/previews-ttv/live_user_esl_csgo-320x180.jpg',
    'https://static-cdn.jtvnw.net/previews-ttv/live_user_esl_csgo-640x360.jpg'
  ],
  upload: 2022-04-01T20:21:41.000Z,
  start: 2022-04-01T20:21:41.000Z,
  _end: 2022-04-02T00:21:41.000Z,
  _isLiveBroadcast: true
}

API

There's actually no function, you can use the package as soon as you import it directly.

Parameters

getTwitchUserInfo("username", booleanOnly, parseProps)

username: String ~ Username of the Twitch streamer.
booleanOnly: Boolean [true/false] ~ Get results in boolean instead of objects.
parseProps: Boolean [true/false] ~ Parse the properties and format them in a good order.

booleanOnly is disabled by default and parseProps is enabled by default.

Data

If booleanOnly parameter is set to true, it will always return the result in boolean regardless of what the response is (other than main errors).

If the booleanOnly parameter is set to false, it will always return the result in objects regardless of what the response is (other than main errors).

Data: Objects

There are always three properties present in the response, regardless of what the response is (good or bad).

Properties: success, error, and live

Properties starting with _ aren't recommended for production and they are also useless & just there for testing.

parseProps is enabled:

{
  success: true,
  error: null,
  live: true,
  name: 'ESL_CSGO - Twitch',
  title: 'RERUN: NaVi vs. AGO - Map 2 [Mirage] - ESL Pro League Season 15 - Group D',
  embedURL: 'https://player.twitch.tv/?channel=esl_csgo&player=facebook&autoplay=true&parent=meta.tag',
  thumbnails: [
    'https://static-cdn.jtvnw.net/previews-ttv/live_user_esl_csgo-80x45.jpg',
    'https://static-cdn.jtvnw.net/previews-ttv/live_user_esl_csgo-320x180.jpg',
    'https://static-cdn.jtvnw.net/previews-ttv/live_user_esl_csgo-640x360.jpg'
  ],
  upload: 2022-04-01T20:21:41.000Z,
  start: 2022-04-01T20:21:41.000Z,
  _end: 2022-04-02T00:21:41.000Z,
  _isLiveBroadcast: true
}

If you are wondering, you should use start over upload as it gives the date when the stream was started instead of when the stream was uploaded.

{
  success: Boolean,
  error: null | Error,
  live: Boolean,
  name: String,
  title: String,
  embedURL: URL,
  thumbnails: Array [URL],
  upload: Date,
  start: Date,
  _end: Date,
  _isLiveBroadcast: Boolean
}

Note: URL type is string type.

parseProps is disabled:

{
  success: true,
  error: null,
  live: true,
  '@type': 'VideoObject',
  '@context': 'https://schema.org',
  description: 'RERUN: Complexity vs. Heroic - Map 1 [Ancient] - ESL Pro League Season 15 - Group D',
  embedUrl: 'https://player.twitch.tv/?channel=esl_csgo&player=facebook&autoplay=true&parent=meta.tag',
  name: 'ESL_CSGO - Twitch',
  thumbnailUrl: [
    'https://static-cdn.jtvnw.net/previews-ttv/live_user_esl_csgo-80x45.jpg',
    'https://static-cdn.jtvnw.net/previews-ttv/live_user_esl_csgo-320x180.jpg',
    'https://static-cdn.jtvnw.net/previews-ttv/live_user_esl_csgo-640x360.jpg'
  ],
  uploadDate: '2022-04-01T20:21:41Z',
  publication: {
    '@type': 'BroadcastEvent',
    endDate: '2022-04-02T00:21:41Z',
    startDate: '2022-04-01T20:21:41Z',
    isLiveBroadcast: true
  }
}
{
  success: Boolean,
  error: null | Error,
  live: Boolean,
  '@type': String,
  '@context': URL,
  description: String,
  embedUrl: URL,
  name: String,
  thumbnailUrl: Array [URL],
  uploadDate: DateString,
  publication: {
    '@type': String,
    endDate: DateString,
    startDate: DateString,
    isLiveBroadcast: Boolean
  }
}

Note: DateString isn't the parsed Date, it's Date in string which you can parse using Date constructor but it's already parsed when using the package with parseProps enabled.