Skip to content

Commit

Permalink
refactor(media-provider): remove unnecessary dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
Kikobeats committed Dec 20, 2023
1 parent 044f875 commit d480efb
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
1 change: 0 additions & 1 deletion packages/metascraper-media-provider/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
"debug-logfmt": "~1.0.4",
"got": "~11.8.6",
"lodash": "~4.17.21",
"p-do-whilst": "~1.1.0",
"p-reflect": "~2.1.0",
"p-retry": "~4.6.1",
"p-timeout": "~4.1.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ const debug = require('debug-logfmt')(
const { serializeError } = require('serialize-error')
const youtubedl = require('youtube-dl-exec')
const { get, constant } = require('lodash')
const pDoWhilst = require('p-do-whilst')
const pTimeout = require('p-timeout')

const RE_UNSUPORTED_URL = /Unsupported URL/
Expand Down Expand Up @@ -53,16 +52,19 @@ module.exports = ({
const userAgent = get(gotOpts, 'headers.user-agent')

const task = async () => {
await pDoWhilst(async () => {
do {
try {
const proxy = getProxy({ url, retryCount: retryCount++ })
const flags = getFlags({ url, proxy, userAgent, cacheDir })
data = await youtubedl(url, flags, { timeout, ...props })
} catch (error) {
if (condition()) { debug('getInfo:error', { retryCount }, serializeError(error)) }
if (condition()) {
debug('getInfo:error', { retryCount }, serializeError(error))
}
isSupportedURL = !RE_UNSUPORTED_URL.test(error.stderr)
console.log('catch', { isSupportedURL })
}
}, condition)
} while (condition())

return data
}
Expand Down

0 comments on commit d480efb

Please sign in to comment.