Installed fluent-ffmpeg package

This commit is contained in:
freearhey 2019-10-25 21:11:21 +03:00
parent 659a43df4b
commit 9f5ff544aa
3 changed files with 57 additions and 44 deletions

31
package-lock.json generated
View File

@ -13,6 +13,12 @@
"regenerator-runtime": "^0.13.2"
}
},
"async": {
"version": "3.1.0",
"resolved": "https://registry.npmjs.org/async/-/async-3.1.0.tgz",
"integrity": "sha512-4vx/aaY6j/j3Lw3fbCHNWP0pPaTCew3F6F3hYyl/tHs/ndmV1q7NW9T5yuJ2XAGwdQrP+6Wu20x06U4APo/iQQ==",
"dev": true
},
"axios": {
"version": "0.19.0",
"resolved": "https://registry.npmjs.org/axios/-/axios-0.19.0.tgz",
@ -53,6 +59,16 @@
"integrity": "sha512-UpzcLCXolUWcNu5HtVMHYdXJjArjsF9C0aNnquZYY4uW/Vu0miy5YoWvbV345HauVvcAUnpRuhMMcqTcGOY2+w==",
"dev": true
},
"fluent-ffmpeg": {
"version": "2.1.2",
"resolved": "https://registry.npmjs.org/fluent-ffmpeg/-/fluent-ffmpeg-2.1.2.tgz",
"integrity": "sha1-yVLeIkD4EuvaCqgAbXd27irPfXQ=",
"dev": true,
"requires": {
"async": ">=0.2.9",
"which": "^1.1.1"
}
},
"follow-redirects": {
"version": "1.5.10",
"resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.5.10.tgz",
@ -78,6 +94,12 @@
"integrity": "sha512-U15Q7MXTuZlrbymiz95PJpZxu8IlipAp4dtS3wOdgPXx3mqBnslrWU14kxfHB+Py/+2PVKSr37dMAgM2A4uArw==",
"dev": true
},
"isexe": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz",
"integrity": "sha1-6PvzdNxVb/iUehDcsFctYz8s+hA=",
"dev": true
},
"m3u8-file-parser": {
"version": "0.2.2",
"resolved": "https://registry.npmjs.org/m3u8-file-parser/-/m3u8-file-parser-0.2.2.tgz",
@ -111,6 +133,15 @@
"integrity": "sha512-naKIZz2GQ8JWh///G7L3X6LaQUAMp2lvb1rvwwsURe/VXwD6VMfr+/1NuNw3ag8v2kY1aQ/go5SNn79O9JU7yw==",
"dev": true
},
"which": {
"version": "1.3.1",
"resolved": "https://registry.npmjs.org/which/-/which-1.3.1.tgz",
"integrity": "sha512-HxJdYWq1MTIQbJ3nw0cqssHoTNU267KlrDuGZ1WYlxDStUtKUhOaJmh112/TZmHxxUfuJqPXSOm7tDyas0OSIQ==",
"dev": true,
"requires": {
"isexe": "^2.0.0"
}
},
"xmldom": {
"version": "0.1.27",
"resolved": "https://registry.npmjs.org/xmldom/-/xmldom-0.1.27.tgz",

View File

@ -13,6 +13,7 @@
"devDependencies": {
"axios": ">=0.18.1",
"escape-string-regexp": "^2.0.0",
"fluent-ffmpeg": "^2.1.2",
"iptv-playlist-parser": "^0.2.2",
"markdown-include": "^0.4.3",
"xmldom": "^0.1.27"

View File

@ -1,6 +1,7 @@
process.env['NODE_TLS_REJECT_UNAUTHORIZED'] = 0
const util = require('../helpers/util')
const axios = require('axios')
const https = require('https')
const ffmpeg = require('fluent-ffmpeg')
const verbose = process.env.npm_config_debug || false
const errorLog = 'error.log'
@ -15,23 +16,6 @@ let stats = {
failures: 0
}
const instance = axios.create({
timeout: config.timeout,
httpsAgent: new https.Agent({
rejectUnauthorized: false
}),
validateStatus: function (status) {
return status >= 200 && status < 400
},
headers: {
'Accept': '*/*',
'Accept-Language': 'en_US',
'User-Agent': 'VLC/3.0.8 LibVLC/3.0.8',
'Range': 'bytes=0-'
},
responseType: 'stream'
})
async function test() {
stats.tests++
@ -52,34 +36,31 @@ async function test() {
for(let item of playlist.items) {
await new Promise(resolve => {
setTimeout(resolve, config.delay)
})
stats.channels++
try {
if(verbose) {
console.log(`Checking '${item.url}'...`)
}
let response = await instance.get(item.url)
await new Promise(resolve => {
ffmpeg(item.url, { timeout: config.timeout }).ffprobe((err) => {
response.data.destroy()
continue
} catch (err) {
if(err.request && ['ECONNRESET'].indexOf(err.code) > -1) continue
if(err) {
const message = err.message.split('\n').find(line => {
return /^\[[\w|\s|\d|@|\]]+/i.test(line)
}).split(']')[1].trim()
stats.failures++
writeToLog(country.url, err.message, item.url)
writeToLog(country.url, message, item.url)
}
resolve()
})
})
}
}
@ -105,5 +86,5 @@ function writeToLog(country, msg, url) {
var now = new Date()
var line = `${country}: ${msg} '${url}'`
util.appendToFile(errorLog, now.toISOString() + ' ' + line + '\n')
console.log(`Error: ${msg} '${url}'`)
console.log(`${msg} '${url}'`)
}