Coder Social home page Coder Social logo

twitch.rb's Introduction

Twitch.rb

Simple twitch client displaying and archiving a playlist for a livestream.

Usage

  twitch.rb stream CHANNEL           # output an m3u8 suitable for most media players
  twitch.rb archive CHANNEL [LIMIT]  # archive the most recent streams
  twitch.rb gc [LIMIT]               # Show commands and statistics to limit the archive

Installation

  • Clone the repository
  • gem install concurrent-ruby thor pry twitch-api m3u8
  • ./twitch.rb help

Archiving

During a livestream, Twitch automatically populates it's archive with an update frequency of roughly 5 minutes. The archiver will catch up to Twitch's archive on each run. Running the archiver periodically ensures gapless transitions between restarts of streams. A certain kind fellow has written a front-end.

Format

The current format consists of two parts, top-level vods.json and a video.json with the properties for each video as Twitch serves it.

{
  "streamer_name": [
    {
      "meta": "relative/path/to/video.json",
      "video": "relative/path/to/",
      "playable": true,
      "source": "relative/path/to/index.m3u8",
      "twitch": {.. contents of meta ..},
    },
//  ...
  ]
}

The playable property indicates whether the video chunks have been deleted to conserve space. If false then source will be omitted. Make use of the url property from the object referenced by meta to provide a link to Twitch.

Known Issues

The archiver writes the meta files before each part of the playlist is downloaded and when nothing is downloaded at all. This has two effects:

  • For a short duration the meta files thus reference non-existing objects. This is not a problem in regular operations as the time to catch up is usually less than the length of even a single chunk. This means it is essentially invisible to clients. Were this to use promises over manually managing a tasks in a threadpool.
  • Modification times are nolonger indicative. There is however a suitable time in the meta file video.json. The lack of mtime (or ctime) makes deletions a bit of a nuisance. As find archive -mtime +20 -delete is unsuitable limiting storage space should probably be integrated in the archive command.

twitch.rb's People

Contributors

xeago 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.