From ee591096c1d6bd6d264f1f5edd972462f1788e04 Mon Sep 17 00:00:00 2001 From: Aleksandr Statciuk Date: Fri, 6 Aug 2021 07:49:35 +0300 Subject: [PATCH 1/4] Update clean.js --- scripts/clean.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/scripts/clean.js b/scripts/clean.js index fa2cb364be..358b275d26 100644 --- a/scripts/clean.js +++ b/scripts/clean.js @@ -17,7 +17,7 @@ program const config = program.opts() const offlineStatusCodes = [404, 410, 451, 500, 501] -const ignore = ['Geo-blocked', 'Not 24/7'] +const ignoreStatus = ['Geo-blocked', 'Not 24/7', 'Offline'] const instance = axios.create({ timeout: config.timeout, maxContentLength: 200000, @@ -56,9 +56,12 @@ async function checkStatus(playlist) { for (const [index, channel] of playlist.channels.entries()) { const current = index + 1 const counter = chalk.gray(`[${current}/${total}]`) + const skipChannel = + channel.status && + ignoreStatus.map(i => i.toLowerCase()).includes(channel.status.toLowerCase()) bar.tick() if ( - (channel.status && ignore.map(i => i.toLowerCase()).includes(channel.status.toLowerCase())) || + skipChannel || (!channel.url.startsWith('http://') && !channel.url.startsWith('https://')) ) { channels.push(channel) From 546c8ff7b157405460e0315d23abcb8baf4e1545 Mon Sep 17 00:00:00 2001 From: Aleksandr Statciuk Date: Fri, 6 Aug 2021 07:49:39 +0300 Subject: [PATCH 2/4] Update detect-resolution.js --- scripts/detect-resolution.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/scripts/detect-resolution.js b/scripts/detect-resolution.js index 5c01841f5d..5da6a282f5 100644 --- a/scripts/detect-resolution.js +++ b/scripts/detect-resolution.js @@ -15,6 +15,7 @@ program .parse(process.argv) const config = program.opts() +const ignoreStatus = ['Offline'] const instance = axios.create({ timeout: config.timeout, maxContentLength: 200000, @@ -50,7 +51,10 @@ async function detectResolution(playlist) { let updated = false for (const channel of playlist.channels) { bar.tick() - if (!channel.resolution.height) { + const skipChannel = + channel.status && + ignoreStatus.map(i => i.toLowerCase()).includes(channel.status.toLowerCase()) + if (!channel.resolution.height && !skipChannel) { const CancelToken = axios.CancelToken const source = CancelToken.source() const timeout = setTimeout(() => { From 04ed1bf955d95f51033b608744dcf41cd85f9958 Mon Sep 17 00:00:00 2001 From: Aleksandr Statciuk Date: Fri, 6 Aug 2021 07:49:43 +0300 Subject: [PATCH 3/4] Update generate.js --- scripts/generate.js | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/scripts/generate.js b/scripts/generate.js index 6aa31c2245..3a2e6a7a3a 100644 --- a/scripts/generate.js +++ b/scripts/generate.js @@ -42,7 +42,7 @@ function generateIndex() { const nsfwFilename = `${ROOT_DIR}/index.nsfw.m3u` file.create(nsfwFilename, '#EXTM3U\n') - const channels = db.channels.sortBy(['name', 'url']).removeDuplicates().get() + const channels = db.channels.sortBy(['name', 'url']).removeDuplicates().removeOffline().get() for (const channel of channels) { if (!channel.isNSFW()) { file.append(filename, channel.toString()) @@ -56,7 +56,11 @@ function generateCategoryIndex() { const filename = `${ROOT_DIR}/index.category.m3u` file.create(filename, '#EXTM3U\n') - const channels = db.channels.sortBy(['category', 'name', 'url']).removeDuplicates().get() + const channels = db.channels + .sortBy(['category', 'name', 'url']) + .removeDuplicates() + .removeOffline() + .get() for (const channel of channels) { file.append(filename, channel.toString()) } @@ -72,6 +76,7 @@ function generateCountryIndex() { .sortBy(['name', 'url']) .forCountry(country) .removeDuplicates() + .removeOffline() .get() for (const channel of channels) { const groupTitle = channel.group.title @@ -95,6 +100,7 @@ function generateLanguageIndex() { .sortBy(['name', 'url']) .forLanguage(language) .removeDuplicates() + .removeOffline() .get() for (const channel of channels) { const groupTitle = channel.group.title @@ -121,6 +127,7 @@ function generateCategories() { .sortBy(['name', 'url']) .forCategory(category) .removeDuplicates() + .removeOffline() .get() for (const channel of channels) { file.append(filename, channel.toString()) @@ -141,6 +148,7 @@ function generateCountries() { .sortBy(['name', 'url']) .forCountry(country) .removeDuplicates() + .removeOffline() .get() for (const channel of channels) { if (!channel.isNSFW()) { @@ -163,6 +171,7 @@ function generateLanguages() { .sortBy(['name', 'url']) .forLanguage(language) .removeDuplicates() + .removeOffline() .get() for (const channel of channels) { if (!channel.isNSFW()) { From 9bab29bf38db3151c6f227c9b7c3382b47d198da Mon Sep 17 00:00:00 2001 From: Aleksandr Statciuk Date: Fri, 6 Aug 2021 07:49:46 +0300 Subject: [PATCH 4/4] Update db.js --- scripts/helpers/db.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/scripts/helpers/db.js b/scripts/helpers/db.js index 417742f847..f94ce678a1 100644 --- a/scripts/helpers/db.js +++ b/scripts/helpers/db.js @@ -31,6 +31,7 @@ db.channels = { list: [], filter: null, duplicates: true, + offline: true, nsfw: true, add(channel) { this.list.push(channel) @@ -86,8 +87,13 @@ db.channels = { output = output.filter(channel => !channel.isNSFW()) } + if (!this.offline) { + output = output.filter(channel => channel.status !== 'Offline') + } + this.nsfw = true this.duplicates = true + this.offline = true this.filter = null return output @@ -102,6 +108,11 @@ db.channels = { return this }, + removeOffline() { + this.offline = false + + return this + }, all() { return this.list },