mirror of
https://github.com/ajayyy/SponsorBlockServer.git
synced 2024-11-10 01:02:30 +01:00
commit
c60d7ed75e
4 changed files with 11 additions and 9 deletions
|
@ -8,7 +8,7 @@ This is the server backend for it
|
|||
|
||||
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://api.sponsor.ajay.app/database.db (formerly https://sponsor.ajay.app/database.db). You can download a backup or get archive.org to take a backup if you do desire. The database is under [this license](https://creativecommons.org/licenses/by-nc-sa/4.0/) unless you get explicit permission from me.
|
||||
To make sure that this project doesn't die, I have made the database publicly downloadable at https://sponsor.ajay.app/database.db. You can download a backup or get archive.org to take a backup if you do desire. The database is under [this license](https://creativecommons.org/licenses/by-nc-sa/4.0/) unless you get explicit permission from me.
|
||||
|
||||
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.
|
||||
|
||||
|
|
|
@ -26,7 +26,6 @@ var getDaysSavedFormatted = require('./routes/getDaysSavedFormatted.js');
|
|||
var oldGetVideoSponsorTimes = require('./routes/oldGetVideoSponsorTimes.js');
|
||||
var oldSubmitSponsorTimes = require('./routes/oldSubmitSponsorTimes.js');
|
||||
|
||||
|
||||
//setup CORS correctly
|
||||
app.use(corsMiddleware);
|
||||
app.use(loggerMiddleware);
|
||||
|
@ -35,6 +34,9 @@ app.use(express.json())
|
|||
// Setup pretty JSON
|
||||
if (config.mode === "development") app.set('json spaces', 2);
|
||||
|
||||
// Set production mode
|
||||
app.set('env', config.mode || 'production');
|
||||
|
||||
//add the get function
|
||||
app.get('/api/getVideoSponsorTimes', oldGetVideoSponsorTimes);
|
||||
|
||||
|
@ -82,10 +84,10 @@ app.get('/api/getTopUsers', getTopUsers);
|
|||
app.get('/api/getTotalStats', getTotalStats);
|
||||
|
||||
//send out a formatted time saved total
|
||||
app.get('/api/getdayssavedformatted', getDaysSavedFormatted);
|
||||
app.get('/api/getDaysSavedFormatted', getDaysSavedFormatted);
|
||||
|
||||
app.get('/database.db', function (req, res) {
|
||||
res.sendfile("./databases/sponsortimes.db", { root: __dirname });
|
||||
res.sendFile("./databases/sponsorTimes.db", { root: "./" });
|
||||
});
|
||||
|
||||
// Create an HTTP service.
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
var db = require('../databases/databases.js');
|
||||
var db = require('../databases/databases.js').db;
|
||||
|
||||
module.exports = function getDaysSavedFormatted (req, res) {
|
||||
let row = db.prepare("select sum((endtime - starttime) / 60 / 60 / 24 * views) as dayssaved from sponsortimes where shadowhidden != 1").get();
|
||||
let row = db.prepare("SELECT SUM((endTime - startTime) / 60 / 60 / 24 * views) as daysSaved from sponsorTimes where shadowHidden != 1").get();
|
||||
|
||||
if (row !== undefined) {
|
||||
//send this result
|
||||
res.send({
|
||||
dayssaved: row.dayssaved.tofixed(2)
|
||||
daysSaved: row.daysSaved.toFixed(2)
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
2
test.js
2
test.js
|
@ -34,7 +34,7 @@ var mockServer = createMockServer(() => {
|
|||
mocha.run(function(failures) {
|
||||
mockServer.close();
|
||||
server.close();
|
||||
process.exitCode = failures ? 1 : 0; // exit with non-zero status if there were failures
|
||||
process.exit(failures ? 1 : 0); // exit with non-zero status if there were failures
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue