test
This commit is contained in:
parent
5f78adabc7
commit
5d3853d208
5 changed files with 217 additions and 127 deletions
|
@ -45,6 +45,7 @@ export class BrowserWindow {
|
|||
private headerSent: any = false;
|
||||
private chromecastIP: any = [];
|
||||
private localSongs: any = [];
|
||||
private localSongsArts: any = [];
|
||||
private clientPort: number = 0;
|
||||
private remotePort: number = 6942;
|
||||
private EnvironmentVariables: object = {
|
||||
|
@ -550,16 +551,23 @@ export class BrowserWindow {
|
|||
res.send(`// Theme not found - ${userThemePath}`);
|
||||
}
|
||||
});
|
||||
|
||||
app.get("/ciderlocal/:songs", (req, res) => {
|
||||
const audio = atob(req.params.songs.replace(/_/g, '/').replace(/-/g, '+'));
|
||||
console.log('auss', audio)
|
||||
let data = {
|
||||
data:
|
||||
this.localSongs.filter((f: any) => audio.split(',').includes(f.id))
|
||||
};
|
||||
//console.log('auss', audio)
|
||||
let data = {data:
|
||||
this.localSongs.filter((f: any) => audio.split(',').includes(f.id))};
|
||||
res.send(data);
|
||||
});
|
||||
|
||||
app.get("/ciderlocalart/:songs", (req, res) => {
|
||||
const audio = req.params.songs;
|
||||
// metadata.common.picture[0].data.toString('base64')
|
||||
let data =
|
||||
this.localSongsArts.filter((f: any) => f.id == audio);
|
||||
res.status(200).send(Buffer.from(data[0]?.url, 'base64'));
|
||||
});
|
||||
|
||||
|
||||
app.get("/themes/:theme/*", (req: { params: { theme: string, 0: string } }, res) => {
|
||||
const theme = req.params.theme;
|
||||
|
@ -675,7 +683,7 @@ export class BrowserWindow {
|
|||
});
|
||||
} else if (details.url.includes("ciderlocal")) {
|
||||
let text = details.url.toString().includes('ids=') ? decodeURIComponent(details.url.toString()).split("?ids=")[1] : decodeURIComponent(details.url.toString().substring(details.url.toString().lastIndexOf('/') + 1));
|
||||
console.log('localurl', text)
|
||||
//console.log('localurl',text)
|
||||
callback({
|
||||
redirectURL: `http://localhost:${this.clientPort}/ciderlocal/${Buffer.from(text).toString('base64url')}`,
|
||||
});
|
||||
|
@ -1198,69 +1206,70 @@ export class BrowserWindow {
|
|||
return dirent.isDirectory() ? getFiles(res) : res;
|
||||
}));
|
||||
return Array.prototype.concat(...files);
|
||||
}
|
||||
if (folders == null || folders.length == null || folders.length == 0) folders = ["D:\\Music"]
|
||||
console.log('folders', folders)
|
||||
let files: any[] = []
|
||||
for (var folder of folders) {
|
||||
// get files from the Music folder
|
||||
files = files.concat(await getFiles(folder))
|
||||
}
|
||||
|
||||
//console.log("cider.files", files2);
|
||||
let supporttedformats = ["mp3", "aac", "webm", "flac", "m4a", "ogg", "wav", "opus"]
|
||||
let audiofiles = files.filter(f => supporttedformats.includes(f.substring(f.lastIndexOf('.') + 1)));
|
||||
// console.log("cider.files2", audiofiles, audiofiles.length);
|
||||
let metadatalist = []
|
||||
let numid = 0;
|
||||
for (var audio of audiofiles) {
|
||||
try {
|
||||
const metadata = await mm.parseFile(audio);
|
||||
if (metadata != null) {
|
||||
let form = {
|
||||
"id": "ciderlocal" + numid,
|
||||
"type": "podcast-episodes",
|
||||
"href": audio,
|
||||
"attributes": {
|
||||
"artwork": {
|
||||
"width": 3000,
|
||||
"height": 3000,
|
||||
"url": metadata.common.picture != undefined ? "data:image/png;base64," + metadata.common.picture[0].data.toString('base64') + "" : "",
|
||||
},
|
||||
"topics": [],
|
||||
"url": "",
|
||||
"subscribable": true,
|
||||
"mediaKind": "audio",
|
||||
"genreNames": [
|
||||
""
|
||||
],
|
||||
// "playParams": {
|
||||
// "id": "ciderlocal" + numid,
|
||||
// "kind": "podcast",
|
||||
// "isLibrary": true,
|
||||
// "reporting": false },
|
||||
"trackNumber": metadata.common.track?.no ?? 0,
|
||||
"discNumber": metadata.common.disk?.no ?? 0,
|
||||
"name": metadata.common.title ?? audio.substring(audio.lastIndexOf('\\') + 1),
|
||||
"albumName": metadata.common.album,
|
||||
"artistName": metadata.common.artist,
|
||||
"copyright": metadata.common.copyright ?? "",
|
||||
"assetUrl": "file:///" + audio,
|
||||
"contentAdvisory": "",
|
||||
"releaseDateTime": "2022-05-13T00:23:00Z",
|
||||
"durationInMilliseconds": Math.floor((metadata.format.duration ?? 0) * 1000),
|
||||
|
||||
"offers": [
|
||||
{
|
||||
"kind": "get",
|
||||
"type": "STDQ"
|
||||
}
|
||||
],
|
||||
"contentRating": "clean"
|
||||
}
|
||||
};
|
||||
numid += 1;
|
||||
|
||||
}
|
||||
if (folders == null || folders.length == null || folders.length == 0) folders = ["D:\\Music"]
|
||||
console.log('folders', folders)
|
||||
let files: any[] = []
|
||||
for (var folder of folders){
|
||||
// get files from the Music folder
|
||||
files = files.concat(await getFiles(folder))
|
||||
}
|
||||
|
||||
//console.log("cider.files", files2);
|
||||
let supporttedformats = ["mp3", "aac", "webm", "flac", "m4a", "ogg", "wav", "opus"]
|
||||
let audiofiles = files.filter(f => supporttedformats.includes(f.substring(f.lastIndexOf('.') + 1)));
|
||||
// console.log("cider.files2", audiofiles, audiofiles.length);
|
||||
let metadatalist = []
|
||||
let metadatalistart = []
|
||||
let numid = 0;
|
||||
for (var audio of audiofiles) {
|
||||
try{
|
||||
const metadata = await mm.parseFile(audio);
|
||||
if (metadata != null){
|
||||
let form = {
|
||||
"id": "ciderlocal" + numid,
|
||||
"type": "podcast-episodes",
|
||||
"href": audio,
|
||||
"attributes": {
|
||||
"artwork": {
|
||||
"width": 3000,
|
||||
"height": 3000,
|
||||
"url": "/ciderlocalart/" + "ciderlocal" + numid,
|
||||
},
|
||||
"topics": [],
|
||||
"url": "",
|
||||
"subscribable": true,
|
||||
"mediaKind": "audio",
|
||||
"genreNames": [
|
||||
""
|
||||
],
|
||||
// "playParams": {
|
||||
// "id": "ciderlocal" + numid,
|
||||
// "kind": "podcast",
|
||||
// "isLibrary": true,
|
||||
// "reporting": false },
|
||||
"trackNumber": metadata.common.track?.no ?? 0,
|
||||
"discNumber": metadata.common.disk?.no ?? 0,
|
||||
"name": metadata.common.title ?? audio.substring(audio.lastIndexOf('\\') + 1),
|
||||
"albumName": metadata.common.album,
|
||||
"artistName": metadata.common.artist,
|
||||
"copyright": metadata.common.copyright ?? "",
|
||||
"assetUrl": "file:///" +audio,
|
||||
"contentAdvisory": "",
|
||||
"releaseDateTime": "2022-05-13T00:23:00Z",
|
||||
"durationInMilliseconds": Math.floor((metadata.format.duration?? 0) * 1000),
|
||||
|
||||
"offers": [
|
||||
{
|
||||
"kind": "get",
|
||||
"type": "STDQ"
|
||||
}
|
||||
],
|
||||
"contentRating": "clean"
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
// let form = {"id": "/ciderlocal?" + audio,
|
||||
// "type": "library-songs",
|
||||
// "href": "/ciderlocal?" + audio,
|
||||
|
@ -1277,9 +1286,18 @@ export class BrowserWindow {
|
|||
// "name": metadata.common.title,
|
||||
// "albumName": metadata.common.album,
|
||||
// "artistName": metadata.common.artist}}
|
||||
metadatalist.push(form)
|
||||
}
|
||||
} catch (e) { }
|
||||
metadatalistart.push({
|
||||
id : "ciderlocal" + numid,
|
||||
url: metadata.common.picture != undefined ? metadata.common.picture[0].data.toString('base64') : "",
|
||||
})
|
||||
numid += 1;
|
||||
metadatalist.push(form)}
|
||||
} catch (e){}
|
||||
}
|
||||
// console.log('metadatalist', metadatalist);
|
||||
this.localSongs = metadatalist;
|
||||
this.localSongsArts = metadatalistart;
|
||||
BrowserWindow.win.webContents.send('getUpdatedLocalList', metadatalist);
|
||||
}
|
||||
// console.log('metadatalist', metadatalist);
|
||||
this.localSongs = metadatalist;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue