From 60afa917c8ee23778d8f800f4c6df6c2da8dd28d Mon Sep 17 00:00:00 2001 From: Bruno Date: Tue, 18 Aug 2020 15:38:16 -0300 Subject: [PATCH] removes details file --- lib/downloader.js | 10 ---------- lib/get-binary.js | 20 -------------------- lib/youtube-dl.js | 7 ++++--- 3 files changed, 4 insertions(+), 33 deletions(-) delete mode 100644 lib/get-binary.js diff --git a/lib/downloader.js b/lib/downloader.js index 1268afa..da42b19 100644 --- a/lib/downloader.js +++ b/lib/downloader.js @@ -14,7 +14,6 @@ const isOverwrite = flags.includes('--overwrite') // First, look for the download link. let dir, filePath const defaultBin = path.join(__dirname, '..', 'bin') -const defaultPath = path.join(defaultBin, 'details') const url = process.env.YOUTUBE_DL_DOWNLOAD_HOST || 'https://yt-dl.org/downloads/latest/youtube-dl' function download (url, callback) { @@ -101,15 +100,6 @@ function downloader (binDir, callback) { download(url, function error (err, newVersion) { if (err) return callback(err) - fs.writeFileSync( - defaultPath, - JSON.stringify({ - version: newVersion, - path: binDir ? filePath : binDir, - exec: exec('youtube-dl') - }), - 'utf8' - ) return callback(null, 'Downloaded youtube-dl ' + newVersion) }) } diff --git a/lib/get-binary.js b/lib/get-binary.js deleted file mode 100644 index 6d94a95..0000000 --- a/lib/get-binary.js +++ /dev/null @@ -1,20 +0,0 @@ -'use strict' - -const debug = require('debug')('youtube-dl') -const { readFileSync, existsSync } = require('fs') -const path = require('path') - -const binPath = path.join(__dirname, '..', 'bin') -const detailsPath = path.join(binPath, 'details') - -module.exports = () => { - if (!existsSync(detailsPath)) { - debug('unable to locate `youtube-dl` at ' + binPath) - } - - const details = JSON.parse(readFileSync(detailsPath)) - - return details.path - ? details.path - : path.resolve(__dirname, '..', 'bin', details.exec) -} diff --git a/lib/youtube-dl.js b/lib/youtube-dl.js index fbb67b0..589a734 100644 --- a/lib/youtube-dl.js +++ b/lib/youtube-dl.js @@ -3,6 +3,7 @@ const universalify = require('universalify') const streamify = require('streamify') const request = require('request') +const path = require('path') const hms = require('hh-mm-ss') const http = require('http') const url = require('url') @@ -15,12 +16,12 @@ const { isString } = require('./util') -let ytdlBinary = require('./get-binary')() +let ytdlBinary = null const execa = universalify.fromPromise(require('execa')) function youtubeDl (args, options, cb) { - return execa(ytdlBinary, args, options, function done (err, output) { + return execa(ytdl.getYtdlBinary(), args, options, function done (err, output) { if (err) return cb(err) return cb(null, output.stdout ? output.stdout.trim().split(/\r?\n/) : undefined) }) @@ -207,7 +208,7 @@ ytdl.setYtdlBinary = function setYtdlBinary (path) { * @param {String} path */ ytdl.getYtdlBinary = function getYtdlBinary () { - return ytdlBinary + return ytdlBinary ? ytdlBinary : path.resolve(__dirname, '..', 'bin', 'youtube-dl') } /**