one click install playlist working

This commit is contained in:
MathieuG-P
2022-12-23 00:29:15 +01:00
parent d556350eef
commit e18caca70f
10 changed files with 54 additions and 54 deletions
-5
View File
@@ -5,15 +5,10 @@ import { UtilsService } from "../services/utils.service";
ipcMain.on("one-click-install-playlist", async (event, request: IpcRequest<string>) => {
console.log("OUI");
const utils = UtilsService.getInstance();
const playlists = LocalPlaylistsManagerService.getInstance();
console.log(request.args);
playlists.oneClickInstallPlaylist(request.args).then(() => {
console.log("C FINI");
utils.ipcSend(request.responceChannel, {success: true});
}).catch(e => {
console.log(e);
+1 -1
View File
@@ -89,7 +89,7 @@ else{
app.whenReady().then(() => {
process.argv.push("bsplaylist://playlist/https://api.beatsaver.com/playlists/id/11137/download/beatsaver-11137.bplist"); // to force deep-link (oneClick map)
process.argv.push("bsplaylist://playlist/https://api.beatsaver.com/playlists/id/11199/download/beatsaver-11199.bplist"); // to force deep-link (oneClick map)
initServicesMustBeInitialized();
@@ -202,8 +202,6 @@ export class LocalMapsManagerService {
}
public async deleteMaps(maps: BsmLocalMap[], verion?: BSVersion){
console.log(verion);
const mapsFolders = await this.getAbsoluteFolderOfMaps(maps, verion);
const mapsHashsToDelete = maps.map(map => map.hash);
@@ -273,12 +271,8 @@ export class LocalMapsManagerService {
public async oneClickDownloadMap(map: BsvMapDetail): Promise<void>{
console.log("AALLLOO");
const downloadedMap = await this.downloadMap(map);
console.log(downloadedMap);
const versions = await this.localVersion.getInstalledVersions();
for(const version of versions){
@@ -289,8 +283,6 @@ export class LocalMapsManagerService {
this.utils.createFolderIfNotExist(versionMapsPath);
console.log(downloadedMap, path.join(versionMapsPath, path.basename(downloadedMap)));
copySync(downloadedMap, path.join(versionMapsPath, path.basename(downloadedMap)), {overwrite: true});
}
@@ -91,13 +91,9 @@ export class LocalPlaylistsManagerService {
const playlistFolder = await this.getPlaylistsFolder(version);
const bpListDest = path.join(playlistFolder, path.basename(bpListUrlOrPath));
console.log("INSTALL BPLIST", bpListUrlOrPath, playlistFolder);
const bpListDest = path.join(playlistFolder, path.basename(bpListUrlOrPath));
if(this.utils.pathExist(bpListUrlOrPath)){
console.log("PATH EXIST", bpListUrlOrPath);
console.log("COPY", bpListUrlOrPath, bpListDest);
copyFileSync(bpListUrlOrPath, bpListDest);
}
else{
@@ -131,12 +127,9 @@ export class LocalPlaylistsManagerService {
public downloadPlaylist(bpListUrl: string, version: BSVersion): Observable<DownloadPlaylistProgression>{
console.log("DOWNLOAD PLAYLIST");
const res = new BehaviorSubject<DownloadPlaylistProgression>({progression: 0, current: null, downloadedMaps: [], mapsPath: [], bpListPath: ""});
const sub = res.subscribe(process => {
console.log("PROGRESS", process);
this.utils.ipcSend("download-playlist-progress", {success: true, data: process});
}, err => {
this.utils.ipcSend("download-playlist-progress", {success: false, error: err});
@@ -169,7 +162,8 @@ export class LocalPlaylistsManagerService {
const progression = ((res.value.downloadedMaps.length + 1) / bpList.songs.length) * 100;
res.next({
...res.value,
...res.value,
current: null,
downloadedMaps: [...res.value.downloadedMaps, map],
mapsPath: [...res.value.mapsPath, mapPath],
progression
@@ -195,8 +189,6 @@ export class LocalPlaylistsManagerService {
const versions = await this.versions.getInstalledVersions();
await timer(2);
const firstVersion = versions.shift();
const fistVersionLinked = await this.maps.versionIsLinked(firstVersion);
@@ -214,8 +206,6 @@ export class LocalPlaylistsManagerService {
const versionMapsFolder = await this.maps.getMapsFolderPath(version);
const mapDest = path.join(versionMapsFolder, path.basename(mapPath));
console.log("COPY MAP", mapPath, mapDest);
copySync(mapPath, mapDest, {overwrite: true});
}
-2
View File
@@ -98,10 +98,8 @@ export class UtilsService{
public ipcSend<T = any>(channel: string, response: IpcResponse<T>): void{
try {
console.log(channel, ...Array.from(this.windows.keys()), response);
Array.from(this.windows.values()).forEach(window => window.webContents.send(channel, response));
} catch (error) {
console.log("ERREUR", error);
log.error(error);
}
}