Skip to content

Commit ca624f4

Browse files
authored
Merge branch 'master' into update-electron
2 parents 8be07bc + 61eb236 commit ca624f4

File tree

3 files changed

+36
-7
lines changed

3 files changed

+36
-7
lines changed

index.js

+19-1
Original file line numberDiff line numberDiff line change
@@ -127,9 +127,27 @@ function createMainWindow() {
127127
autoHideMenuBar: config.get("options.hideMenu"),
128128
});
129129
remote.enable(win.webContents);
130+
130131
if (windowPosition) {
131132
const { x, y } = windowPosition;
132-
win.setPosition(x, y);
133+
const winSize = win.getSize();
134+
const displaySize =
135+
electron.screen.getDisplayNearestPoint(windowPosition).bounds;
136+
if (
137+
x + winSize[0] < displaySize.x - 8 ||
138+
x - winSize[0] > displaySize.x + displaySize.width ||
139+
y < displaySize.y - 8 ||
140+
y > displaySize.y + displaySize.height
141+
) {
142+
//Window is offscreen
143+
if (is.dev()) {
144+
console.log(
145+
`Window tried to render offscreen, windowSize=${winSize}, displaySize=${displaySize}, position=${windowPosition}`
146+
);
147+
}
148+
} else {
149+
win.setPosition(x, y);
150+
}
133151
}
134152
if (windowMaximized) {
135153
win.maximize();

package.json

+11-1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,15 @@
1515
"productName": "YouTube Music",
1616
"mac": {
1717
"identity": null,
18+
"target": [
19+
{
20+
"target": "dmg",
21+
"arch": [
22+
"x64",
23+
"arm64"
24+
]
25+
}
26+
],
1827
"icon": "assets/generated/icons/mac/icon.icns"
1928
},
2029
"win": {
@@ -58,7 +67,8 @@
5867
"clean": "rimraf dist",
5968
"build": "yarn run clean && electron-builder --win --mac --linux",
6069
"build:linux": "yarn run clean && electron-builder --linux",
61-
"build:mac": "yarn run clean && electron-builder --mac",
70+
"build:mac": "yarn run clean && electron-builder --mac dmg:x64",
71+
"build:mac:arm64": "yarn run clean && electron-builder --mac dmg:arm64",
6272
"build:win": "yarn run clean && electron-builder --win",
6373
"lint": "xo",
6474
"plugins": "yarn run plugin:adblocker",

plugins/downloader/menu.js

+6-5
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ const { dialog, ipcMain } = require("electron");
55
const is = require("electron-is");
66
const ytpl = require("ytpl");
77
const chokidar = require('chokidar');
8+
const filenamify = require('filenamify');
89

910
const { setOptions } = require("../../config/plugins");
1011
const { sendError } = require("./back");
@@ -94,10 +95,10 @@ async function downloadPlaylist(givenUrl, win, options) {
9495
sendError(win, e);
9596
return;
9697
}
97-
const playlistTitle = playlist.title;
98+
const safePlaylistTitle = filenamify(playlist.title, {replacement: ' '});
9899

99100
const folder = getFolder(options.downloadFolder);
100-
const playlistFolder = join(folder, playlistTitle);
101+
const playlistFolder = join(folder, safePlaylistTitle);
101102
if (existsSync(playlistFolder)) {
102103
sendError(
103104
win,
@@ -111,13 +112,13 @@ async function downloadPlaylist(givenUrl, win, options) {
111112
type: "info",
112113
buttons: ["OK"],
113114
title: "Started Download",
114-
message: `Downloading Playlist "${playlistTitle}"`,
115+
message: `Downloading Playlist "${playlist.title}"`,
115116
detail: `(${playlist.items.length} songs)`,
116117
});
117118

118119
if (is.dev()) {
119120
console.log(
120-
`Downloading playlist "${playlistTitle}" - ${playlist.items.length} songs (${playlistId})`
121+
`Downloading playlist "${playlist.title}" - ${playlist.items.length} songs (${playlistId})`
121122
);
122123
}
123124

@@ -143,7 +144,7 @@ async function downloadPlaylist(givenUrl, win, options) {
143144
win.webContents.send(
144145
"downloader-download-playlist",
145146
song.url,
146-
playlistTitle,
147+
safePlaylistTitle,
147148
options
148149
);
149150
});

0 commit comments

Comments
 (0)