A POSIX shell script that skips sponsored Youtube content on all local Chromecasts, using the SponsorBlock API. It was inspired by CastBlock but written from scratch to avoid some of its pitfalls (see Differences from CastBlock)
Care was taken to ensure it's fully POSIX-compatible, so it can run on lighter shells such as Dash.
The script will scan for all Chromecasts on the LAN, and launches a process for each one to efficiently poll it status every second. If a Chromecast is found to be playing a YouTube video, sponsor segments are fetched from the SponsorBlock API and stored in a temporary file. Whenever the Chromecast reaches a sponsored segment, the script tells it to seek to the end of the segment.
Install sponsorblockcast-git with your AUR helper of choice or with makepkg.
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 Docker or in the example for docker-compose
.
Run the below commands as root or a member of the docker
group
docker build . -t sponsorblockcast:latest
docker run --network=host --name sponsorblockcast sponsorblockcast:latest
First you will need a docker-compose.yaml
file, such as the example included. Run the below commands as root or a member of the docker
group
docker-compose build
docker-compose up -d
- Copy sponsorblockcast.sh to
/usr/bin/sponsorblockcast
. - Copy sponsorblockcast.service to
/usr/lib/systemd/system/sponsorblockcast.service
.
Run sponsorblockcast
from a terminal or activate the service with systemd enable --now sponsorblockcast
You can configure the following parameters by setting the appropriate enviroment values:
SBCPOLLINTERVAL
- Time to wait between each polling of the Chromecasts' status (default=1
)SBCSCANINTERVAL
- Time to wait between each scan for available Chromecast (default=300
)SBCDIR
- Directory where temporary files are stored (default=/tmp/sponsorblockcast
)SBCCATEGORIES
- Space-separated SponsorBlock categories to skip, see category list (default=sponsor
)
To run from the terminal with custom parameters you can use env
like so:
env SBCSCANINTERVAL=10 SBCPOLLINTERVAL=100 SBCCATEGORIES="sponsor selfpromo" sponsorblockcast
To modify the variables when running as a systemd service, create an override for the service with:
sudo systemctl edit sponsorblockcast.service
This will open a blank override file where you can specify Environment values like so:
[Service]
Environment="SBCPOLLINTERVAL=10"
Environment="SBCSCANINTERVAL=100"
Environment="SBCCATEGORIES=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 SBCPOLLINTERVAL=10 --env SBCSCANINTERVAL=100 --name sponsorblockcast sponsorblockcast:latest
When using docker-compose.yaml
you can simply edit the environment
directive as shown in the example file.
- Regular scans to find new Chromecasts while the script is running
- Allows configuring parameters
- Specify which SponsorBlock categories to skip
- More efficient polling, through using
go-chromecast
'swatch
command, avoiding expensive startup costs. This lets us poll much more often, without any large performance costs. - Full POSIX-compatibility