From 60e0ffcfc61cbd328530e958c5640be86ca37273 Mon Sep 17 00:00:00 2001 From: Gabe Cook Date: Tue, 15 Aug 2023 11:11:20 -0500 Subject: [PATCH] chore: Rename to CastSponsorSkip --- .dockerignore | 2 +- .gitignore | 2 +- .goreleaser.yaml | 8 +++--- Dockerfile | 6 ++-- Dockerfile.goreleaser | 6 ++-- README.md | 28 +++++++++---------- ...cast-go.service => castsponsorskip.service | 4 +-- cmd/cmd.go | 6 ++-- docker-compose.yaml | 2 +- go.mod | 2 +- internal/config/viper.go | 4 +-- internal/device/dns.go | 2 +- internal/device/watch.go | 4 +-- internal/sponsorblock/query.go | 2 +- main.go | 2 +- 15 files changed, 40 insertions(+), 40 deletions(-) rename sponsorblockcast-go.service => castsponsorskip.service (67%) diff --git a/.dockerignore b/.dockerignore index 64a4c94..43c5e3f 100644 --- a/.dockerignore +++ b/.dockerignore @@ -6,5 +6,5 @@ .pre-commit-config.yaml Dockerfile docker-compose.yml -sponsorblockcast-go +castsponsorskip vendor/ diff --git a/.gitignore b/.gitignore index 526a8ff..f85dc75 100644 --- a/.gitignore +++ b/.gitignore @@ -16,4 +16,4 @@ dist/ vendor/ -sponsorblockcast-go +castsponsorskip diff --git a/.goreleaser.yaml b/.goreleaser.yaml index c5cc661..c7be2cd 100644 --- a/.goreleaser.yaml +++ b/.goreleaser.yaml @@ -1,4 +1,4 @@ -project_name: sponsorblockcast-go +project_name: castsponsorskip builds: - env: - CGO_ENABLED=0 @@ -69,7 +69,7 @@ docker_manifests: nfpms: - id: packages vendor: Gabe Cook - homepage: https://github.com/gabe565/sponsorblockcast-go + homepage: https://github.com/gabe565/castsponsorskip description: A Go program that skips sponsored YouTube content on all local Google Cast devices license: GPL-3.0 maintainer: Gabe Cook @@ -77,8 +77,8 @@ nfpms: - deb - rpm contents: - - src: ./sponsorblockcast-go.service - dst: /etc/systemd/system/sponsorblockcast-go.service + - src: ./castsponsorskip.service + dst: /etc/systemd/system/castsponsorskip.service type: config publishers: - name: fury.io diff --git a/Dockerfile b/Dockerfile index 79e0828..910121e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -17,13 +17,13 @@ WORKDIR /app RUN apk add --no-cache tzdata -ARG USERNAME=sponsorblockcast-go +ARG USERNAME=castsponsorskip ARG UID=1000 ARG GID=$UID RUN addgroup -g "$GID" "$USERNAME" \ && adduser -S -u "$UID" -G "$USERNAME" "$USERNAME" -COPY --from=go-builder /app/sponsorblockcast-go ./ +COPY --from=go-builder /app/castsponsorskip ./ USER $UID -CMD ["./sponsorblockcast-go"] +CMD ["./castsponsorskip"] diff --git a/Dockerfile.goreleaser b/Dockerfile.goreleaser index 6a3bb9e..f28f352 100644 --- a/Dockerfile.goreleaser +++ b/Dockerfile.goreleaser @@ -3,13 +3,13 @@ WORKDIR /app RUN apk add --no-cache tzdata -COPY sponsorblockcast-go . +COPY castsponsorskip . -ARG USERNAME=sponsorblockcast-go +ARG USERNAME=castsponsorskip ARG UID=1000 ARG GID=$UID RUN addgroup -g "$GID" "$USERNAME" \ && adduser -S -u "$UID" -G "$USERNAME" "$USERNAME" USER $UID -CMD ["./sponsorblockcast-go"] +CMD ["./castsponsorskip"] diff --git a/README.md b/README.md index b2b48f4..18bf51c 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,10 @@ -# sponsorblockcast-go +# CastSponsorSkip A Go program that skips sponsored YouTube content and skippable ads on all local Google Cast devices, using the [SponsorBlock](https://github.com/ajayyy/SponsorBlock) API. This project was inspired by [sponsorblockcast](https://github.com/nichobi/sponsorblockcast), but written from scratch to decrease memory and CPU usage, and to work around some of its problems (see [Differences from sponsorblockcast](#differences-from-sponsorblockcast)). This program will scan for all Google Cast devices on the LAN, and runs a Goroutine for each one to efficiently poll its status every minute. If a Cast device is found to be playing a YouTube video, the poll interval is increased to once every second, sponsored segments are fetched from the SponsorBlock API and stored in memory. Whenever the Cast device reaches a sponsored segment, the program tells it to seek to the end of the segment. -Additionally, sponsorblockcast-go will look for skippable YouTube ads, and automatically hit the skip button when it becomes available. +Additionally, CastSponsorSkip will look for skippable YouTube ads, and automatically hit the skip button when it becomes available. ## Installation @@ -18,7 +18,7 @@ Additionally, sponsorblockcast-go will look for skippable YouTube ads, and autom #### Docker Run the below commands as root or a member of the `docker` group: ```shell - docker run --network=host --name=sponsorblockcast-go ghcr.io/gabe565/sponsorblockcast-go + docker run --network=host --name=castsponsorskip ghcr.io/gabe565/castsponsorskip ``` #### Docker Compose @@ -49,9 +49,9 @@ Additionally, sponsorblockcast-go will look for skippable YouTube ads, and autom sudo apt update ``` -4. Install sponsorblockcast-go +4. Install CastSponsorSkip ```shell - sudo apt install sponsorblockcast-go + sudo apt install castsponsorskip ``` @@ -74,9 +74,9 @@ Additionally, sponsorblockcast-go will look for skippable YouTube ads, and autom gpgcheck=0 ``` -3. Install sponsorblockcast-go +3. Install CastSponsorSkip ```shell - sudo yum install sponsorblockcast-go + sudo yum install castsponsorskip ``` @@ -86,7 +86,7 @@ Additionally, sponsorblockcast-go will look for skippable YouTube ads, and autom Click to expand ```shell - brew install gabe565/tap/sponsorblockcast-go + brew install gabe565/tap/castsponsorskip ``` @@ -97,11 +97,11 @@ Additionally, sponsorblockcast-go will look for skippable YouTube ads, and autom #### Instructions - Download and run the [latest release binary](https://github.com/gabe565/sponsorblockcast-go/releases/latest) for your system and architecture. + Download and run the [latest release binary](https://github.com/gabe565/castsponsorskip/releases/latest) for your system and architecture. ## Usage -Run `sponsorblockcast-go` from a terminal or activate the service with `systemctl enable --now sponsorblockcast-go`. +Run `castsponsorskip` from a terminal or activate the service with `systemctl enable --now castsponsorskip`. ## Configuration You can configure the following parameters by setting the appropriate command line flag or environment variable: @@ -116,7 +116,7 @@ You can configure the following parameters by setting the appropriate command li To modify the variables when running as a systemd service, create an override for the service with: ```shell -sudo systemctl edit sponsorblockcast-go.service +sudo systemctl edit castsponsorskip.service ``` This will open a blank override file where you can specify environment variables like so: @@ -130,13 +130,13 @@ Environment="SBC_CATEGORIES=sponsor,selfpromo" To modify the variables when running as a Docker container, you can add arguments to the `docker run` command like so: ```shell -docker run --network=host --env SBC_PAUSED_INTERVAL=5m --env SBC_PLAYING_INTERVAL=2s --name=sponsorblockcast-go ghcr.io/gabe565/sponsorblockcast-go +docker run --network=host --env SBC_PAUSED_INTERVAL=5m --env SBC_PLAYING_INTERVAL=2s --name=castsponsorskip ghcr.io/gabe565/castsponsorskip ``` When using `docker-compose.yaml`, you can simply edit the `environment` directive as shown in the example file. ## Differences from sponsorblockcast -- Compiles to a single binary. No dependencies are required other than `sponsorblockcast-go`. +- Compiles to a single binary. No dependencies are required other than CastSponsorSkip. - Scans Cast device status much less frequently when a YouTube video is not playing, resulting in decreased CPU usage and less stress on the Cast device. - Written Go, which is the same language as `go-chromecast`. This means `go-chromecast` functions can be called directly instead of relying on shell scripts, child commands, or string parsing. - `go-chromecast` only needs to be loaded once within a single Go program, resulting on lower memory usage. @@ -147,4 +147,4 @@ I own 12 Google Cast devices, and have compared CPU and memory usage of the two | Program | CPU | Memory | |---------------------|-----|--------| | sponsorblockcast | 75m | 70Mi | -| sponsorblockcast-go | 1m | 10Mi | +| castsponsorskip | 1m | 10Mi | diff --git a/sponsorblockcast-go.service b/castsponsorskip.service similarity index 67% rename from sponsorblockcast-go.service rename to castsponsorskip.service index 2361b7b..96de97c 100644 --- a/sponsorblockcast-go.service +++ b/castsponsorskip.service @@ -1,11 +1,11 @@ [Unit] Description=A Go program that skips sponsored YouTube content on all local Google Cast devices -Documentation=https://github.com/gabe565/sponsorblockcast-go +Documentation=https://github.com/gabe565/castsponsorskip After=network.target [Service] Restart=always -ExecStart=/usr/bin/sponsorblockcast-go +ExecStart=/usr/bin/castsponsorskip TimeoutStopSec=20s [Install] diff --git a/cmd/cmd.go b/cmd/cmd.go index 821a348..4e62d46 100644 --- a/cmd/cmd.go +++ b/cmd/cmd.go @@ -8,14 +8,14 @@ import ( "sync" "syscall" - "github.com/gabe565/sponsorblockcast-go/internal/config" - "github.com/gabe565/sponsorblockcast-go/internal/device" + "github.com/gabe565/castsponsorskip/internal/config" + "github.com/gabe565/castsponsorskip/internal/device" "github.com/spf13/cobra" ) func NewCommand() *cobra.Command { cmd := &cobra.Command{ - Use: "sponsorblockcast-go", + Use: "castsponsorskip", Short: "Skip sponsored YouTube segments on local Cast devices", RunE: run, } diff --git a/docker-compose.yaml b/docker-compose.yaml index 1c39a13..35d35e5 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -2,7 +2,7 @@ version: "3.9" services: app: - image: ghcr.io/gabe565/sponsorblockcast-go + image: ghcr.io/gabe565/castsponsorskip environment: SBC_PAUSED_INTERVAL: 1m SBC_PLAYING_INTERVAL: 1s diff --git a/go.mod b/go.mod index 903f32a..9eba1a8 100644 --- a/go.mod +++ b/go.mod @@ -1,4 +1,4 @@ -module github.com/gabe565/sponsorblockcast-go +module github.com/gabe565/castsponsorskip go 1.21 diff --git a/internal/config/viper.go b/internal/config/viper.go index da9db88..3ace94b 100644 --- a/internal/config/viper.go +++ b/internal/config/viper.go @@ -9,11 +9,11 @@ import ( func InitViper() func() { return func() { - viper.SetConfigName("sponsorblockcast-go") + viper.SetConfigName("castsponsorskip") viper.SetConfigType("yaml") viper.AddConfigPath("$HOME/.config/") viper.AddConfigPath("$HOME/") - viper.AddConfigPath("/etc/sponsorblockcast-go/") + viper.AddConfigPath("/etc/castsponsorskip/") viper.AutomaticEnv() viper.SetEnvPrefix("SBC") diff --git a/internal/device/dns.go b/internal/device/dns.go index e0e89cc..9611429 100644 --- a/internal/device/dns.go +++ b/internal/device/dns.go @@ -8,7 +8,7 @@ import ( "net" "time" - "github.com/gabe565/sponsorblockcast-go/internal/config" + "github.com/gabe565/castsponsorskip/internal/config" castdns "github.com/vishen/go-chromecast/dns" ) diff --git a/internal/device/watch.go b/internal/device/watch.go index 0d044b7..17ef7c6 100644 --- a/internal/device/watch.go +++ b/internal/device/watch.go @@ -6,8 +6,8 @@ import ( "log/slog" "time" - "github.com/gabe565/sponsorblockcast-go/internal/config" - "github.com/gabe565/sponsorblockcast-go/internal/sponsorblock" + "github.com/gabe565/castsponsorskip/internal/config" + "github.com/gabe565/castsponsorskip/internal/sponsorblock" "github.com/vishen/go-chromecast/application" "github.com/vishen/go-chromecast/cast/proto" castdns "github.com/vishen/go-chromecast/dns" diff --git a/internal/sponsorblock/query.go b/internal/sponsorblock/query.go index 2c0501e..2222ac9 100644 --- a/internal/sponsorblock/query.go +++ b/internal/sponsorblock/query.go @@ -9,7 +9,7 @@ import ( "net/http" "net/url" - "github.com/gabe565/sponsorblockcast-go/internal/config" + "github.com/gabe565/castsponsorskip/internal/config" ) type Segment struct { diff --git a/main.go b/main.go index 207f5c6..fba904d 100644 --- a/main.go +++ b/main.go @@ -3,7 +3,7 @@ package main import ( "os" - "github.com/gabe565/sponsorblockcast-go/cmd" + "github.com/gabe565/castsponsorskip/cmd" ) func main() {