Update format.js

Skip stalled requests
This commit is contained in:
freearhey 2021-05-07 16:21:33 +03:00
parent c37a56c8ea
commit 9bd0a8c816
1 changed files with 13 additions and 2 deletions

View File

@ -87,10 +87,21 @@ async function detectResolution(playlist) {
for (const channel of playlist.channels) {
bar.tick()
if (!channel.resolution.height) {
const CancelToken = axios.CancelToken
const source = CancelToken.source()
const timeout = setTimeout(() => {
source.cancel()
}, config.timeout)
const response = await instance
.get(channel.url)
.get(channel.url, { cancelToken: source.token })
.then(() => {
clearTimeout(timeout)
})
.then(utils.sleep(config.delay))
.catch(err => {})
.catch(err => {
clearTimeout(timeout)
})
if (response && response.status === 200) {
if (/^#EXTM3U/.test(response.data)) {