Small style change

pull/9/head v1.7.0
aandrew-me 3 years ago
parent 74db1be7df
commit 3110d05324

@ -60,8 +60,8 @@ body {
} }
h1 { h2{
font-size: 50px; margin-top:0;
} }
input[type="text"] { input[type="text"] {

@ -28,7 +28,7 @@
</div> </div>
<h1>YouTube Downloader</h1> <h2>YouTube Downloader</h2>
<input type="text" name="url" placeholder="Paste Video URL or ID here" id="url" autofocus> <input type="text" name="url" placeholder="Paste Video URL or ID here" id="url" autofocus>
<!-- Get info button --> <!-- Get info button -->
<button id="getInfo" onclick="clickAnimation('getInfo')">Get info</button> <button id="getInfo" onclick="clickAnimation('getInfo')">Get info</button>

@ -23,13 +23,12 @@ function createWindow() {
win.maximize(); win.maximize();
win.setMenu(null) win.setMenu(null)
win.show(); win.show();
win.webContents.openDevTools() // win.webContents.openDevTools()
autoUpdater.checkForUpdatesAndNotify(); autoUpdater.checkForUpdatesAndNotify();
} }
app.whenReady().then(() => { app.whenReady().then(() => {
createWindow(); createWindow();
app.on("activate", () => { app.on("activate", () => {
if (BrowserWindow.getAllWindows().length === 0) { if (BrowserWindow.getAllWindows().length === 0) {
createWindow(); createWindow();

@ -3,15 +3,14 @@ const ytdl = require("ytdl-core");
const cp = require("child_process"); const cp = require("child_process");
const os = require("os"); const os = require("os");
const ffmpeg = require("ffmpeg-static"); const ffmpeg = require("ffmpeg-static");
const { BrowserWindow, shell, remote, ipcRenderer } = require("electron"); const path = require("path")
const { shell, ipcRenderer, app } = require("electron");
// Directories // Directories
const homedir = os.homedir(); const homedir = os.homedir();
const appdir = homedir + "/.ytDownloader/"; const appdir = path.join(homedir,".ytDownloader");
const tempDir = appdir + "temp/"; const tempDir = path.join(appdir, "temp");
fs.mkdirSync(homedir + "/.ytDownloader/temp", { recursive: true }); fs.mkdirSync(path.join(homedir, ".ytDownloader/temp"), { recursive: true });
let config; let config;
// Download directory // Download directory
@ -33,40 +32,6 @@ else{
// Clearing tempDir // Clearing tempDir
fs.readdirSync(tempDir).forEach((f) => fs.rmSync(`${tempDir}/${f}`)); fs.readdirSync(tempDir).forEach((f) => fs.rmSync(`${tempDir}/${f}`));
// Handling download location input from user
async function checkPath(path) {
const check = new Promise((resolve, reject) => {
fs.readdir(path, (err) => {
// If directory doesn't exist, try creating it
if (err) {
fs.mkdir(path, (err) => {
if (err) {
reject(err);
} else {
console.log("Successfully created " + path);
resolve(true);
}
});
} else {
fs.writeFile(path + "/.test", "", (err) => {
// If that location is not accessible
if (err) {
reject(err);
} else {
fs.rm(path + "/.test", (err) => {
if (err) console.log(err);
});
resolve(true);
}
});
}
});
});
const result = await check;
return result;
}
// Collecting info from youtube // Collecting info from youtube
async function getVideoInfo(url) { async function getVideoInfo(url) {
let info; let info;
@ -291,7 +256,7 @@ function download(type) {
resolve("video downloaded"); resolve("video downloaded");
} }
}) })
.pipe(fs.createWriteStream(tempDir + videoName)); .pipe(fs.createWriteStream(path.join(tempDir, videoName)));
}), }),
new Promise((resolve, reject) => { new Promise((resolve, reject) => {
@ -310,16 +275,16 @@ function download(type) {
resolve("audio downloaded"); resolve("audio downloaded");
} }
}) })
.pipe(fs.createWriteStream(tempDir + audioName)); .pipe(fs.createWriteStream(path.join(tempDir, audioName)));
}), }),
]; ];
Promise.all([arr[0], arr[1]]) Promise.all([arr[0], arr[1]])
.then((response) => { .then((response) => {
cp.exec( cp.exec(
`"${ffmpeg}" -i "${tempDir + videoName}" -i "${ `"${ffmpeg}" -i "${path.join(tempDir, videoName)}" -i "${
tempDir + audioName path.join(tempDir, audioName)
}" -c copy "${downloadDir + "/" + filename}"`, }" -c copy "${path.join(downloadDir, filename)}"`,
(error, stdout, stderr) => { (error, stdout, stderr) => {
if (error) { if (error) {
console.log(error); console.log(error);
@ -353,7 +318,7 @@ function download(type) {
afterSave(downloadDir, filename); afterSave(downloadDir, filename);
} }
}) })
.pipe(fs.createWriteStream(downloadDir + "/" + filename)); .pipe(fs.createWriteStream(path.join(downloadDir, filename)));
} }
}); });
} }
@ -374,7 +339,8 @@ function afterSave(location, filename) {
).innerHTML = `File saved. Click to open <b title="Click to open" class="savedMsg">${location}</b>`; ).innerHTML = `File saved. Click to open <b title="Click to open" class="savedMsg">${location}</b>`;
getId("savedMsg").addEventListener("click", (e) => { getId("savedMsg").addEventListener("click", (e) => {
shell.showItemInFolder(location + "/" + filename); shell.showItemInFolder(path.join(location, filename));
log(path.join(location, filename))
}); });
} }

Loading…
Cancel
Save