No description
Find a file
Adam Novak a9683b08a0 Add video ID based query and ReVanced stubs
This adds the endpoints ReVanced queries when opening the settings or watching
videos. The version of skipSegments it uses is actually implrmrnted, and the
others are stubbed out.

I still haven't managed to get ReVanced to actually *work* with this, but it at
least isn't getting any server errors sent to it now.

I've also added my learnings to the README.
2022-10-29 22:42:59 -04:00
.github Build application outside docker for ci. 2022-10-25 10:19:41 +01:00
migrations Initial commit. 2022-10-22 13:28:40 +01:00
src Add video ID based query and ReVanced stubs 2022-10-29 22:42:59 -04:00
.dockerignore Add files to deploy on docker-compose. 2022-10-22 21:43:13 +01:00
.env Initial commit. 2022-10-22 13:28:40 +01:00
.gitignore Initial commit. 2022-10-22 13:28:40 +01:00
Cargo.lock Update Rust crate serde_json to 1.0.87 2022-10-23 22:07:28 +00:00
Cargo.toml Update Rust crate serde_json to 1.0.87 2022-10-23 22:07:28 +00:00
diesel.toml Initial commit. 2022-10-22 13:28:40 +01:00
docker-compose.yml Increase shm size and add depends_on. 2022-10-24 12:58:47 +01:00
Dockerfile Install ca-certificates package. 2022-10-23 17:56:19 +01:00
Dockerfile.ci Build application outside docker for ci. 2022-10-25 10:19:41 +01:00
LICENSE Initial commit 2022-10-22 13:30:03 +01:00
README.md Add video ID based query and ReVanced stubs 2022-10-29 22:42:59 -04:00
renovate.json Update renovate config. 2022-10-23 21:24:49 +01:00
Rocket.toml Add cors for official instance. 2022-10-25 10:13:34 +01:00

sponsorblock-mirror

This is a Rust-based mirror of the SponsorBlock API.

It also uses sb-mirror for mirroring the CSV dumps via rsync.

Instances

Feel free to add your instance to this list by making a pull request.

You can also configure Piped-Backend to use your mirror by changing the SPONSORBLOCK_SERVERS configuration value.

Compatibility

This implementation does not implement the full SponsorBlock server API. It supports hash-based queries to /api/skipSegments/<hash>, with optional categories parameter, and queries to /api/skipSegments with required videoID and optional categories parameters.

The browser extension works with only the hash-based query endpoint, but other clients, such as the one in ReVanced, require the video ID endpoint, and additionally query /api/userInfo and /api/isUserVip. Right now there are stub implementations for these. ReVanced had not yet been verified as compatible.

Building

To make a local release build, use cargo build --release. This will produce a binary in target/release/sponsorblock-mirror.

To make a Docker container, you need to do a BuildKit Docker build, not a normal Docker build. Make sure you have buildx available in your Docker, and run:

docker buildx build --load -t 1337kavin/sponsorblock-mirror .

Using with Docker Compose

To run the server under Docker Compose, run:

docker compose up

This starts the API server, a database, and a mirroring service to download the SponsorBlock data from the sponsorblock.kavin.rocks mirror and keep it up to date.

The API will be available on http://localhost:8000. For example, you can try http://localhost:8000/api/skipSegments/aabf or http://localhost:8000/api/skipSegments?videoID=eQ_8F4nzyiw. It will take a few minutes at least for the database to download and import, so these will not return data on the first run.

Troubleshooting

  • If the linker complains about a missing -lpq, make sure you have the PostgresQL development libraries, which may be in a libpq-dev package or your distribution's equivalent.

  • If Docker complains that the --mount option requires BuildKit, make sure you are building with docker buildx build and not docker build.

  • If docker compose complains like this:

    ERROR: The Compose file './docker-compose.yml' is invalid because:
    Unsupported config option for volumes: 'postgres_data'
    Unsupported config option for services: 'sb-mirror'
    

    then you are using an old version of docker compose which does not fully support the Compose Specification and requires a 'version' key to differentiate the file from a V1 compose file. Try appending version: "3" to the file.

  • On the first run of docker compose, even after the database files are downloaded, you may see errors like could not open file "/mirror/sponsorTimes.csv" for reading: Permission denied. Assuming the permissions on the .csv files are actually set to be world-readable, you might be able to fix this by stopping and restarting docker compose.

  • To access the PosgresQL database directly, you can docker exec -ti postgres-sb-mirror bash -c 'psql $POSTGRES_DB $POSTGRES_USER'.

  • Requests for videos not in the database are forwarded to https://sponsor.ajay.app/, which may be down or malfunctioning. A response of the string Internal Server Error is likely to be from there, rather than from this application.