Skip to content

Commit 6d2cb21

Browse files
authored
Hotfix Build URLs (#11)
Hotfix for issues with build URLs
1 parent 203a60c commit 6d2cb21

5 files changed

Lines changed: 30 additions & 17 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ No need to install other programs as ffmpeg-cli will download and extract necess
1313
## Supported OS
1414
+ MacOS ~ 64 bit
1515
+ Linux ~ 32/64 bit
16-
+ Windows ~ 32/64 bit
16+
+ Windows ~ [~~32/~~](https://github.com/PotatoParser/ffmpeg-cli/issues/9)64 bit
1717

1818
## FFmpeg Path
1919
Returns the path of FFmpeg executable

lib/download.js

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
const fs = require('fs');
2-
const https = require('https');
2+
const { https } = require('follow-redirects');
33
const tar = require('tar');
44
const AdmZip = require('adm-zip');
55
const lzma = require('lzma-native');
@@ -48,7 +48,7 @@ async function getPackage(){
4848
if (fs.existsSync(system.typePath)) rimraf(system.typePath);
4949
if (!fs.existsSync(`${system.rootDir}/ffmpeg`)) fs.mkdirSync(`${system.rootDir}/ffmpeg`);
5050
var downloaded = await new Promise(resolve=>{
51-
https.get(system.url, res => {
51+
https.get(system.url, {headers: {'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.121 Safari/537.36'}}, res => {
5252
res.on('error', ()=>resolve(false));
5353
res.pipe(fs.createWriteStream(system.zipPath)).on('finish', ()=>resolve(true));
5454
let bar = console.bar(parseInt(res.headers['content-length'], 10));
@@ -62,8 +62,14 @@ async function getPackage(){
6262
console.log('Unzipped files');
6363
fs.unlinkSync(system.zipPath);
6464

65-
console.log('Renaming files');
66-
fs.renameSync(temp, system.typePath);
65+
if (system.file) {
66+
console.log('Moving files');
67+
fs.mkdirSync(system.typePath);
68+
fs.renameSync(system.file, system.path);
69+
} else {
70+
console.log('Renaming files');
71+
fs.renameSync(system.dir, system.typePath);
72+
}
6773

6874
console.log('Applying chmod');
6975
fs.readdirSync(system.pathDir, { withFileTypes: true }).forEach(f => {

lib/system.js

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,37 +3,38 @@ const console = require('./console');
33
const rootDir = path.join(__dirname, '..');
44
const OS = process.platform;
55
const BIT = process.arch;
6-
if (!(BIT === 'x32' || BIT === 'x64')) error('CPU architecture not supported');
6+
if (!(BIT === 'x32' || BIT === 'x64')) console.error('CPU architecture not supported');
77
const allOS = {
88
linux: {
99
x32: {
1010
url: 'https://johnvansickle.com/ffmpeg/releases/ffmpeg-release-amd64-static.tar.xz',
11+
dir: rootDir + '/ffmpeg/ffmpeg-4.3.1-amd64-static',
1112
path: rootDir + '/ffmpeg/linuxx32/ffmpeg'
1213
},
1314
x64: {
1415
url: 'https://johnvansickle.com/ffmpeg/releases/ffmpeg-release-i686-static.tar.xz',
16+
dir: rootDir + '/ffmpeg/ffmpeg-4.3.1-i686-static',
1517
path: rootDir + '/ffmpeg/linuxx64/ffmpeg'
1618
}
1719
},
1820
darwin: {
1921
x64: {
20-
url: 'https://ffmpeg.zeranoe.com/builds/macos64/static/ffmpeg-4.2.2-macos64-static.zip',
21-
path: rootDir + '/ffmpeg/darwinx64/bin/ffmpeg'
22+
url: 'https://evermeet.cx/ffmpeg/ffmpeg-4.3.1.zip',
23+
file: rootDir + '/ffmpeg/ffmpeg',
24+
path: rootDir + '/ffmpeg/darwinx64/ffmpeg'
2225
}
2326
},
2427
win32: {
25-
x32: {
26-
url: 'https://ffmpeg.zeranoe.com/builds/win32/static/ffmpeg-latest-win32-static.zip',
27-
path: rootDir + '/ffmpeg/win32x32/bin/ffmpeg.exe'
28-
},
2928
x64: {
30-
url: 'https://ffmpeg.zeranoe.com/builds/win64/static/ffmpeg-latest-win64-static.zip',
29+
url: 'https://github.com/BtbN/FFmpeg-Builds/releases/download/autobuild-2020-09-26-14-24/ffmpeg-n4.3.1-18-g6d886b6586-win64-gpl-4.3.zip',
30+
dir: rootDir + '/ffmpeg/ffmpeg-n4.3.1-18-g6d886b6586-win64-gpl-4.3',
3131
path: rootDir + '/ffmpeg/win32x64/bin/ffmpeg.exe'
3232
}
3333
}
3434
}
35-
if (allOS[OS] === undefined) console.error('OS not supporteds!');
36-
if (allOS[OS][BIT] === undefined) console.error('Invalid OS and CPU architecture!');
35+
if (!allOS[OS]) console.error('OS not supporteds!');
36+
if (!allOS[OS][BIT]) console.error('Invalid OS and CPU architecture!');
37+
3738
module.exports = Object.assign({}, allOS[OS][BIT]);
3839
module.exports.typePath = path.normalize(rootDir + '/ffmpeg/' + OS + BIT);
3940
module.exports.zipPath = path.normalize(rootDir + '/ffmpeg/' + module.exports.url.substring(module.exports.url.lastIndexOf('/')+1));

package-lock.json

Lines changed: 6 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "ffmpeg-cli",
3-
"version": "2.5.2",
3+
"version": "2.6.0",
44
"description": "ffmpeg with support for multiple OSs",
55
"main": "./lib/index.js",
66
"scripts": {
@@ -27,6 +27,7 @@
2727
"homepage": "https://github.com/PotatoParser/ffmpeg-cli#readme",
2828
"dependencies": {
2929
"adm-zip": "^0.4.14",
30+
"follow-redirects": "^1.13.0",
3031
"lzma-native": "^5.0.1",
3132
"progress": "^2.0.3",
3233
"tar": "^6.0.2"

0 commit comments

Comments
 (0)