SponsorBlockServer/README.MD

331 lines
6 KiB
Text
Raw Normal View History

2019-07-18 04:04:04 +02:00
# SponsorBlock Server
2019-07-10 05:11:06 +02:00
2019-07-18 04:04:04 +02:00
SponsorBlock is an extension that will skip over sponsored segments of YouTube videos. SponsorBlock is a crowdsourced browser extension that let's anyone submit the start and end time's of sponsored segments of YouTube videos. Once one person submits this information, everyone else with this extension will skip right over the sponsored segment.
2019-07-10 05:11:06 +02:00
This is the server backend for it
# Server
This is a simple Sqlite database that will hold all the timing data.
To make sure that this project doesn't die, I have made the database publicly downloadable at https://sponsor.ajay.app/database.db. So, you can download a backup or get archive.org to take a backup if you do desire.
Hopefully this project can be combined with projects like [this](https://github.com/Sponsoff/sponsorship_remover) and use this data to create a neural network to predict when sponsored segments happen. That project is sadly abandoned now, so I have decided to attempt to revive this idea.
# Client
2019-07-18 04:04:04 +02:00
The client web browser extension is available here: https://github.com/ajayyy/SponsorBlock
2019-08-04 04:37:35 +02:00
2019-09-11 05:31:16 +02:00
# Build At Home
This is a node.js server, so clone this repo and run `npm install` to install all dependencies.
Make sure to create the databases in the `databases` folder out of the database schemas.
Rename `config.json.example` to `config.json` and fill the parameters inside.
Run the server with `npm start`.
2019-08-04 04:37:35 +02:00
# API Docs
2019-08-04 04:43:14 +02:00
Public API available at https://sponsor.ajay.app.
________________________________________________________________________________
2019-08-13 06:28:14 +02:00
**GET** `/api/getVideoSponsorTimes`
2019-08-04 04:37:35 +02:00
**Input**:
```
{
videoID: string
}
```
**Response**:
```
{
sponorTimes: array [float],
UUIDs: array [string] //The ID for this sponsor time, used to submit votes
}
```
**Error codes**:
2019-08-04 04:40:49 +02:00
2019-08-04 04:37:35 +02:00
404: Not Found
__________________________________________________________________
2019-08-13 06:28:14 +02:00
**GET** `/api/postVideoSponsorTimes`
2019-08-04 04:37:35 +02:00
**Input**:
```
{
videoID: string,
startTime: float,
endTime: float,
userID: string //This should be a randomly generated UUID
}
```
**Response**:
```
2019-08-04 04:41:46 +02:00
{
2019-08-04 04:41:15 +02:00
Nothing (status code 200)
2019-08-04 04:41:46 +02:00
}
2019-08-04 04:37:35 +02:00
```
**Error codes**:
2019-08-04 04:40:49 +02:00
2019-08-04 04:37:35 +02:00
400: Bad Request (Your inputs are wrong/impossible)
2019-08-04 04:40:49 +02:00
2019-08-04 04:37:35 +02:00
429: Rate Limit (Too many for the same user or IP)
2019-08-04 04:40:49 +02:00
2019-08-04 04:37:35 +02:00
409: Duplicate
__________________________________________________________________
2019-08-13 06:28:14 +02:00
**GET** `/api/voteOnSponsorTime`
2019-08-04 04:37:35 +02:00
**Input**:
```
{
UUID: string, //id of the sponsor being voted on
userID: string,
type: int //0 for downvote, 1 for upvote
}
```
**Response**:
```
{
2019-08-04 04:41:15 +02:00
Nothing (status code 200)
2019-08-04 04:37:35 +02:00
}
```
**Error codes**:
2019-08-04 04:40:49 +02:00
2019-08-04 04:37:35 +02:00
400: Bad Request (Your inputs are wrong/impossible)
2019-08-04 04:40:49 +02:00
2019-08-04 04:37:35 +02:00
405: Duplicate
__________________________________________________________________
2019-08-13 06:28:14 +02:00
**GET** `/api/viewedVideoSponsorTime`
2019-08-04 04:37:35 +02:00
**Input**:
```
{
UUID: string
}
```
**Response**:
```
{
2019-08-13 06:29:36 +02:00
Nothing (status code 200)
2019-08-04 04:37:35 +02:00
}
```
**Error codes**:
2019-08-04 04:40:49 +02:00
2019-08-04 04:37:35 +02:00
400: Bad Request (Your inputs are wrong/impossible)
__________________________________________________________________
2019-08-13 06:28:14 +02:00
**GET** `/api/getViewsForUser`
2019-08-04 04:37:35 +02:00
**Input**:
```
{
userID: string
}
```
**Response**:
```
{
viewCount: int
}
```
**Error codes**:
2019-08-04 04:40:49 +02:00
2019-08-04 04:37:35 +02:00
404: Not Found
__________________________________________________________________
2019-08-13 06:28:14 +02:00
**POST** `/api/setUsername`
**Input**:
```
{
userID: string,
2019-09-11 05:28:15 +02:00
userName: string,
//optional
adminUserID: string //This is if you want to change someone elses username from the admin account
2019-08-13 06:28:14 +02:00
}
```
**Response**:
```
{
2019-08-13 06:29:54 +02:00
Nothing (status code 200)
2019-08-13 06:28:14 +02:00
}
```
**Error codes**:
400: Bad Request (Your inputs are wrong/impossible)
__________________________________________________________________
**GET** `/api/getUsername`
2019-08-13 06:28:14 +02:00
**Input**:
```
{
userID: string
}
```
**Response**:
```
{
userName: string //will send back hashed userID if no username has been set
}
```
**Error codes**:
400: Bad Request (Your inputs are wrong/impossible)
__________________________________________________________________
2019-08-04 04:37:35 +02:00
### Stats Calls
2019-08-13 06:28:14 +02:00
**GET** `/api/getTopUsers`
2019-08-04 04:37:35 +02:00
**Input**:
```
{
sortType: int //0 for by minutes saved, 1 for by view count, 2 for by total submissions
}
```
**Response**:
```
{
userNames: array [string],
viewCounts: array [int],
totalSubmissions: array [int],
minutesSaved: array [float]
}
```
**Error codes**:
2019-08-04 04:40:49 +02:00
2019-08-04 04:37:35 +02:00
400: Bad Request (Your inputs are wrong/impossible)
__________________________________________________________________
2019-08-13 06:28:14 +02:00
**GET** `/api/getTotalStats`
2019-08-04 04:37:35 +02:00
**Input**:
```
{
2019-08-04 04:41:15 +02:00
Nothing
2019-08-04 04:37:35 +02:00
}
```
**Response**:
```
{
userCount: int,
viewCount: int,
totalSubmissions: int,
minutesSaved: float
}
```
**Error codes**:
2019-08-04 04:40:49 +02:00
2019-08-04 04:37:35 +02:00
None
2019-09-11 05:28:15 +02:00
__________________________________________________________________
**GET** `/api/getDaysSavedFormatted`
**Input**:
```
{
Nothing
}
```
**Response**:
```
{
daysSaved: float (2 decimal places)
}
```
**Error codes**:
None
__________________________________________________________________
### Admin Calls
These can only be called by the server administrator, set in the config.
**POST** `/api/shadowBanUser`
Shadow banned submissions are hidden for everyone but the IP that originally submitted it. Shadow banning a user shadow bans all future submissions.
**Input**:
```
{
userID: string, //public userID of the user you want to shadowBan
adminUserID: string, //your userID as an admin
enabled: boolean, //optional, to be able to add and remove users
unHideOldSubmissions: boolean //optional, should all previous submissions be banned as well?
}
```
**Response**:
```
{
Nothing (status code 200)
}
```
**Error codes**:
400: Bad Request (Your inputs are wrong/impossible)
403: Unauthorized (You are not an admin)
__________________________________________________________________
**POST** `/api/addUserAsVIP`
VIPs have extra privileges and their votes count more.
**Input**:
```
{
userID: string, //public userID of the user you want to add to the VIP list
adminUserID: string, //your userID as an admin
enabled: boolean //optional, to be able to add and remove users
}
```
**Response**:
```
{
Nothing (status code 200)
}
```
**Error codes**:
400: Bad Request (Your inputs are wrong/impossible)
403: Unauthorized (You are not an admin)