Skip to main content

Personal twitch stream recorder

Project description

offstream

Record your favorite twitch streams automatically and watch them later.

  • There is no web UI, just use curl and your favorite video player.
  • Streams are recorded as is, without re-transcoding.
  • Recordings are never muted.
  • Ads are optional.
  • You can run it on Heroku (completely free) or locally.
  • Recordings are stored on IPFS.
  • RSS feed of all recordings is available. It can be consumed by youtube-dl, VLC, and other feed readers.
  • Streams are available while recording is in progress.

Installing

Option 1: Heroku

You can deploy the app to Heroku by clicking the button below and following the instructions. IMPORTANT: When the app is deployed, click on the "View" button at the bottom to complete the setup.

Deploy

Option 2: Local installation

  1. Install the package.
    $ pip install offstream
    
  2. Setup your local sqlite database located at ~/.offstream/offstream.db.
    $ offstream setup
    
    You will get credentials to control the app. I recommend adding them to your ~/.netrc file (or _netrc on Windows):
    machine <your-app-hostname>
        login offstream
        password <your-password>
    
  3. Start the app.
    $ offstream
    

Usage

Once your app is ready, you can add your favorite streamers.

$ curl -n https://your-app-name.herokuapp.com/streamers -d name=garybernhardt
$ curl -n https://your-app-name.herokuapp.com/streamers -d name=esl_sc2 -d max_quality=720p60

The max_quality parameter is optional and defaults to best. Typical stream quality options are
audio_only, 160p, 360p, 480p, 720p, 720p60, 1080p60, best.

When any of the streamers goes live, the app will record the stream.

An RSS feed of all recordings is available at
https://your-app-name.herokuapp.com/rss.

Finally, to watch the latest recording, open the following URL in mpv, VLC, QuickTime, or any other video player.

$ mpv https://your-app-name.herokuapp.com/latest/{streamer_name}

API

  • POST /streamers -d name=<streamer_name> -d max_quality=<quality>

    Track a new streamer.

    Requires auth.

  • DELETE /streamers/{streamer_name}

    Delete a streamer. WARNING: Deletes all associated recordings too.

    Requires auth.

  • GET /latest/{streamer_name}

    Get the latest recorded stream.

  • POST /settings -d ping_start_hour=<hour> -d ping_end_hour=<hour>

    Modify ping settings. On Heroku, offstream keeps itself awake 24/7 by pinging itself periodically. You can save some dyno hours by changing the ping_start_hour and ping_end_hour settings to let the app sleep when no one is streaming.

    Requires auth.

  • GET /rss or GET /rss?limit=100

    RSS feed of recent recordings.

Configuration

The following environment variables are supported.

  • OFFSTREAM_FLUSH_THRESHOLD

    Default: automatically calculated, normally 100000000 bytes (100M).

  • OFFSTREAM_CHECK_INTERVAL

    Default: 120 seconds

  • OFFSTREAM_IPFS_API_ADDR

    Default: /dns/ipfs.infura.io/tcp/5001/https

  • OFFSTREAM_IPFS_GATEWAY_URI_TEMPLATE

    Default: https://{cid}.ipfs.infura-ipfs.io/{path}

  • OFFSTREAM_MAX_CONCURRENT_RECORDERS

    Default: 5

  • DATABASE_URL

    Default: sqlite:///$HOME/.offstream/offstream.db

  • TZ

    Preferred timezone, e.g. America/New_York. Please see
    https://en.wikipedia.org/wiki/List_of_tz_database_time_zones#List

FAQ

  • Q: My video player reports the following error:
    keepalive request failed for 'https://bafybeie3v6lomkfti2b4zsa4yj35nypojllvjrzpbzyxhn5tkfoqaswmbm.ipfs.infura-ipfs.io/18846.ts'

    A: This warning can be safely ignored. It's because Infura keeps the root content identifier (CID) in a subdomain, rather than in the path portion of the URL.

See Also

Please also check out the streamlink project.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

offstream-1.0.3.tar.gz (20.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

offstream-1.0.3-py3-none-any.whl (19.8 kB view details)

Uploaded Python 3

File details

Details for the file offstream-1.0.3.tar.gz.

File metadata

  • Download URL: offstream-1.0.3.tar.gz
  • Upload date:
  • Size: 20.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.4

File hashes

Hashes for offstream-1.0.3.tar.gz
Algorithm Hash digest
SHA256 404b2f5b1f65ba8aa3520726b8409a0ebf4b6504e2ffa847725fef3909189516
MD5 c048ef5a9a497134762592a08864340f
BLAKE2b-256 571fd63f2b0da3262ad021efcb013dd4e14fe6bf95cce0ae6937b41a6c06f368

See more details on using hashes here.

File details

Details for the file offstream-1.0.3-py3-none-any.whl.

File metadata

  • Download URL: offstream-1.0.3-py3-none-any.whl
  • Upload date:
  • Size: 19.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.4

File hashes

Hashes for offstream-1.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 9c25ec806be7366835ba3ad51e32e7024f22e513098d12038b846216bf2f7e33
MD5 4cdcd7ce611699cbc84eaed0714afc6d
BLAKE2b-256 6f2cf90eb319abf0afa92fb57c67663d725aff56bcfc532be5460118c06499ef

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page