museria 0.2.35 → 0.2.36
Sign up to get free protection for your applications and to get access to all the features.
- package/.github/workflows/build.yml +1 -1
- package/.github/workflows/publish.yml +1 -1
- package/README.md +2 -0
- package/dist/client/museria.client.js +6 -6
- package/dist/face/museria.face.js +8 -8
- package/dist/face/style.css +1 -1
- package/package.json +4 -4
- package/src/browser/face/controllers/app/app.html +7 -0
- package/src/browser/face/controllers/app/app.js +20 -1
- package/src/db/transports/loki/index.js +8 -7
- package/src/node.js +1 -1
- package/src/server/transports/express/index.js +1 -1
- package/test/node.js +0 -16
package/dist/face/style.css
CHANGED
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "museria",
|
3
|
-
"version": "0.2.
|
3
|
+
"version": "0.2.36",
|
4
4
|
"description": "Decentralized music storage",
|
5
5
|
"main": "./src/index.js",
|
6
6
|
"bin": {
|
@@ -77,7 +77,7 @@
|
|
77
77
|
"express": "^4.17.1",
|
78
78
|
"fs-extra": "^9.0.1",
|
79
79
|
"lodash": "^4.17.20",
|
80
|
-
"metastocle": "^0.2.
|
80
|
+
"metastocle": "^0.2.23",
|
81
81
|
"music-metadata": "^6.4.0",
|
82
82
|
"node-fetch": "^2.6.1",
|
83
83
|
"node-id3": "^0.2.2",
|
@@ -86,8 +86,8 @@
|
|
86
86
|
"serve-favicon": "^2.5.0",
|
87
87
|
"sharp": "^0.25.2",
|
88
88
|
"splaytree": "^3.1.0",
|
89
|
-
"spreadable": "^0.2.
|
90
|
-
"storacle": "^0.2.
|
89
|
+
"spreadable": "^0.2.19",
|
90
|
+
"storacle": "^0.2.19",
|
91
91
|
"transliteration": "^2.2.0"
|
92
92
|
},
|
93
93
|
"repository": {
|
@@ -238,6 +238,13 @@
|
|
238
238
|
Once you are here, then the network is public or you have access.
|
239
239
|
You can try to find a song in the storage or add your own there.
|
240
240
|
</div>
|
241
|
+
</li>
|
242
|
+
<li>
|
243
|
+
<div>How many songs are in this node?</div>
|
244
|
+
<div>
|
245
|
+
There are <b class="text-warning">${ this.songsCount }</b> song(s) at the moment. You also can find more info about the node status
|
246
|
+
<a href="/status?pretty" target="_blank">here</a>.
|
247
|
+
</div>
|
241
248
|
</li>
|
242
249
|
<li>
|
243
250
|
<div>How to learn more about all this?</div>
|
@@ -1,6 +1,7 @@
|
|
1
1
|
import './app.scss';
|
2
2
|
import Akili from 'akili';
|
3
3
|
import router from 'akili/src/services/router';
|
4
|
+
import request from 'akili/src/services/request';
|
4
5
|
import client from '../../client';
|
5
6
|
|
6
7
|
export default class App extends Akili.Component {
|
@@ -18,6 +19,9 @@ export default class App extends Akili.Component {
|
|
18
19
|
created() {
|
19
20
|
this.captchaWidth = 240;
|
20
21
|
this.findingSongsLimit = 10;
|
22
|
+
this.songsCountInterval = 10 * 1000;
|
23
|
+
this.songsCountIntervalObj = null;
|
24
|
+
this.scope.songsCount = 0;
|
21
25
|
this.scope.searchInputValue = this.transition.query.f;
|
22
26
|
this.scope.showCaptcha = false;
|
23
27
|
this.scope.isUploading = false;
|
@@ -39,11 +43,16 @@ export default class App extends Akili.Component {
|
|
39
43
|
this.scope.checkUploadSongTitle = this.checkUploadSongTitle.bind(this);
|
40
44
|
this.resetSearchEvent();
|
41
45
|
this.resetUploadEvent();
|
42
|
-
this.resetSongUploadInfo();
|
46
|
+
this.resetSongUploadInfo();
|
43
47
|
}
|
44
48
|
|
45
49
|
async compiled() {
|
46
50
|
this.scope.searchInputValue && await this.findSongs();
|
51
|
+
await this.enableSongsCountCounter();
|
52
|
+
}
|
53
|
+
|
54
|
+
removed() {
|
55
|
+
clearInterval(this.songsCountIntervalObj);
|
47
56
|
}
|
48
57
|
|
49
58
|
resetSearchEvent() {
|
@@ -67,6 +76,16 @@ export default class App extends Akili.Component {
|
|
67
76
|
};
|
68
77
|
}
|
69
78
|
|
79
|
+
async enableSongsCountCounter() {
|
80
|
+
this.songsCountIntervalObj = setInterval(() => this.setSongsCount(), this.songsCountInterval);
|
81
|
+
await this.setSongsCount();
|
82
|
+
}
|
83
|
+
|
84
|
+
async setSongsCount() {
|
85
|
+
const data = (await request.get('/status', { json: true })).data;
|
86
|
+
this.scope.songsCount = data.filesCount;
|
87
|
+
}
|
88
|
+
|
70
89
|
setFindingValue(val) {
|
71
90
|
this.scope.searchInputValue = val;
|
72
91
|
router.reload({}, { f: this.scope.searchInputValue || null }, undefined, { reload: false, saveScrollPosition: true });
|
@@ -2,6 +2,7 @@ const DatabaseMuseria = require('../database')();
|
|
2
2
|
const DatabaseLoki = require('spreadable/src/db/transports/loki')(DatabaseMuseria);
|
3
3
|
const DatabaseLokiMetastocle = require('metastocle/src/db/transports/loki')(DatabaseLoki);
|
4
4
|
const DatabaseLokiStoracle = require('storacle/src/db/transports/loki')(DatabaseLokiMetastocle);
|
5
|
+
const ArrayChunkReader = require('array-chunk-reader');
|
5
6
|
const utils = require('../../../utils');
|
6
7
|
|
7
8
|
module.exports = (Parent) => {
|
@@ -18,13 +19,13 @@ module.exports = (Parent) => {
|
|
18
19
|
similarity: this.node.options.music.similarity
|
19
20
|
}, options);
|
20
21
|
const fullName = this.createCollectionName('music');
|
21
|
-
const collection = await this.node.getCollection('music');
|
22
|
+
const collection = await this.node.getCollection('music');
|
22
23
|
const documents = this.col[fullName].find();
|
24
|
+
const reader = new ArrayChunkReader(documents, { limit: 1000, log: false });
|
23
25
|
let max = null;
|
24
26
|
|
25
|
-
|
26
|
-
|
27
|
-
let score = doc[collection.pk] === title? 1: 0;
|
27
|
+
await reader.start((doc) => {
|
28
|
+
let score = doc[collection.pk] === title? 1: 0;
|
28
29
|
|
29
30
|
if(!score) {
|
30
31
|
score = utils.getSongSimilarity(doc[collection.pk], title, {
|
@@ -35,18 +36,18 @@ module.exports = (Parent) => {
|
|
35
36
|
|
36
37
|
if(score === 1) {
|
37
38
|
max = { score, doc };
|
38
|
-
|
39
|
+
return reader.stop();
|
39
40
|
}
|
40
41
|
|
41
42
|
if(!max || score > max.score) {
|
42
43
|
max = { score, doc };
|
43
|
-
|
44
|
+
return;
|
44
45
|
}
|
45
46
|
|
46
47
|
if(score == max.score && Math.random() > 0.5) {
|
47
48
|
max = { score, doc };
|
48
49
|
}
|
49
|
-
}
|
50
|
+
});
|
50
51
|
|
51
52
|
if(max && max.score >= options.similarity) {
|
52
53
|
return this.prepareDocumentToGet(max.doc);
|
package/src/node.js
CHANGED
@@ -126,7 +126,7 @@ module.exports = (Parent) => {
|
|
126
126
|
async beautifySongTitles() {
|
127
127
|
const docs = await this.db.getDocuments('music');
|
128
128
|
const reader = new ArrayChunkReader(docs, { size: 1000, log: false });
|
129
|
-
reader.start(async (doc) => {
|
129
|
+
await reader.start(async (doc) => {
|
130
130
|
doc.title = utils.beautifySongTitle(doc.title);
|
131
131
|
await this.db.updateDocument(doc);
|
132
132
|
});
|
@@ -29,7 +29,7 @@ module.exports = (Parent) => {
|
|
29
29
|
const remove = [
|
30
30
|
'addDocument', 'updateDocuments',
|
31
31
|
'deleteDocuments', 'getDocumentsCount',
|
32
|
-
'getDocumentByPk'
|
32
|
+
'getDocumentByPk', 'getDocuments'
|
33
33
|
];
|
34
34
|
return super.getClientRoutes().filter(r => !remove.includes(r.name)).concat(routesClient);
|
35
35
|
}
|
package/test/node.js
CHANGED
@@ -376,22 +376,6 @@ describe('Node', () => {
|
|
376
376
|
assert.notEqual(title, beauty, 'check the title');
|
377
377
|
assert.equal(docs[docs.length - 1].title, beauty, 'check the doc');
|
378
378
|
});
|
379
|
-
|
380
|
-
it('should not remove wrong files', async () => {
|
381
|
-
const filePath = await utils.setSongTags(path.join(tools.tmpPath, 'audio.mp3'), { fullTitle: 'another - song' });
|
382
|
-
const hash = await utils.getFileHash(filePath);
|
383
|
-
await node.withAddingFile(hash, async () => {
|
384
|
-
await node.addFileToStorage(filePath, hash, { copy: true });
|
385
|
-
await node.cleanUpMusic();
|
386
|
-
});
|
387
|
-
assert.isTrue(await node.hasFile(hash));
|
388
|
-
});
|
389
|
-
|
390
|
-
it('should remove wrong files', async () => {
|
391
|
-
const hash = await utils.getFileHash(path.join(tools.tmpPath, 'audio.mp3'));
|
392
|
-
await node.cleanUpMusic();
|
393
|
-
assert.isFalse(await node.hasFile(hash));
|
394
|
-
});
|
395
379
|
});
|
396
380
|
|
397
381
|
describe('.getStorageCleaningUpTree()', () => {
|