Skip to content

Commit d5f2ba3

Browse files
authored
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
2 parents b7eb136 + 9e60dc4 commit d5f2ba3

File tree

3 files changed

+6
-4
lines changed

3 files changed

+6
-4
lines changed

src/main/services/additional-content/local-playlists-manager.service.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ export class LocalPlaylistsManagerService {
123123
const dest = await (async () => {
124124
if(opt.dest && path.isAbsolute(opt.dest) && this.acceptPlaylistFiletype(opt.dest)) { return opt.dest; }
125125
const playlistFolder = await this.getPlaylistsFolder(opt.version);
126-
return path.join(playlistFolder, filename);
126+
return path.join(playlistFolder, sanitize(filename));
127127
})();
128128

129129
writeFileSync(dest, JSON.stringify(bpList, null, 2));

src/main/services/request.service.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { unlinkSync } from "fs-extra";
88
import { tryit } from "shared/helpers/error.helpers";
99
import path from "path";
1010
import { pipeline } from "stream/promises";
11+
import sanitize from "sanitize-filename";
1112

1213
export class RequestService {
1314
private static instance: RequestService;
@@ -66,7 +67,7 @@ export class RequestService {
6667
const filename = opt?.preferContentDisposition ? this.getFilenameFromContentDisposition(response.headers["content-disposition"]) : null;
6768

6869
if (filename) {
69-
dest = path.join(path.dirname(dest), filename);
70+
dest = path.join(path.dirname(dest), sanitize(filename));
7071
}
7172

7273
progress.data = dest;

src/main/util.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,9 @@ export function resolveHtmlPath (htmlFileName: string) {
88
const url = new URL(`http://localhost:${port}/${htmlFileName}`);
99
return url.toString();
1010
}
11-
const filePath = path.resolve(__dirname, "..", "renderer", htmlFileName);
12-
return pathToFileURL(filePath).toString();
11+
12+
const filePath = path.resolve(__dirname, "..", "renderer");
13+
return pathToFileURL(filePath).toString().concat("/", htmlFileName);
1314
};
1415

1516

0 commit comments

Comments
 (0)