-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
21 changed files
with
661 additions
and
464 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,8 @@ | ||
const { getCurrentWindow } = require('@electron/remote') | ||
const { windowAlwaysOnTop } = require('../../utils/window-always-on-top') | ||
const { ELEMENTS } = require('../../utils/elements') | ||
|
||
const settingsForm = ELEMENTS.settingsForm | ||
|
||
settingsForm.alwaysOnTop.onchange = () => { | ||
getCurrentWindow().setAlwaysOnTop(settingsForm.alwaysOnTop.checked) | ||
windowAlwaysOnTop(settingsForm.alwaysOnTop.checked) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
const modal = document.querySelector('dialog') | ||
helpBtn.onclick = () => modal.showModal() | ||
const { ELEMENTS } = require('../../utils/elements') | ||
|
||
const closeBtn = modal.querySelector('button') | ||
closeBtn.onclick = () => modal.close() | ||
ELEMENTS.helpBtn.onclick = () => ELEMENTS.modal.showModal() | ||
ELEMENTS.closeBtn.onclick = () => ELEMENTS.modal.close() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
const path = require('path') | ||
const homedir = require('os').homedir(); | ||
|
||
const destDownloadFolder = homedir + '/veditbox' | ||
|
||
class CONSTANTS { | ||
static destDownloadFolder = destDownloadFolder; | ||
static videoFilePath = (ext = 'mp4') => createPath(ext); | ||
static audioFilePath = (ext = 'wav') => createPath(ext); | ||
static imageFilePath = (ext = 'png') => createPath(ext); | ||
} | ||
|
||
function createPath(ext) { | ||
return path.join(destDownloadFolder, `${new Date().toJSON().replace(/\W/g, '')}.${ext}`) | ||
} | ||
|
||
module.exports = { CONSTANTS } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
const fs = require('fs'); | ||
const { CONSTANTS } = require('./constants') | ||
|
||
const create = () => { | ||
const dir = CONSTANTS.destDownloadFolder | ||
|
||
if (!fs.existsSync(dir)){ | ||
fs.mkdirSync(dir); | ||
} | ||
} | ||
|
||
module.exports = { create } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
class ELEMENTS { | ||
static getElement = (selector) => document.querySelector(selector) | ||
|
||
static setElement = (name, selector) => { | ||
return this[name] = this.getElement(selector) | ||
} | ||
} | ||
|
||
ELEMENTS.setElement('mainArea', '#mainArea') | ||
ELEMENTS.setElement('settingsForm', '#settingsForm') | ||
ELEMENTS.setElement('statusText', '#statusText') | ||
ELEMENTS.setElement('modal', 'dialog') | ||
ELEMENTS.setElement('helpBtn', '#helpBtn') | ||
ELEMENTS.setElement('closeBtn', 'dialog button') | ||
|
||
module.exports = { ELEMENTS } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
const axios = require('axios') | ||
// const os = require('os') | ||
const fs = require('fs') | ||
const YTDlpWrap = require('yt-dlp-wrap').default; | ||
const DownloadDirectory = require('./create-download-directory') | ||
const { CONSTANTS } = require('./constants'); | ||
|
||
const filePath = `${CONSTANTS.destDownloadFolder}/yt-dlp` | ||
|
||
async function downloadLatestRelease() { | ||
try { | ||
if(fs.existsSync(filePath)) return | ||
|
||
console.log('downloading yt-dlp') | ||
//Get the data from the github releases API. In this case get page 1 with a maximum of 5 items. | ||
let githubReleasesData = await YTDlpWrap.getGithubReleases(1, 5); | ||
|
||
// const platform = os.platform(); | ||
const assets = githubReleasesData[0].assets | ||
// let releases = assets.filter(asset => asset.name.includes(platform)); | ||
let release = assets.find(asset => asset.name === "yt-dlp"); | ||
|
||
// if (releases.length === 0) { | ||
// throw new Error(`No release assets found for platform: ${platform}`); | ||
// } | ||
|
||
if(!release) throw new Error('No release found') | ||
|
||
const downloadUrl = release.browser_download_url; | ||
const downloadResponse = await axios.get(downloadUrl, { responseType: 'stream' }); | ||
|
||
const fileWriter = fs.createWriteStream(filePath); | ||
downloadResponse.data.pipe(fileWriter); | ||
|
||
return new Promise((resolve, reject) => { | ||
fileWriter.on('finish', resolve); | ||
fileWriter.on('error', reject); | ||
}); | ||
} catch (error) { | ||
console.error('Error occurred while downloading release:', error); | ||
} | ||
} | ||
|
||
|
||
(async() => { | ||
DownloadDirectory.create() | ||
|
||
await downloadLatestRelease() | ||
//Download the yt-dlp binary for the given version and platform to the provided path. | ||
//By default the latest version will be downloaded to "./yt-dlp" and platform = os.platform(). | ||
await YTDlpWrap.downloadFromGithub(filePath); | ||
|
||
})() | ||
|
||
module.exports = new YTDlpWrap(filePath); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
const { CONSTANTS } = require('./constants') | ||
const { showStatus } = require('./show-status') | ||
|
||
globalThis.destDownloadFolder = CONSTANTS.destDownloadFolder | ||
|
||
globalThis.activeThing = { dispose: () => {} } | ||
module.exports.activeThing = globalThis.activeThing | ||
|
||
globalThis.showStatus = showStatus | ||
module.exports.showStatus = showStatus |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
const { ELEMENTS } = require('./elements') | ||
|
||
const showStatus = (text, color = 'white') => { | ||
ELEMENTS.statusText.textContent = text | ||
ELEMENTS.statusText.style.color = color | ||
} | ||
|
||
module.exports = { showStatus } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
const { getCurrentWindow } = require('@electron/remote') | ||
|
||
const windowAlwaysOnTop = (onTop) => { | ||
getCurrentWindow().setAlwaysOnTop(onTop) | ||
} | ||
|
||
module.exports = { windowAlwaysOnTop } |
Oops, something went wrong.