Update index.js

- added skipPlaylist() function
- added exclude option to script
This commit is contained in:
freearhey 2019-09-08 19:52:49 +03:00
parent 8213dcd697
commit bfc2eeb452
1 changed files with 14 additions and 1 deletions

View File

@ -41,7 +41,7 @@ async function test() {
for(let country of countries) {
if (util.skipPlaylist(country.url)) {
if (skipPlaylist(country.url)) {
continue
}
@ -114,3 +114,16 @@ function writeToLog(country, msg, url) {
util.appendToFile(errorLog, now.toISOString() + ' ' + line + '\n')
console.log(`Error: ${msg} '${url}'`)
}
function skipPlaylist(filename) {
let testCountry = process.env.npm_config_country
let excludeCountries = process.env.npm_config_exclude.split(',')
if (testCountry && filename !== 'channels/' + testCountry + '.m3u') return true
for(const countryCode of excludeCountries) {
if (filename === 'channels/' + countryCode + '.m3u') return true
}
return false
}