Merge branch 'master' into patch-3

This commit is contained in:
freearhey 2021-01-19 22:08:47 +03:00
commit f52e8311f8
1 changed files with 9 additions and 9 deletions

View File

@ -20,7 +20,7 @@ const config = program.opts()
const instance = axios.create({ const instance = axios.create({
timeout: config.timeout, timeout: config.timeout,
maxContentLength: 5000, maxContentLength: 20000,
httpsAgent: new https.Agent({ httpsAgent: new https.Agent({
rejectUnauthorized: false rejectUnauthorized: false
}) })
@ -120,10 +120,14 @@ async function detectResolution(playlist) {
.get(url) .get(url)
.then(sleep(config.delay)) .then(sleep(config.delay))
.catch(err => {}) .catch(err => {})
if (isValid(response)) { if (response) {
const resolution = parseResolution(response.data) if (response.status === 200) {
if (resolution) { if (/^#EXTM3U/.test(response.data)) {
item.resolution = resolution 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) { async function updatePlaylist(playlist) {
const original = helper.readFile(playlist.url) const original = helper.readFile(playlist.url)
let output = playlist.getHeader() let output = playlist.getHeader()