From 8ef8ccf49bb402c00fb1caf7aca670b8e9cd7428 Mon Sep 17 00:00:00 2001 From: Wilson Nguyen Date: Sat, 26 Sep 2020 13:08:38 -0700 Subject: [PATCH 1/4] Hotfix for issues with build URLs --- README.md | 2 +- lib/download.js | 15 +++++++++++---- lib/system.js | 25 +++++++++++++------------ package-lock.json | 5 +++++ package.json | 1 + 5 files changed, 31 insertions(+), 17 deletions(-) diff --git a/README.md b/README.md index 3d40643..7b0de98 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,7 @@ No need to install other programs as ffmpeg-cli will download and extract necess ## Supported OS + MacOS ~ 64 bit + Linux ~ 32/64 bit -+ Windows ~ 32/64 bit ++ Windows ~ [~~32/~~](https://github.com/PotatoParser/ffmpeg-cli/issues/9)64 bit ## FFmpeg Path Returns the path of FFmpeg executable diff --git a/lib/download.js b/lib/download.js index 8eb3811..ae89111 100644 --- a/lib/download.js +++ b/lib/download.js @@ -1,5 +1,5 @@ const fs = require('fs'); -const https = require('https'); +const { https } = require('follow-redirects'); const tar = require('tar'); const AdmZip = require('adm-zip'); const lzma = require('lzma-native'); @@ -29,6 +29,7 @@ function decompressXZ(file) { } function decompressZip(file) { let zip = AdmZip(file); + console.log(require('util').inspect(zip.getEntries().map(i => i.name))); zip.extractAllTo(`${system.rootDir}/ffmpeg`, true); return file.substring(0, file.lastIndexOf('.')); } @@ -48,7 +49,7 @@ async function getPackage(){ if (fs.existsSync(system.typePath)) rimraf(system.typePath); if (!fs.existsSync(`${system.rootDir}/ffmpeg`)) fs.mkdirSync(`${system.rootDir}/ffmpeg`); var downloaded = await new Promise(resolve=>{ - https.get(system.url, res => { + 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 => { res.on('error', ()=>resolve(false)); res.pipe(fs.createWriteStream(system.zipPath)).on('finish', ()=>resolve(true)); let bar = console.bar(parseInt(res.headers['content-length'], 10)); @@ -62,8 +63,14 @@ async function getPackage(){ console.log('Unzipped files'); fs.unlinkSync(system.zipPath); - console.log('Renaming files'); - fs.renameSync(temp, system.typePath); + if (system.file) { + console.log('Moving files'); + fs.mkdirSync(system.typePath); + fs.renameSync(system.file, system.path); + } else { + console.log('Renaming files'); + fs.renameSync(system.dir, system.typePath); + } console.log('Applying chmod'); fs.readdirSync(system.pathDir, { withFileTypes: true }).forEach(f => { diff --git a/lib/system.js b/lib/system.js index 97b7142..6e8fd6d 100644 --- a/lib/system.js +++ b/lib/system.js @@ -1,39 +1,40 @@ const path = require('path'); const console = require('./console'); const rootDir = path.join(__dirname, '..'); -const OS = process.platform; -const BIT = process.arch; -if (!(BIT === 'x32' || BIT === 'x64')) error('CPU architecture not supported'); +const OS = 'darwin';//process.platform; +const BIT = 'x64';//process.arch; +if (!(BIT === 'x32' || BIT === 'x64')) console.error('CPU architecture not supported'); const allOS = { linux: { x32: { url: 'https://johnvansickle.com/ffmpeg/releases/ffmpeg-release-amd64-static.tar.xz', + dir: rootDir + '/ffmpeg/ffmpeg-release-amd64-static', path: rootDir + '/ffmpeg/linuxx32/ffmpeg' }, x64: { url: 'https://johnvansickle.com/ffmpeg/releases/ffmpeg-release-i686-static.tar.xz', + dir: rootDir + '/ffmpeg/ffmpeg-release-i686-static', path: rootDir + '/ffmpeg/linuxx64/ffmpeg' } }, darwin: { x64: { - url: 'https://ffmpeg.zeranoe.com/builds/macos64/static/ffmpeg-4.2.2-macos64-static.zip', - path: rootDir + '/ffmpeg/darwinx64/bin/ffmpeg' + url: 'https://evermeet.cx/ffmpeg/ffmpeg-4.3.1.zip', + file: rootDir + '/ffmpeg/ffmpeg', + path: rootDir + '/ffmpeg/darwinx64/ffmpeg' } }, win32: { - x32: { - url: 'https://ffmpeg.zeranoe.com/builds/win32/static/ffmpeg-latest-win32-static.zip', - path: rootDir + '/ffmpeg/win32x32/bin/ffmpeg.exe' - }, x64: { - url: 'https://ffmpeg.zeranoe.com/builds/win64/static/ffmpeg-latest-win64-static.zip', + 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', + dir: rootDir + '/ffmpeg/ffmpeg-n4.3.1-18-g6d886b6586-win64-gpl-4.3', path: rootDir + '/ffmpeg/win32x64/bin/ffmpeg.exe' } } } -if (allOS[OS] === undefined) console.error('OS not supporteds!'); -if (allOS[OS][BIT] === undefined) console.error('Invalid OS and CPU architecture!'); +if (!allOS[OS]) console.error('OS not supporteds!'); +if (!allOS[OS][BIT]) console.error('Invalid OS and CPU architecture!'); + module.exports = Object.assign({}, allOS[OS][BIT]); module.exports.typePath = path.normalize(rootDir + '/ffmpeg/' + OS + BIT); module.exports.zipPath = path.normalize(rootDir + '/ffmpeg/' + module.exports.url.substring(module.exports.url.lastIndexOf('/')+1)); diff --git a/package-lock.json b/package-lock.json index 6beb0e4..715999c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -87,6 +87,11 @@ "resolved": "https://registry.npmjs.org/detect-libc/-/detect-libc-1.0.3.tgz", "integrity": "sha1-+hN8S9aY7fVc1c0CrFWfkaTEups=" }, + "follow-redirects": { + "version": "1.13.0", + "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.13.0.tgz", + "integrity": "sha512-aq6gF1BEKje4a9i9+5jimNFIpq4Q1WiwBToeRK5NvZBd/TRsmW8BsJfOEGkr76TbOyPVD3OVDN910EcUNtRYEA==" + }, "fs-minipass": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/fs-minipass/-/fs-minipass-2.1.0.tgz", diff --git a/package.json b/package.json index f272e54..aef5161 100644 --- a/package.json +++ b/package.json @@ -27,6 +27,7 @@ "homepage": "https://github.com/PotatoParser/ffmpeg-cli#readme", "dependencies": { "adm-zip": "^0.4.14", + "follow-redirects": "^1.13.0", "lzma-native": "^5.0.1", "progress": "^2.0.3", "tar": "^6.0.2" From 8bedda962c7385109ec6f78ee8cb369b4a6223e5 Mon Sep 17 00:00:00 2001 From: Wilson Nguyen Date: Sat, 26 Sep 2020 13:10:11 -0700 Subject: [PATCH 2/4] Remove excess outputs --- lib/download.js | 1 - lib/system.js | 4 ++-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/lib/download.js b/lib/download.js index ae89111..038f4fb 100644 --- a/lib/download.js +++ b/lib/download.js @@ -29,7 +29,6 @@ function decompressXZ(file) { } function decompressZip(file) { let zip = AdmZip(file); - console.log(require('util').inspect(zip.getEntries().map(i => i.name))); zip.extractAllTo(`${system.rootDir}/ffmpeg`, true); return file.substring(0, file.lastIndexOf('.')); } diff --git a/lib/system.js b/lib/system.js index 6e8fd6d..8b167a8 100644 --- a/lib/system.js +++ b/lib/system.js @@ -1,8 +1,8 @@ const path = require('path'); const console = require('./console'); const rootDir = path.join(__dirname, '..'); -const OS = 'darwin';//process.platform; -const BIT = 'x64';//process.arch; +const OS = process.platform; +const BIT = process.arch; if (!(BIT === 'x32' || BIT === 'x64')) console.error('CPU architecture not supported'); const allOS = { linux: { From 7eb596f1eaeac976f9829046ea2ae87ca310c1c6 Mon Sep 17 00:00:00 2001 From: Wilson Nguyen Date: Sat, 26 Sep 2020 13:21:13 -0700 Subject: [PATCH 3/4] Change paths --- lib/system.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/system.js b/lib/system.js index 8b167a8..89065db 100644 --- a/lib/system.js +++ b/lib/system.js @@ -8,12 +8,12 @@ const allOS = { linux: { x32: { url: 'https://johnvansickle.com/ffmpeg/releases/ffmpeg-release-amd64-static.tar.xz', - dir: rootDir + '/ffmpeg/ffmpeg-release-amd64-static', + dir: rootDir + '/ffmpeg/ffmpeg-4.3.1-amd64-static', path: rootDir + '/ffmpeg/linuxx32/ffmpeg' }, x64: { url: 'https://johnvansickle.com/ffmpeg/releases/ffmpeg-release-i686-static.tar.xz', - dir: rootDir + '/ffmpeg/ffmpeg-release-i686-static', + dir: rootDir + '/ffmpeg/ffmpeg-4.3.1-i686-static', path: rootDir + '/ffmpeg/linuxx64/ffmpeg' } }, From 60a55405987ad27235e395df85082b62b943ee82 Mon Sep 17 00:00:00 2001 From: Wilson Nguyen Date: Sat, 26 Sep 2020 13:25:45 -0700 Subject: [PATCH 4/4] 2.6.0 --- package-lock.json | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package-lock.json b/package-lock.json index 715999c..26db5e2 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "ffmpeg-cli", - "version": "2.5.2", + "version": "2.6.0", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index aef5161..189a108 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ffmpeg-cli", - "version": "2.5.2", + "version": "2.6.0", "description": "ffmpeg with support for multiple OSs", "main": "./lib/index.js", "scripts": {