Home

Awesome

CastSponsorSkip

<img src="./assets/icon.svg" alt="CastSponsorSkip Icon" align="right" width="90">

GitHub release (latest by date) Build Go Report Card Quality Gate Status

A Go program that skips sponsored YouTube content and skippable ads on all local Google Cast devices, using the SponsorBlock API. This project was inspired by sponsorblockcast, but written from scratch to decrease memory and CPU usage, and to work around some of its problems (see Differences from sponsorblockcast).

When run, this program will watch all Google Cast devices on the LAN. If a Cast device begins playing a YouTube video, sponsored segments are fetched from the SponsorBlock API. When the device reaches a sponsored segment, the CastSponsorSkip will quickly seek to the end of the segment.

Additionally, CastSponsorSkip will look for skippable YouTube ads, and automatically hit the skip button when it becomes available.

Installation

Docker

<details> <summary>Click to expand</summary>

You can install Docker directly or use Docker Compose (Or use Podman, Portainer, etc). Please note you MUST use the host network as shown below for cli or in the example docker-compose file.

Docker

Run the below commands as root or a member of the docker group:

docker run --network=host --name=castsponsorskip ghcr.io/gabe565/castsponsorskip

Docker Compose

First you will need a docker-compose.yaml file, such as the one included in this repo. Run the below commands as root or a member of the docker group:

docker compose up -d
</details>

Home Assistant Addon

<details> <summary>Click to expand</summary>

A Home Assistant addon is provided by @alexbelgium and @bruvv. See alexbelgium/hassio-addons for installation instructions.

</details>

APT (Ubuntu, Debian)

<details> <summary>Click to expand</summary>
  1. If you don't have it already, install the ca-certificates package

    sudo apt install ca-certificates
    
  2. Add gabe565 apt repository

    echo 'deb [trusted=yes] https://apt.gabe565.com /' | sudo tee /etc/apt/sources.list.d/gabe565.list
    
  3. Update apt repositories

    sudo apt update
    
  4. Install CastSponsorSkip

    sudo apt install castsponsorskip
    
</details>

RPM (CentOS, RHEL)

<details> <summary>Click to expand</summary>
  1. If you don't have it already, install the ca-certificates package

    sudo dnf install ca-certificates
    
  2. Add gabe565 rpm repository to /etc/yum.repos.d/gabe565.repo

    [gabe565]
    name=gabe565
    baseurl=https://rpm.gabe565.com
    enabled=1
    gpgcheck=0
    
  3. Install CastSponsorSkip

    sudo dnf install castsponsorskip
    
</details>

AUR (Arch Linux)

<details> <summary>Click to expand</summary>

Install castsponsorskip-bin with your AUR helper of choice.

</details>

Homebrew (macOS, Linux)

<details> <summary>Click to expand</summary>

Install CastSponsorSkip from gabe565/homebrew-tap:

brew install gabe565/tap/castsponsorskip
</details>

Kubernetes

<details> <summary>Click to expand</summary>

CastSponsorSkip doesn't require a Service or Ingress, so it's simple to host in Kubernetes with a single Deployment. The only gotcha is that hostNetwork must be enabled for device discovery to work.

A Helm chart is available to make Kubernetes deployment even simpler. For more information, see charts.gabe565.com or Artifact Hub.

</details>

Manual Installation

<details> <summary>Click to expand</summary>

Download and run the latest release binary for your system and architecture.

</details>

Usage

Run castsponsorskip from a terminal or activate the service with systemd:

systemctl enable --now castsponsorskip
<details> <summary>Homebrew Instructions</summary>

Use brew services to start CastSponsorSkip:

brew services start castsponsorskip
</details>

Configuration

CastSponsorSkip can be configured with envs, command-line flags, or a config file. Some notable envs are listed below, but all flags can be set with envs.
To use an env that is not listed here, capitalize all characters, replace - with _, and prefix with CSS_. For example, --paused-interval=1m would become CSS_PAUSED_INTERVAL=1m.

Notable Envs

Here's a list of commonly used envs. Also see full env reference.

EnvDescriptionDefault
CSS_DISCOVER_INTERVALInterval to restart the DNS discovery client.5m
CSS_PAUSED_INTERVALTime to wait between each poll of the Cast device status when paused.1m
CSS_PLAYING_INTERVALTime to wait between each poll of the Cast device status when playing.500ms
CSS_CATEGORIESComma-separated list of SponsorBlock categories to skip, see category list and category breakdown.sponsor
CSS_YOUTUBE_API_KEYYouTube API key for fallback video identification (required on some Chromecast devices).
CSS_MUTE_ADSMutes the device while an ad is playing.true
CSS_DEVICESComma-separated list of device addresses. This will disable discovery and is not recommended unless discovery fails.[]
CSS_SKIP_SPONSORSToggles sponsored segment skipping via the SponsorBlock API. If disabled, only YouTube ads will be skipped.true

[!NOTE] sponsorblockcast envs are also supported to simplify the migration to CastSponsorSkip. When used, a deprecation warning will be logged with an updated env key and value. There are currently no plans to remove these envs.

Flags

See command-line reference.

Systemd

To modify the variables when running as a systemd service, create an override for the service with:

sudo systemctl edit castsponsorskip.service

This will open a blank override file where you can specify environment variables like so:

[Service]
Environment="CSS_PAUSED_INTERVAL=1m"
Environment="CSS_PLAYING_INTERVAL=1s"
Environment="CSS_CATEGORIES=sponsor,selfpromo"

To modify the variables when running as a Docker container, you can add arguments to the docker run command like so:

docker run --network=host --env CSS_PAUSED_INTERVAL=5m --env CSS_PLAYING_INTERVAL=2s --name=castsponsorskip ghcr.io/gabe565/castsponsorskip

Docker Compose

When using docker-compose.yaml, you can simply edit the environment directive as shown in the example file.

Differences from sponsorblockcast

I own 12 Google Cast devices, and have compared CPU and memory usage of the two programs. Note that CPU usage is measured in "milliCPU", meaning that 1m is equal to 1/1000 of a CPU. Here are the averages:

ProgramCPUMemory
sponsorblockcast75m70Mi
castsponsorskip1m10Mi