some test
This commit is contained in:
parent
f0ceaae958
commit
d872087685
4 changed files with 30 additions and 9 deletions
|
@ -68,11 +68,13 @@
|
||||||
"node-ssdp": "^4.0.1",
|
"node-ssdp": "^4.0.1",
|
||||||
"pouchdb-adapter-leveldb": "^7.3.0",
|
"pouchdb-adapter-leveldb": "^7.3.0",
|
||||||
"pouchdb-node": "^7.3.0",
|
"pouchdb-node": "^7.3.0",
|
||||||
|
"pouchdb-upsert": "^2.2.0",
|
||||||
"qrcode": "^1.5.0",
|
"qrcode": "^1.5.0",
|
||||||
"react": "^18.0.0",
|
"react": "^18.0.0",
|
||||||
"react-dom": "^18.0.0",
|
"react-dom": "^18.0.0",
|
||||||
"run-script-os": "^1.1.6",
|
"run-script-os": "^1.1.6",
|
||||||
"source-map-support": "^0.5.21",
|
"source-map-support": "^0.5.21",
|
||||||
|
"ts-md5": "^1.2.11",
|
||||||
"v8-compile-cache": "^2.3.0",
|
"v8-compile-cache": "^2.3.0",
|
||||||
"wallpaper": "5.0.1",
|
"wallpaper": "5.0.1",
|
||||||
"ws": "^8.5.0",
|
"ws": "^8.5.0",
|
||||||
|
|
|
@ -1185,6 +1185,8 @@ export class BrowserWindow {
|
||||||
|
|
||||||
|
|
||||||
ipcMain.handle("scanLibrary", async (event, folders) => {
|
ipcMain.handle("scanLibrary", async (event, folders) => {
|
||||||
|
const oldmetadatalist = await LocalFiles.sendOldLibrary()
|
||||||
|
BrowserWindow.win.webContents.send('getUpdatedLocalList', oldmetadatalist);
|
||||||
const metadatalist = await LocalFiles.scanLibrary()
|
const metadatalist = await LocalFiles.scanLibrary()
|
||||||
BrowserWindow.win.webContents.send('getUpdatedLocalList', metadatalist);
|
BrowserWindow.win.webContents.send('getUpdatedLocalList', metadatalist);
|
||||||
})
|
})
|
||||||
|
|
|
@ -1,8 +1,12 @@
|
||||||
import * as PouchDB from 'pouchdb-node';
|
import * as PouchDB from 'pouchdb-node';
|
||||||
|
import {join} from 'path';
|
||||||
|
import {app} from "electron";
|
||||||
|
PouchDB.plugin(require('pouchdb-upsert'));
|
||||||
export class ProviderDB {
|
export class ProviderDB {
|
||||||
public static db: any = null
|
public static db: any = null
|
||||||
static async init() {
|
static init() {
|
||||||
// ProviderDB.db = new PouchDB('tracks')
|
if (ProviderDB.db == null){
|
||||||
|
ProviderDB.db = new PouchDB(join(app.getPath('userData'), 'tracksdb'))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,16 +1,26 @@
|
||||||
// import { ProviderDB } from "./db";
|
import { ProviderDB } from "./db";
|
||||||
import * as path from 'path';
|
import * as path from 'path';
|
||||||
const { readdir } = require('fs').promises;
|
const { readdir } = require('fs').promises;
|
||||||
import { utils } from '../../base/utils';
|
import { utils } from '../../base/utils';
|
||||||
import * as mm from 'music-metadata';
|
import * as mm from 'music-metadata';
|
||||||
|
import {Md5} from 'ts-md5/dist/md5';
|
||||||
|
|
||||||
export class LocalFiles {
|
export class LocalFiles {
|
||||||
static localSongs: any = [];
|
static localSongs: any = [];
|
||||||
static localSongsArts: any = [];
|
static localSongsArts: any = [];
|
||||||
// public static DB = ProviderDB.db;
|
public static DB = ProviderDB.db;
|
||||||
|
|
||||||
|
static async sendOldLibrary() {
|
||||||
|
ProviderDB.init()
|
||||||
|
let u = (await ProviderDB.db.allDocs({include_docs: true,
|
||||||
|
attachments: true})).rows.map((item: any)=>{return item.doc})
|
||||||
|
this.localSongs = u;
|
||||||
|
console.log('sdadad', u.length)
|
||||||
|
return u;
|
||||||
|
}
|
||||||
|
|
||||||
static async scanLibrary() {
|
static async scanLibrary() {
|
||||||
|
ProviderDB.init()
|
||||||
let folders = utils.getStoreValue("libraryPrefs.localPaths")
|
let folders = utils.getStoreValue("libraryPrefs.localPaths")
|
||||||
if (folders == null || folders.length == null || folders.length == 0) folders = ["D:\\Music"]
|
if (folders == null || folders.length == null || folders.length == 0) folders = ["D:\\Music"]
|
||||||
console.log('folders', folders)
|
console.log('folders', folders)
|
||||||
|
@ -30,16 +40,18 @@ export class LocalFiles {
|
||||||
for (var audio of audiofiles) {
|
for (var audio of audiofiles) {
|
||||||
try {
|
try {
|
||||||
const metadata = await mm.parseFile(audio);
|
const metadata = await mm.parseFile(audio);
|
||||||
|
let lochash = Md5.hashStr(audio) ?? numid;
|
||||||
if (metadata != null) {
|
if (metadata != null) {
|
||||||
let form = {
|
let form = {
|
||||||
"id": "ciderlocal" + numid,
|
"id": "ciderlocal" + lochash,
|
||||||
|
"_id": "ciderlocal" + lochash,
|
||||||
"type": "podcast-episodes",
|
"type": "podcast-episodes",
|
||||||
"href": audio,
|
"href": audio,
|
||||||
"attributes": {
|
"attributes": {
|
||||||
"artwork": {
|
"artwork": {
|
||||||
"width": 3000,
|
"width": 3000,
|
||||||
"height": 3000,
|
"height": 3000,
|
||||||
"url": "/ciderlocalart/" + "ciderlocal" + numid,
|
"url": "/ciderlocalart/" + "ciderlocal" + lochash,
|
||||||
},
|
},
|
||||||
"topics": [],
|
"topics": [],
|
||||||
"url": "",
|
"url": "",
|
||||||
|
@ -74,10 +86,11 @@ export class LocalFiles {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
metadatalistart.push({
|
metadatalistart.push({
|
||||||
id: "ciderlocal" + numid,
|
id: "ciderlocal" + lochash,
|
||||||
url: metadata.common.picture != undefined ? metadata.common.picture[0].data.toString('base64') : "",
|
url: metadata.common.picture != undefined ? metadata.common.picture[0].data.toString('base64') : "",
|
||||||
})
|
})
|
||||||
numid += 1;
|
numid += 1;
|
||||||
|
ProviderDB.db.putIfNotExists(form)
|
||||||
metadatalist.push(form)
|
metadatalist.push(form)
|
||||||
}
|
}
|
||||||
} catch (e) { }
|
} catch (e) { }
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue