https://iptv-org.github.io/iptv/categories/${category.slug}.m3u
`
+ })
+ }
+
+ const table = markdown.createTable(rows, [
+ { name: 'Category', align: 'left' },
+ { name: 'Channels', align: 'right' },
+ { name: 'Playlist', align: 'left' }
+ ])
+
+ await file.create('./.readme/_categories.md', table)
+}
+
+async function generateCountryTable() {
+ logger.info('Generating country table...')
+
+ const rows = []
+ for (const country of countries) {
+ const flag = getCountryFlag(country.code)
+ const prefix = flag ? `${flag} ` : ''
+
+ rows.push({
+ country: prefix + country.name,
+ channels: country.count,
+ playlist: `https://iptv-org.github.io/iptv/countries/${country.code.toLowerCase()}.m3u
`
+ })
+ }
+
+ const table = markdown.createTable(rows, [
+ { name: 'Country', align: 'left' },
+ { name: 'Channels', align: 'right' },
+ { name: 'Playlist', align: 'left' }
+ ])
+
+ await file.create('./.readme/_countries.md', table)
+}
+
+async function generateRegionTable() {
+ logger.info('Generating region table...')
+
+ const rows = []
+ for (const region of regions) {
+ rows.push({
+ region: region.name,
+ channels: region.count,
+ playlist: `https://iptv-org.github.io/iptv/regions/${region.code.toLowerCase()}.m3u
`
+ })
+ }
+
+ const table = markdown.createTable(rows, [
+ { name: 'Region', align: 'left' },
+ { name: 'Channels', align: 'right' },
+ { name: 'Playlist', align: 'left' }
+ ])
+
+ await file.create('./.readme/_regions.md', table)
+}
+
+async function generateLanguageTable() {
+ logger.info('Generating language table...')
+
+ const rows = []
+ for (const language of languages) {
+ rows.push({
+ language: language.name,
+ channels: language.count,
+ playlist: `https://iptv-org.github.io/iptv/languages/${language.code}.m3u
`
+ })
+ }
+
+ const table = markdown.createTable(rows, [
+ { name: 'Language', align: 'left' },
+ { name: 'Channels', align: 'right' },
+ { name: 'Playlist', align: 'left' }
+ ])
+
+ await file.create('./.readme/_languages.md', table)
+}
+
+async function updateReadme() {
+ logger.info('Updating README.md...')
+
+ const config = require(file.resolve(options.config))
+ await file.createDir(file.dirname(config.build))
+ await markdown.compile(options.config)
+}
+
+async function setUp() {
+ categories = await parser.parseLogs(`${LOGS_PATH}/generate-playlists/categories.log`)
+ countries = await parser.parseLogs(`${LOGS_PATH}/generate-playlists/countries.log`)
+ languages = await parser.parseLogs(`${LOGS_PATH}/generate-playlists/languages.log`)
+ regions = await parser.parseLogs(`${LOGS_PATH}/generate-playlists/regions.log`)
+}
+
+function getCountryFlag(code) {
+ switch (code) {
+ case 'UK':
+ return '🇬🇧'
+ case 'INT':
+ return '🌍'
+ case 'UNDEFINED':
+ return ''
+ default:
+ return code.replace(/./g, char => String.fromCodePoint(char.charCodeAt(0) + 127397))
+ }
+}
diff --git a/scripts/commands/validate.js b/scripts/commands/validate.js
new file mode 100644
index 0000000000..0d2b716558
--- /dev/null
+++ b/scripts/commands/validate.js
@@ -0,0 +1,55 @@
+const blocklist = require('../data/blocklist')
+const parser = require('iptv-playlist-parser')
+const { file, logger } = require('../core')
+const { program } = require('commander')
+
+const options = program
+ .option('--input-dir ${column.name} | ` + } + output += '
---|
${item[prop]} | ` + i++ + } + output += '
https://iptv-org.github.io/iptv/categories/${category.id}.m3u
`
- })
- }
-
- const table = generateTable(categories, {
- columns: [
- { name: 'Category', align: 'left' },
- { name: 'Channels', align: 'right' },
- { name: 'Playlist', align: 'left' }
- ]
- })
-
- file.create('./.readme/_categories.md', table)
-}
-
-function generateCountriesTable() {
- log.print('Generating countries table...\n')
-
- const countries = []
- for (const country of [
- ...db.countries.sortBy(['name']).all(),
- { name: 'Undefined', code: 'undefined' }
- ]) {
- let flag = utils.code2flag(country.code)
- const prefix = flag ? `${flag} ` : ''
- countries.push({
- country: prefix + country.name,
- channels: db.channels
- .forCountry(country)
- .removeOffline()
- .removeDuplicates()
- .removeNSFW()
- .count(),
- playlist: `https://iptv-org.github.io/iptv/countries/${country.code}.m3u
`
- })
- }
-
- const table = generateTable(countries, {
- columns: [
- { name: 'Country', align: 'left' },
- { name: 'Channels', align: 'right' },
- { name: 'Playlist', align: 'left', nowrap: true }
- ]
- })
-
- file.create('./.readme/_countries.md', table)
-}
-
-function generateLanguagesTable() {
- log.print('Generating languages table...\n')
- const languages = []
-
- for (const language of [
- ...db.languages.sortBy(['name']).all(),
- { name: 'Undefined', code: 'undefined' }
- ]) {
- languages.push({
- language: language.name,
- channels: db.channels
- .forLanguage(language)
- .removeOffline()
- .removeDuplicates()
- .removeNSFW()
- .count(),
- playlist: `https://iptv-org.github.io/iptv/languages/${language.code}.m3u
`
- })
- }
-
- const table = generateTable(languages, {
- columns: [
- { name: 'Language', align: 'left' },
- { name: 'Channels', align: 'right' },
- { name: 'Playlist', align: 'left' }
- ]
- })
-
- file.create('./.readme/_languages.md', table)
-}
-
-function generateTable(data, options) {
- let output = '${column.name} | ` - } - output += '
---|
${item[prop]} | ` - i++ - } - output += '
Category | Channels | Playlist |
---|---|---|
General | 1 | https://iptv-org.github.io/iptv/categories/general.m3u |
News | 1 | https://iptv-org.github.io/iptv/categories/news.m3u |
Other | 0 | https://iptv-org.github.io/iptv/categories/other.m3u |
Language | Channels | Playlist |
---|---|---|
Catalan | 0 | https://iptv-org.github.io/iptv/languages/cat.m3u |
English | 1 | https://iptv-org.github.io/iptv/languages/eng.m3u |
Russian | 1 | https://iptv-org.github.io/iptv/languages/rus.m3u |
Undefined | 0 | https://iptv-org.github.io/iptv/languages/undefined.m3u |
Region | Channels | Playlist |
---|---|---|
Asia | 1 | https://iptv-org.github.io/iptv/regions/asia.m3u |
Commonwealth of Independent States | 1 | https://iptv-org.github.io/iptv/regions/cis.m3u |
Europe | 2 | https://iptv-org.github.io/iptv/regions/eur.m3u |
Europe, the Middle East and Africa | 2 | https://iptv-org.github.io/iptv/regions/emea.m3u |
Undefined | 0 | https://iptv-org.github.io/iptv/regions/undefined.m3u |
Country | Channels | Playlist |
---|---|---|
🇦🇩 Andorra | 0 | https://iptv-org.github.io/iptv/countries/ad.m3u |
🇷🇺 Russia | 1 | https://iptv-org.github.io/iptv/countries/ru.m3u |
🇬🇧 United Kingdom | 1 | https://iptv-org.github.io/iptv/countries/uk.m3u |
🌍 International | 0 | https://iptv-org.github.io/iptv/countries/int.m3u |
Undefined | 0 | https://iptv-org.github.io/iptv/countries/undefined.m3u |