Skip to content

Commit 81db0f1

Browse files
authored
Merge pull request #4 from JEMcats-Software/dev
release 1.0.1-beta
2 parents dc0b4f9 + 37a33c2 commit 81db0f1

11 files changed

Lines changed: 739 additions & 560 deletions

File tree

README.md

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,18 @@
33
VideoSnatcher by JEMcats-Software allows for you to download videos from Youtube and similer platforms.
44

55
## To-Do List
6+
- [ ] Batch Downloads
7+
- [ ] Audio Extraction For Video Only Instances
68
- [ ] Fix The Problems Of Youtube Outputs (m4a's work best)
79
- [ ] Add Dark Mode
810
- [ ] Add Windows Support
911
- [ ] Add Download Progress Bar
10-
- [ ] Launch v1.0.0-beta
11-
12-
## Requirements
13-
You MUST have Rosetta installed if you are on a Mac with Apple Silicon. To do so please run this command in terminal.
14-
```
15-
/usr/sbin/softwareupdate --install-rosetta
16-
```
12+
- [ ] Write Documentation
13+
- [ ] Add Customizable Output Path
14+
- [x] Fix Saving Videos
15+
- [x] Auto Install Rosetta
16+
- [x] Add Website
17+
- [x] Launch v1.0.0-beta
1718

1819
## Support
1920
For questions open a discussion.
@@ -41,4 +42,5 @@ No closed-source forks or redistributions allowed.
4142

4243
## Credits
4344

44-
- [YT-DLP](https://github.com/yt-dlp/yt-dlp) (The runtime that make this possible)
45+
- [YT-DLP](https://github.com/yt-dlp/yt-dlp) (The runtime that make this possible)
46+
- [FFMPEG](https://github.com/FFmpeg/FFmpeg) (Combines video and audio + extracts audio)

index.js

Lines changed: 19 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,13 @@ const os = require('os');
77
const https = require('https'); // Add this import
88
const { v4: uuidv4 } = require('uuid');
99
const { Decoder } = require('ts-ebml');
10+
const { shell } = require('electron');
1011

12+
let savePath = path.join(os.homedir(), 'Downloads');
1113

1214
const expressApp = express();
1315
let serverPort, ytWin;
1416
let youtubeCookies = "";
15-
1617
const baseDir = path.join(os.homedir(), 'Library/Application Support/videosnatcher');
1718
const logsDir = path.join(baseDir, 'logs');
1819
const liveLogPath = path.join(logsDir, 'live.log');
@@ -347,6 +348,13 @@ app.whenReady().then(() => {
347348
path.join(executablesDir, 'yt-dlp-mac'),
348349
'https://jemcats.software/github_pages/VideoSnatcher/files/yt-dlp-mac'
349350
);
351+
exec('/usr/sbin/softwareupdate --install-rosetta --agree-to-license', (error, stdout, stderr) => {
352+
if (error) {
353+
console.error(`Error installing Rosetta: ${error.message}`);
354+
} else {
355+
console.log('Rosetta installed successfully.');
356+
}
357+
});
350358
ensureFile(
351359
path.join(executablesDir, 'ffmpeg-mac'),
352360
'https://jemcats.software/github_pages/VideoSnatcher/files/ffmpeg-mac'
@@ -359,42 +367,17 @@ expressApp.get('/get_vid', (req, res) => {
359367

360368
if (!videoPath) return res.status(400).send('Missing "path" parameter');
361369

362-
const stream = fs.createReadStream(videoPath);
363-
stream.on('error', (err) => {
364-
console.error(err);
365-
res.status(500).send('Error reading video file');
366-
});
367-
const ext = path.extname(videoPath).toLowerCase();
368-
if (ext === '.mp4') {
369-
const stat = fs.statSync(videoPath);
370-
const ebmlDecoder = new Decoder();
371-
const fileBuffer = fs.readFileSync(videoPath);
372-
const elements = ebmlDecoder.decode(fileBuffer);
373-
const isAudioOnly = elements.some(element => element.name === 'TrackType' && element.value === 2); // Check if the file contains audio-only tracks
374-
if (isAudioOnly) {
375-
res.setHeader('Content-Type', 'audio/mp4');
376-
} else {
377-
res.setHeader('Content-Type', 'video/mp4');
378-
}
379-
} else if (ext === '.webm') {
380-
const stat = fs.statSync(videoPath);
381-
const ebmlDecoder = new Decoder();
382-
const fileBuffer = fs.readFileSync(videoPath);
383-
const elements = ebmlDecoder.decode(fileBuffer);
384-
const isAudioOnly = elements.some(element => element.name === 'TrackType' && element.value === 2); // Check if the file contains audio-only tracks
385-
if (isAudioOnly) {
386-
res.setHeader('Content-Type', 'audio/webm');
387-
} else {
388-
res.setHeader('Content-Type', 'video/webm');
370+
const destinationPath = path.join(savePath, path.basename(videoPath));
371+
372+
fs.rename(videoPath, destinationPath, (err) => {
373+
if (err) {
374+
console.error('Error moving file:', err);
375+
return res.status(500).send('Error moving file');
389376
}
390-
} else if (ext === '.mp3') {
391-
res.setHeader('Content-Type', 'audio/mp3');
392-
} else if (ext === '.m4a') {
393-
res.setHeader('Content-Type', 'audio/m4a');
394-
} else {
395-
res.setHeader('Content-Type', 'application/octet-stream');
396-
}
397-
stream.pipe(res);
377+
shell.showItemInFolder(destinationPath);
378+
res.send(JSON.stringify({ path: destinationPath }));
379+
});
380+
398381
});
399382

400383
app.on('window-all-closed', () => {

0 commit comments

Comments
 (0)