mirror of
https://github.com/Zagrios/bs-manager.git
synced 2026-07-03 14:08:25 +02:00
create one click install playlist window
This commit is contained in:
@@ -35,4 +35,15 @@ ipcMain.on("bsv-get-map-details-by-id", async (event, request: IpcRequest<string
|
||||
}).catch(e => {
|
||||
utlis.ipcSend(request.responceChannel, {success: false, error: e});
|
||||
})
|
||||
});
|
||||
|
||||
ipcMain.on("bsv-get-playlist-details-by-id", async (event, request: IpcRequest<string>) => {
|
||||
const utlis = UtilsService.getInstance();
|
||||
const bsvService = BeatSaverService.getInstance();
|
||||
|
||||
bsvService.getPlaylistPage(request.args).then(maps => {
|
||||
utlis.ipcSend(request.responceChannel, {success: true, data: maps});
|
||||
}).catch(e => {
|
||||
utlis.ipcSend(request.responceChannel, {success: false, error: e});
|
||||
})
|
||||
});
|
||||
@@ -1,6 +1,5 @@
|
||||
import path from "path";
|
||||
import { BehaviorSubject } from "rxjs";
|
||||
import { Observable } from "rxjs";
|
||||
import { BehaviorSubject, Observable } from "rxjs";
|
||||
import { BSVersion } from "shared/bs-version.interface";
|
||||
import { BsvPlaylist, BsvPlaylistPage } from "shared/models/maps/beat-saver.model";
|
||||
import { BSLocalVersionService } from "../bs-local-version.service";
|
||||
@@ -47,12 +46,12 @@ export class LocalPlaylistsManagerService {
|
||||
this.windows = WindowManagerService.getInstance();
|
||||
|
||||
this.deepLink.addLinkOpenedListener(this.DEEP_LINKS.BeatSaver, link => {
|
||||
|
||||
log.info("DEEP-LINK RECEIVED FROM", this.DEEP_LINKS.BeatSaver, link);
|
||||
const url = new URL(link);
|
||||
const bplistUrl = url.host === "playlist" ? url.pathname.replace("/", "") : "";
|
||||
const playlistId = this.getPlaylistIdFromDownloadUrl(bplistUrl);
|
||||
|
||||
this.openOneClickDownloadPlaylistWindow(playlistId);
|
||||
this.openOneClickDownloadPlaylistWindow(bplistUrl);
|
||||
|
||||
});
|
||||
|
||||
@@ -91,10 +90,10 @@ export class LocalPlaylistsManagerService {
|
||||
// TODO
|
||||
}
|
||||
|
||||
private openOneClickDownloadPlaylistWindow(playlistId: string): void{
|
||||
private openOneClickDownloadPlaylistWindow(downloadUrl: string): void{
|
||||
|
||||
ipcMain.once("one-click-playlist-info", async (event, req: IpcRequest<void>) => {
|
||||
this.utils.ipcSend(req.responceChannel, {success: true, data: playlistId});
|
||||
ipcMain.on("one-click-playlist-info", async (event, req: IpcRequest<void>) => {
|
||||
this.utils.ipcSend(req.responceChannel, {success: true, data: {bpListUrl: downloadUrl, id: this.getPlaylistIdFromDownloadUrl(downloadUrl)}});
|
||||
});
|
||||
|
||||
this.windows.openWindow("oneclick-download-playlist.html");
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { ApiResult } from "renderer/models/api/api.model";
|
||||
import { BsvMapDetail } from "shared/models/maps";
|
||||
import { BsvPlaylistPage, MapFilter, SearchParams, SearchResponse } from "shared/models/maps/beat-saver.model";
|
||||
import { BsvPlaylist, BsvPlaylistPage, MapFilter, SearchParams, SearchResponse } from "shared/models/maps/beat-saver.model";
|
||||
import fetch from "node-fetch"
|
||||
|
||||
export class BeatSaverApiService {
|
||||
@@ -121,13 +121,13 @@ export class BeatSaverApiService {
|
||||
|
||||
}
|
||||
|
||||
public async getPlaylistDetails(id: number): Promise<ApiResult<BsvPlaylistPage>>{
|
||||
public async getPlaylistDetails(id: string): Promise<ApiResult<BsvPlaylist>>{
|
||||
|
||||
const res = await fetch(`${this.bsaverApiUrl}/playlists/id/${id}`);
|
||||
const res = await fetch(`${this.bsaverApiUrl}/playlists/id/${id}/0`);
|
||||
|
||||
const data = await res.json() as BsvPlaylistPage;
|
||||
|
||||
return {status: res.status, data};
|
||||
return {status: res.status, data: data.playlist};
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -66,7 +66,7 @@ export class BeatSaverService {
|
||||
|
||||
}
|
||||
|
||||
public async getPlaylistPage(id: number): Promise<BsvPlaylistPage>{
|
||||
public async getPlaylistPage(id: string): Promise<BsvPlaylist>{
|
||||
|
||||
const res = await this.bsaverApi.getPlaylistDetails(id);
|
||||
return res.data;
|
||||
|
||||
Reference in New Issue
Block a user