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

streamlink-serverless

v0.0.70

Published

Streamlink as a Service

Downloads

156

Readme

Streamlink as a Serverless Service | Getting started | Usage | FAQ

View on Construct Hub

Getting started

Streamlink Serverless is a CDK construct to run Streamlink as a serverless Lambda Function on AWS.

Requirements

  • AWS CDK
  • Docker (to bundle the Streamlink Serverless Lambda Function)

Installation

Add Streamlink Serverless to a new or existing AWS CDK app in the language of your choice:

Node.js

# npm 
npm install streamlink-serverless
# Yarn
yarn add streamlink-serverless
# pnpm
pnpm add streamlink-serverless

Other languages

# Python
pip install streamlink-serverless

# Dotnet
dotnet add package StreamlinkServerless

Full example

This example creates a Stack with a Streamlink Serverless backend and publishes the service behind a Function URL. Finally an output returns the service URL for immediate use.

const app = new cdk.App();
const stack = new cdk.Stack(app, 'Streamlink');

const streamlink = new Streamlink(stack, 'Backend');

const endpoint = new lambda.FunctionUrl(stack, 'Endpoint', {
  function: streamlink.function,
  authType: lambda.FunctionUrlAuthType.NONE,
});

new cdk.CfnOutput(stack, 'EndpointUrl', {
  value: endpoint.url,
});

app.synth();

Usage

Once deployed, you can use your Streamlink Serverless service like this: https://example.com/live/youtube.com/@NASA/best.m3u8

URL formats

https://<endpoint>/live/<url>
Simply put the stream URL behind your endpoint.

  • <endpoint>
    The endpoint URL of the Streamlink Serverless deployment.
  • <url>
    A URL to attempt to extract streams from. Usually, the protocol of http(s) URLs can be omitted.

https://<endpoint>/live/<url>/<stream>.<type>
This format allows selecting a specific stream quality and format.

  • <stream>
    Stream to play. Use best or worst for selecting the highest or lowest available quality. Optional.
  • <type>
    Type of the returned stream. Needed by some players for correct playback. Use m3u8 for HLS streams or mpd for Dash streams.

FAQ

Feel free to open an issue for any unaddressed questions.

🌍 Does it work with geo-blocking?

Make sure to deploy Streamlink Serverless into the region you intend to watch streams from. Most services are already geo-blocked when trying to retrieve the stream URL. E.g. if you are based in London, United Kingdom deploy to eu-west-2.

See this blog post for detailed instructions.

💰 How much does it cost to run?

The pricing model for AWS Lambda is based on number of request and duration of the execution. It also offers a generous "always free" allocation via AWS Free Tier.

While cost predications are incredible difficult to make, it seems possible to run Streamlink Serverless for personal use only within the bounds of AWS Free Tier.

Always set up billing alarms to avoid unexpected costs.

🔐 Why does it have no authentication or password protection?

Adding appropriate authentication is your responsibility. Putting any unprotected URL online makes you susceptible to occurring unexpected cost.

Streamlink Serverless does not offer built-in password protection, because the pricing model for AWS Lambda charges for number of requests and duration of the execution. This means that you would still be charged for any unauthenticated requests if password protection were to be handled inside the Lambda Function. While there might be some savings from shorter execution times and the deterrent of an unusable service, it is much safer to deploy a proper authentication mechanism.

The simplest way would be to enable AWS_IAM auth on the Lambda Function URL (see docs). However IAM authentication is likely not compatible with the intended use case of using Streamlink Serverless URLs as IPTV playlists, as it involves signing requests.

A more advanced approach would be to deploy Streamlink Serverless as part of an API Gateway HTTP API and configure an authorizer according to your needs.