Skip to content

Commit

Permalink
Merge pull request #645 from Zagrios/bugfix/fix-oneclick-download-pla…
Browse files Browse the repository at this point in the history
…ylist-broken

[bugfix] Fix broken oneclick playlist download + issue with specials chars in playlists filenames
  • Loading branch information
Zagrios authored Nov 5, 2024
2 parents b7eb136 + 9e60dc4 commit d5f2ba3
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
3 changes: 2 additions & 1 deletion src/main/services/request.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
5 changes: 3 additions & 2 deletions src/main/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
};


0 comments on commit d5f2ba3

Please sign in to comment.