mirror of
https://github.com/DIYgod/DPlayer
synced 2024-11-22 18:56:54 +00:00
back-end: id list
This commit is contained in:
parent
1d22794bde
commit
697dbdf5bd
15
README.md
15
README.md
@ -56,7 +56,7 @@ var option = {
|
||||
pic: '若能绽放光芒.png' // Optional, music picture
|
||||
},
|
||||
danmaku: { // Optional, showing danmaku
|
||||
id: '9E2E3368B56CDBB4', // Required, danmaku id, MUST BE UNIQUE
|
||||
id: '9E2E3368B56CDBB4', // Required, danmaku id, MUST BE UNIQUE, CAN NOT USE THESE IN YOUR NEW PLAYER: `https://dplayer.daoapp.io/list`
|
||||
api: 'https://dplayer.daoapp.io/', // Required, danmaku api
|
||||
token: 'tokendemo' // Optional, danmaku token for api
|
||||
}
|
||||
@ -90,6 +90,19 @@ var dp = new DPlayer({
|
||||
});
|
||||
```
|
||||
|
||||
### Danmaku back-end
|
||||
|
||||
**Ready-made API:**
|
||||
|
||||
`https://dplayer.daoapp.io/`
|
||||
|
||||
**Build yourself:**
|
||||
|
||||
Required environment
|
||||
|
||||
- Node.js
|
||||
- Mongodb
|
||||
|
||||
## Run in development
|
||||
|
||||
```
|
||||
|
@ -35,7 +35,9 @@ else {
|
||||
}
|
||||
|
||||
var danmakuSchema = new mongoose.Schema({
|
||||
player: String,
|
||||
player: {
|
||||
type: [String], index: true
|
||||
},
|
||||
author: String,
|
||||
time: Number,
|
||||
text: String,
|
||||
@ -218,4 +220,36 @@ app.post('/', function (req, res) {
|
||||
}
|
||||
});
|
||||
|
||||
app.get('/list', function (req, res) {
|
||||
mongoose.connect(mongodbUrl);
|
||||
var db = mongoose.connection;
|
||||
db.on('error', errorListener);
|
||||
|
||||
db.once('open', function() {
|
||||
cleanListener();
|
||||
danmaku.distinct('player', function (err, data) {
|
||||
if (err) {
|
||||
logger.error(err);
|
||||
}
|
||||
|
||||
var json = ``;
|
||||
for (var i = 0; i < data.length; i++) {
|
||||
json += data[i] + `<br>`;
|
||||
}
|
||||
res.send(json);
|
||||
db.close();
|
||||
})
|
||||
});
|
||||
|
||||
function errorListener (err) {
|
||||
cleanListener();
|
||||
logger.error(err);
|
||||
res.send(`{"code": 0, "msg": "Error happens, please contact system administrator."}`);
|
||||
}
|
||||
|
||||
function cleanListener () {
|
||||
db.removeListener('error', errorListener);
|
||||
}
|
||||
});
|
||||
|
||||
app.listen(1207);
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "dplayer",
|
||||
"version": "0.1.0",
|
||||
"version": "0.1.2",
|
||||
"description": "Wow, such a lovely HTML5 danmaku video player",
|
||||
"main": "dist/DPlayer.min.js",
|
||||
"scripts": {
|
||||
|
Loading…
Reference in New Issue
Block a user