Merge pull request #645 from Zagrios/bugfix/fix-oneclick-download-playlist-broken

[bugfix] Fix broken oneclick playlist download + issue with specials chars in playlists filenames
This commit is contained in:
MathieuG-P
2024-11-05 20:42:23 +01:00
committed by GitHub
3 changed files with 6 additions and 4 deletions
@@ -123,7 +123,7 @@ export class LocalPlaylistsManagerService {
const dest = await (async () => {
if(opt.dest && path.isAbsolute(opt.dest) && this.acceptPlaylistFiletype(opt.dest)) { return opt.dest; }
const playlistFolder = await this.getPlaylistsFolder(opt.version);
return path.join(playlistFolder, filename);
return path.join(playlistFolder, sanitize(filename));
})();
writeFileSync(dest, JSON.stringify(bpList, null, 2));
+2 -1
View File
@@ -8,6 +8,7 @@ import { unlinkSync } from "fs-extra";
import { tryit } from "shared/helpers/error.helpers";
import path from "path";
import { pipeline } from "stream/promises";
import sanitize from "sanitize-filename";
export class RequestService {
private static instance: RequestService;
@@ -66,7 +67,7 @@ export class RequestService {
const filename = opt?.preferContentDisposition ? this.getFilenameFromContentDisposition(response.headers["content-disposition"]) : null;
if (filename) {
dest = path.join(path.dirname(dest), filename);
dest = path.join(path.dirname(dest), sanitize(filename));
}
progress.data = dest;
+3 -2
View File
@@ -8,8 +8,9 @@ export function resolveHtmlPath (htmlFileName: string) {
const url = new URL(`http://localhost:${port}/${htmlFileName}`);
return url.toString();
}
const filePath = path.resolve(__dirname, "..", "renderer", htmlFileName);
return pathToFileURL(filePath).toString();
const filePath = path.resolve(__dirname, "..", "renderer");
return pathToFileURL(filePath).toString().concat("/", htmlFileName);
};