mirror of
https://github.com/th-ch/youtube-music.git
synced 2026-01-11 10:31:47 +00:00
Merge branch 'master' into update-electron
This commit is contained in:
20
index.js
20
index.js
@ -127,9 +127,27 @@ function createMainWindow() {
|
|||||||
autoHideMenuBar: config.get("options.hideMenu"),
|
autoHideMenuBar: config.get("options.hideMenu"),
|
||||||
});
|
});
|
||||||
remote.enable(win.webContents);
|
remote.enable(win.webContents);
|
||||||
|
|
||||||
if (windowPosition) {
|
if (windowPosition) {
|
||||||
const { x, y } = windowPosition;
|
const { x, y } = windowPosition;
|
||||||
win.setPosition(x, y);
|
const winSize = win.getSize();
|
||||||
|
const displaySize =
|
||||||
|
electron.screen.getDisplayNearestPoint(windowPosition).bounds;
|
||||||
|
if (
|
||||||
|
x + winSize[0] < displaySize.x - 8 ||
|
||||||
|
x - winSize[0] > displaySize.x + displaySize.width ||
|
||||||
|
y < displaySize.y - 8 ||
|
||||||
|
y > displaySize.y + displaySize.height
|
||||||
|
) {
|
||||||
|
//Window is offscreen
|
||||||
|
if (is.dev()) {
|
||||||
|
console.log(
|
||||||
|
`Window tried to render offscreen, windowSize=${winSize}, displaySize=${displaySize}, position=${windowPosition}`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
win.setPosition(x, y);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (windowMaximized) {
|
if (windowMaximized) {
|
||||||
win.maximize();
|
win.maximize();
|
||||||
|
|||||||
12
package.json
12
package.json
@ -15,6 +15,15 @@
|
|||||||
"productName": "YouTube Music",
|
"productName": "YouTube Music",
|
||||||
"mac": {
|
"mac": {
|
||||||
"identity": null,
|
"identity": null,
|
||||||
|
"target": [
|
||||||
|
{
|
||||||
|
"target": "dmg",
|
||||||
|
"arch": [
|
||||||
|
"x64",
|
||||||
|
"arm64"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
"icon": "assets/generated/icons/mac/icon.icns"
|
"icon": "assets/generated/icons/mac/icon.icns"
|
||||||
},
|
},
|
||||||
"win": {
|
"win": {
|
||||||
@ -58,7 +67,8 @@
|
|||||||
"clean": "rimraf dist",
|
"clean": "rimraf dist",
|
||||||
"build": "yarn run clean && electron-builder --win --mac --linux",
|
"build": "yarn run clean && electron-builder --win --mac --linux",
|
||||||
"build:linux": "yarn run clean && electron-builder --linux",
|
"build:linux": "yarn run clean && electron-builder --linux",
|
||||||
"build:mac": "yarn run clean && electron-builder --mac",
|
"build:mac": "yarn run clean && electron-builder --mac dmg:x64",
|
||||||
|
"build:mac:arm64": "yarn run clean && electron-builder --mac dmg:arm64",
|
||||||
"build:win": "yarn run clean && electron-builder --win",
|
"build:win": "yarn run clean && electron-builder --win",
|
||||||
"lint": "xo",
|
"lint": "xo",
|
||||||
"plugins": "yarn run plugin:adblocker",
|
"plugins": "yarn run plugin:adblocker",
|
||||||
|
|||||||
@ -5,6 +5,7 @@ const { dialog, ipcMain } = require("electron");
|
|||||||
const is = require("electron-is");
|
const is = require("electron-is");
|
||||||
const ytpl = require("ytpl");
|
const ytpl = require("ytpl");
|
||||||
const chokidar = require('chokidar');
|
const chokidar = require('chokidar');
|
||||||
|
const filenamify = require('filenamify');
|
||||||
|
|
||||||
const { setOptions } = require("../../config/plugins");
|
const { setOptions } = require("../../config/plugins");
|
||||||
const { sendError } = require("./back");
|
const { sendError } = require("./back");
|
||||||
@ -94,10 +95,10 @@ async function downloadPlaylist(givenUrl, win, options) {
|
|||||||
sendError(win, e);
|
sendError(win, e);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const playlistTitle = playlist.title;
|
const safePlaylistTitle = filenamify(playlist.title, {replacement: ' '});
|
||||||
|
|
||||||
const folder = getFolder(options.downloadFolder);
|
const folder = getFolder(options.downloadFolder);
|
||||||
const playlistFolder = join(folder, playlistTitle);
|
const playlistFolder = join(folder, safePlaylistTitle);
|
||||||
if (existsSync(playlistFolder)) {
|
if (existsSync(playlistFolder)) {
|
||||||
sendError(
|
sendError(
|
||||||
win,
|
win,
|
||||||
@ -111,13 +112,13 @@ async function downloadPlaylist(givenUrl, win, options) {
|
|||||||
type: "info",
|
type: "info",
|
||||||
buttons: ["OK"],
|
buttons: ["OK"],
|
||||||
title: "Started Download",
|
title: "Started Download",
|
||||||
message: `Downloading Playlist "${playlistTitle}"`,
|
message: `Downloading Playlist "${playlist.title}"`,
|
||||||
detail: `(${playlist.items.length} songs)`,
|
detail: `(${playlist.items.length} songs)`,
|
||||||
});
|
});
|
||||||
|
|
||||||
if (is.dev()) {
|
if (is.dev()) {
|
||||||
console.log(
|
console.log(
|
||||||
`Downloading playlist "${playlistTitle}" - ${playlist.items.length} songs (${playlistId})`
|
`Downloading playlist "${playlist.title}" - ${playlist.items.length} songs (${playlistId})`
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -143,7 +144,7 @@ async function downloadPlaylist(givenUrl, win, options) {
|
|||||||
win.webContents.send(
|
win.webContents.send(
|
||||||
"downloader-download-playlist",
|
"downloader-download-playlist",
|
||||||
song.url,
|
song.url,
|
||||||
playlistTitle,
|
safePlaylistTitle,
|
||||||
options
|
options
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user