Skip to content

Commit

Permalink
refactor: remove unnecessary lines
Browse files Browse the repository at this point in the history
  • Loading branch information
Kikobeats committed Apr 12, 2024
1 parent cb4c24f commit 227370a
Showing 1 changed file with 3 additions and 11 deletions.
14 changes: 3 additions & 11 deletions scripts/postinstall.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,6 @@ const debug = require('debug-logfmt')('youtube-dl-exec:install')
const { mkdir, chmod } = require('node:fs/promises')
const { pipeline } = require('node:stream/promises')
const { createWriteStream } = require('node:fs')
const { Readable } = require('node:stream')

const httpGet = async url =>
fetch(url, {
headers: {
'user-agent': 'microlinkhq/youtube-dl-exec'
}
})

const {
YOUTUBE_DL_PATH,
Expand All @@ -26,15 +18,15 @@ const getLatest = async data => {
const { browser_download_url: url } = assets.find(
({ name }) => name === YOUTUBE_DL_FILE
)
return httpGet(url)
return fetch(url)
}

const getBinary = async url => {
let response = await httpGet(url)
let response = await fetch(url)
if (response.headers.get('content-type') !== 'application/octet-stream') {
response = await getLatest(await response.json())
}
return Readable.fromWeb(response.body)
return response.body
}

const installBinary = async () => {
Expand Down

0 comments on commit 227370a

Please sign in to comment.