Update format.js

This commit is contained in:
freearhey 2021-01-20 01:02:40 +03:00
parent 2a5e17ad2b
commit c11ce03a5c
1 changed files with 4 additions and 12 deletions

View File

@ -5,11 +5,10 @@ const ProgressBar = require('progress')
const https = require('https') const https = require('https')
program program
.version('1.0.0', '-v, --version')
.usage('[OPTIONS]...') .usage('[OPTIONS]...')
.option('-d, --debug', 'Debug mode') .option('-d, --debug', 'Debug mode')
.option('-c, --country <country>', 'Comma-separated list of country codes') .option('-c, --country <country>', 'Comma-separated list of country codes', '')
.option('-e, --exclude <exclude>', 'Comma-separated list of country codes to be excluded ') .option('-e, --exclude <exclude>', 'Comma-separated list of country codes to be excluded', '')
.option('--epg', 'Turn on EPG parser') .option('--epg', 'Turn on EPG parser')
.option('--resolution', 'Turn on resolution parser') .option('--resolution', 'Turn on resolution parser')
.option('--delay <delay>', 'Delay between parser requests', 0) .option('--delay <delay>', 'Delay between parser requests', 0)
@ -27,7 +26,6 @@ const instance = axios.create({
}) })
let globalBuffer = [] let globalBuffer = []
let bar
async function main() { async function main() {
const index = parseIndex() const index = parseIndex()
@ -109,7 +107,7 @@ async function removeDuplicates(playlist) {
async function detectResolution(playlist) { async function detectResolution(playlist) {
if (!config.resolution) return playlist if (!config.resolution) return playlist
bar = new ProgressBar(' Detecting resolution: [:bar] :current/:total (:percent) ', { const bar = new ProgressBar(' Detecting resolution: [:bar] :current/:total (:percent) ', {
total: playlist.items.length total: playlist.items.length
}) })
const results = [] const results = []
@ -118,7 +116,7 @@ async function detectResolution(playlist) {
const url = item.url const url = item.url
const response = await instance const response = await instance
.get(url) .get(url)
.then(sleep(config.delay)) .then(helper.sleep(config.delay))
.catch(err => {}) .catch(err => {})
if (response) { if (response) {
if (response.status === 200) { if (response.status === 200) {
@ -198,12 +196,6 @@ async function removeUnsortedDuplicates(playlist) {
return playlist return playlist
} }
function sleep(ms) {
return function (x) {
return new Promise(resolve => setTimeout(() => resolve(x), ms))
}
}
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()