Update index.js

Skip SSL errors
This commit is contained in:
freearhey 2019-08-08 14:11:11 +03:00
parent 7fd99ba1d6
commit 1165bcc830

View File

@ -1,5 +1,6 @@
const util = require('../helpers/util') const util = require('../helpers/util')
const axios = require('axios') const axios = require('axios')
const https = require('https')
const errorLog = 'error.log' const errorLog = 'error.log'
const config = { const config = {
@ -13,7 +14,12 @@ let stats = {
failures: 0 failures: 0
} }
const http = axios.create({ timeout: config.timeout }) const http = axios.create({
timeout: config.timeout,
httpsAgent: new https.Agent({
rejectUnauthorized: false
})
})
http.defaults.headers.common["User-Agent"] = "VLC/2.2.4 LibVLC/2.2.4" http.defaults.headers.common["User-Agent"] = "VLC/2.2.4 LibVLC/2.2.4"
async function test() { async function test() {
@ -36,6 +42,8 @@ async function test() {
for(let item of playlist.items) { for(let item of playlist.items) {
if(item.url.indexOf('rtmp://') > -1) continue
await new Promise(resolve => { await new Promise(resolve => {
setTimeout(resolve, config.delay) setTimeout(resolve, config.delay)
}) })
@ -50,6 +58,8 @@ async function test() {
} catch (err) { } catch (err) {
if(!err.response) {
stats.failures++ stats.failures++
writeToLog(country.url, err.message, item.url) writeToLog(country.url, err.message, item.url)
@ -57,6 +67,8 @@ async function test() {
} }
} }
}
} }
if(stats.failures === 0) { if(stats.failures === 0) {