From 84f3470bb3be9231b0275f22fcb8f2d13632b275 Mon Sep 17 00:00:00 2001 From: freearhey Date: Tue, 19 Jan 2021 22:08:35 +0300 Subject: [PATCH] Update format.js --- scripts/format.js | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/scripts/format.js b/scripts/format.js index f888868e3..397ffee27 100644 --- a/scripts/format.js +++ b/scripts/format.js @@ -20,7 +20,7 @@ const config = program.opts() const instance = axios.create({ timeout: config.timeout, - maxContentLength: 5000, + maxContentLength: 20000, httpsAgent: new https.Agent({ rejectUnauthorized: false }) @@ -120,10 +120,14 @@ async function detectResolution(playlist) { .get(url) .then(sleep(config.delay)) .catch(err => {}) - if (isValid(response)) { - const resolution = parseResolution(response.data) - if (resolution) { - item.resolution = resolution + if (response) { + if (response.status === 200) { + if (/^#EXTM3U/.test(response.data)) { + const resolution = parseResolution(response.data) + if (resolution) { + item.resolution = resolution + } + } } } @@ -200,10 +204,6 @@ function sleep(ms) { } } -function isValid(response) { - return response && response.status === 200 && /^#EXTM3U/.test(response.data) -} - async function updatePlaylist(playlist) { const original = helper.readFile(playlist.url) let output = playlist.getHeader()