Update remove-duplicates.js

This commit is contained in:
Aleksandr Statciuk 2021-09-08 20:57:13 +03:00
parent b442162ecd
commit e1d5a6d062
1 changed files with 8 additions and 6 deletions

View File

@ -1,5 +1,6 @@
const parser = require('./helpers/parser') const parser = require('./helpers/parser')
const utils = require('./helpers/utils') const utils = require('./helpers/utils')
const file = require('./helpers/file')
const log = require('./helpers/log') const log = require('./helpers/log')
let globalBuffer = [] let globalBuffer = []
@ -7,18 +8,19 @@ let globalBuffer = []
async function main() { async function main() {
log.start() log.start()
log.print(`Parsing 'index.m3u'...`) let files = await file.list()
const playlists = parser.parseIndex().filter(i => i.url !== 'channels/unsorted.m3u') if (!files.length) log.print(`No files is selected\n`)
for (const playlist of playlists) { files = files.filter(file => file !== 'channels/unsorted.m3u')
log.print(`\nProcessing '${playlist.url}'...`) for (const file of files) {
log.print(`\nProcessing '${file}'...`)
await parser await parser
.parsePlaylist(playlist.url) .parsePlaylist(file)
.then(addToGlobalBuffer) .then(addToGlobalBuffer)
.then(removeDuplicates) .then(removeDuplicates)
.then(p => p.save()) .then(p => p.save())
} }
if (playlists.length) { if (files.length) {
log.print(`\nProcessing 'channels/unsorted.m3u'...`) log.print(`\nProcessing 'channels/unsorted.m3u'...`)
await parser await parser
.parsePlaylist('channels/unsorted.m3u') .parsePlaylist('channels/unsorted.m3u')