${item.link}`
+
+ item.children
+ .orderBy(item => item.index)
+ .forEach(item => {
+ row += `\r\n\ - ${item.name} ${item.link}`
+
+ item.children
+ .orderBy(item => item.index)
+ .forEach(item => {
+ row += `\r\n\ - ${item.name} ${item.link}`
+ })
+ })
+
+ return row
+ })
+ .join('\r\n')
+
+ const readmeStorage = new Storage(README_DIR)
+ await readmeStorage.save('_countries.md', output)
+ }
+}
diff --git a/scripts/tables/countryTable.ts b/scripts/tables/countryTable.ts
deleted file mode 100644
index d0075e62cd..0000000000
--- a/scripts/tables/countryTable.ts
+++ /dev/null
@@ -1,65 +0,0 @@
-import { Storage, Collection, File } from '@freearhey/core'
-import { HTMLTable, LogParser, LogItem } from '../core'
-import { Country } from '../models'
-import { DATA_DIR, LOGS_DIR, README_DIR } from '../constants'
-import { Table } from './table'
-
-export class CountryTable implements Table {
- constructor() {}
-
- async make() {
- const dataStorage = new Storage(DATA_DIR)
-
- const countriesContent = await dataStorage.json('countries.json')
- const countries = new Collection(countriesContent).map(data => new Country(data))
- const countriesGroupedByCode = countries.keyBy((country: Country) => country.code)
-
- const parser = new LogParser()
- const logsStorage = new Storage(LOGS_DIR)
- const generatorsLog = await logsStorage.load('generators.log')
- const parsed = parser.parse(generatorsLog)
-
- let data = new Collection()
-
- parsed
- .filter((logItem: LogItem) => logItem.type === 'country')
- .forEach((logItem: LogItem) => {
- const file = new File(logItem.filepath)
- const code = file.name().toUpperCase()
- const [countryCode] = code.split('-') || ['', '']
- const country = countriesGroupedByCode.get(countryCode)
-
- if (country) {
- data.add([
- country.name,
- `${country.flag} ${country.name}`,
- logItem.count,
- `https://iptv-org.github.io/iptv/${logItem.filepath}`
- ])
- } else {
- data.add([
- 'ZZ',
- 'Undefined',
- logItem.count,
- `https://iptv-org.github.io/iptv/${logItem.filepath}`
- ])
- }
- })
-
- data = data
- .orderBy(item => item[0])
- .map(item => {
- item.shift()
- return item
- })
-
- const table = new HTMLTable(data.all(), [
- { name: 'Country' },
- { name: 'Channels', align: 'right' },
- { name: 'Playlist', nowrap: true }
- ])
-
- const readmeStorage = new Storage(README_DIR)
- await readmeStorage.save('_countries.md', table.toString())
- }
-}
diff --git a/scripts/tables/index.ts b/scripts/tables/index.ts
index 6da33e8221..f25c0a3a27 100644
--- a/scripts/tables/index.ts
+++ b/scripts/tables/index.ts
@@ -1,5 +1,4 @@
-export * from './categoryTable'
-export * from './countryTable'
-export * from './languageTable'
-export * from './regionTable'
-export * from './subdivisionTable'
+export * from './categoriesTable'
+export * from './countriesTable'
+export * from './languagesTable'
+export * from './regionsTable'
diff --git a/scripts/tables/languageTable.ts b/scripts/tables/languagesTable.ts
similarity index 68%
rename from scripts/tables/languageTable.ts
rename to scripts/tables/languagesTable.ts
index 2014ba6760..7621907453 100644
--- a/scripts/tables/languageTable.ts
+++ b/scripts/tables/languagesTable.ts
@@ -1,18 +1,21 @@
-import { Storage, Collection, File } from '@freearhey/core'
+import { Storage, Collection, File, Dictionary } from '@freearhey/core'
import { HTMLTable, LogParser, LogItem } from '../core'
+import { LOGS_DIR, README_DIR } from '../constants'
import { Language } from '../models'
-import { DATA_DIR, LOGS_DIR, README_DIR } from '../constants'
import { Table } from './table'
-export class LanguageTable implements Table {
- constructor() {}
+type LanguagesTableProps = {
+ languagesKeyByCode: Dictionary
+}
+
+export class LanguagesTable implements Table {
+ languagesKeyByCode: Dictionary
+
+ constructor({ languagesKeyByCode }: LanguagesTableProps) {
+ this.languagesKeyByCode = languagesKeyByCode
+ }
async make() {
- const dataStorage = new Storage(DATA_DIR)
- const languagesContent = await dataStorage.json('languages.json')
- const languages = new Collection(languagesContent).map(data => new Language(data))
- const languagesGroupedByCode = languages.keyBy((language: Language) => language.code)
-
const parser = new LogParser()
const logsStorage = new Storage(LOGS_DIR)
const generatorsLog = await logsStorage.load('generators.log')
@@ -24,7 +27,7 @@ export class LanguageTable implements Table {
.forEach((logItem: LogItem) => {
const file = new File(logItem.filepath)
const languageCode = file.name()
- const language: Language = languagesGroupedByCode.get(languageCode)
+ const language: Language = this.languagesKeyByCode.get(languageCode)
data.add([
language ? language.name : 'ZZ',
diff --git a/scripts/tables/regionTable.ts b/scripts/tables/regionTable.ts
deleted file mode 100644
index 84eeaaa4a2..0000000000
--- a/scripts/tables/regionTable.ts
+++ /dev/null
@@ -1,62 +0,0 @@
-import { Storage, Collection, File } from '@freearhey/core'
-import { HTMLTable, LogParser, LogItem } from '../core'
-import { Region } from '../models'
-import { DATA_DIR, LOGS_DIR, README_DIR } from '../constants'
-import { Table } from './table'
-
-export class RegionTable implements Table {
- constructor() {}
-
- async make() {
- const dataStorage = new Storage(DATA_DIR)
- const regionsContent = await dataStorage.json('regions.json')
- const regions = new Collection(regionsContent).map(data => new Region(data))
- const regionsGroupedByCode = regions.keyBy((region: Region) => region.code)
-
- const parser = new LogParser()
- const logsStorage = new Storage(LOGS_DIR)
- const generatorsLog = await logsStorage.load('generators.log')
-
- let data = new Collection()
- parser
- .parse(generatorsLog)
- .filter((logItem: LogItem) => logItem.type === 'region')
- .forEach((logItem: LogItem) => {
- const file = new File(logItem.filepath)
- const regionCode = file.name().toUpperCase()
- const region: Region = regionsGroupedByCode.get(regionCode)
-
- if (region) {
- data.add([
- region.name,
- region.name,
- logItem.count,
- `https://iptv-org.github.io/iptv/${logItem.filepath}`
- ])
- } else {
- data.add([
- 'ZZZ',
- 'Undefined',
- logItem.count,
- `https://iptv-org.github.io/iptv/${logItem.filepath}`
- ])
- }
- })
-
- data = data
- .orderBy(item => item[0])
- .map(item => {
- item.shift()
- return item
- })
-
- const table = new HTMLTable(data.all(), [
- { name: 'Region', align: 'left' },
- { name: 'Channels', align: 'right' },
- { name: 'Playlist', align: 'left', nowrap: true }
- ])
-
- const readmeStorage = new Storage(README_DIR)
- await readmeStorage.save('_regions.md', table.toString())
- }
-}
diff --git a/scripts/tables/regionsTable.ts b/scripts/tables/regionsTable.ts
new file mode 100644
index 0000000000..25f2e71bcb
--- /dev/null
+++ b/scripts/tables/regionsTable.ts
@@ -0,0 +1,52 @@
+import { Storage, Collection, File } from '@freearhey/core'
+import { HTMLTable, LogParser, LogItem } from '../core'
+import { LOGS_DIR, README_DIR } from '../constants'
+import { Region } from '../models'
+import { Table } from './table'
+
+type RegionsTableProps = {
+ regions: Collection
+}
+
+export class RegionsTable implements Table {
+ regions: Collection
+
+ constructor({ regions }: RegionsTableProps) {
+ this.regions = regions
+ }
+
+ async make() {
+ const parser = new LogParser()
+ const logsStorage = new Storage(LOGS_DIR)
+ const generatorsLog = await logsStorage.load('generators.log')
+ const parsed = parser.parse(generatorsLog)
+ const logRegions = parsed.filter((logItem: LogItem) => logItem.type === 'region')
+
+ let items = new Collection()
+ this.regions.forEach((region: Region) => {
+ const logItem = logRegions.find(
+ (logItem: LogItem) => logItem.filepath === `regions/${region.code.toLowerCase()}.m3u`
+ )
+
+ if (!logItem) return
+
+ items.add({
+ index: region.name,
+ name: region.name,
+ count: logItem.count,
+ link: `https://iptv-org.github.io/iptv/${logItem.filepath}`
+ })
+ })
+
+ items = items.orderBy(item => item.index)
+
+ const output = items
+ .map(item => {
+ return `- ${item.name} ${item.link}`
+ })
+ .join('\r\n')
+
+ const readmeStorage = new Storage(README_DIR)
+ await readmeStorage.save('_regions.md', output)
+ }
+}
diff --git a/scripts/tables/subdivisionTable.ts b/scripts/tables/subdivisionTable.ts
deleted file mode 100644
index 925d9094e3..0000000000
--- a/scripts/tables/subdivisionTable.ts
+++ /dev/null
@@ -1,72 +0,0 @@
-import { Storage, Collection, File } from '@freearhey/core'
-import { HTMLTable, LogParser, LogItem } from '../core'
-import { Country, Subdivision } from '../models'
-import { DATA_DIR, LOGS_DIR, README_DIR } from '../constants'
-import { Table } from './table'
-
-export class SubdivisionTable implements Table {
- constructor() {}
-
- async make() {
- const dataStorage = new Storage(DATA_DIR)
-
- const countriesContent = await dataStorage.json('countries.json')
- const countries = new Collection(countriesContent).map(data => new Country(data))
- const countriesGroupedByCode = countries.keyBy((country: Country) => country.code)
- const subdivisionsContent = await dataStorage.json('subdivisions.json')
- const subdivisions = new Collection(subdivisionsContent).map(data => new Subdivision(data))
- const subdivisionsGroupedByCode = subdivisions.keyBy(
- (subdivision: Subdivision) => subdivision.code
- )
-
- const parser = new LogParser()
- const logsStorage = new Storage(LOGS_DIR)
- const generatorsLog = await logsStorage.load('generators.log')
- const parsed = parser.parse(generatorsLog)
- const parsedSubdivisions = parsed.filter((logItem: LogItem) => logItem.type === 'subdivision')
-
- let output = ''
- countries.forEach((country: Country) => {
- const parsedCountrySubdivisions = parsedSubdivisions.filter((logItem: LogItem) =>
- logItem.filepath.includes(`subdivisions/${country.code.toLowerCase()}`)
- )
-
- if (!parsedCountrySubdivisions.length) return
-
- output += `\r\nhttps://iptv-org.github.io/iptv/${logItem.filepath}`
- ])
- }
- }
- })
-
- const table = new HTMLTable(data.all(), [
- { name: 'Subdivision' },
- { name: 'Channels', align: 'right' },
- { name: 'Playlist', nowrap: true }
- ])
-
- output += table.toString()
-
- output += '\r\n| Country | Channels | Playlist |
|---|---|---|
| π¨π² Cameroon | 1 | https://iptv-org.github.io/iptv/countries/cm.m3u |
| π¨π¦ Canada | 2 | https://iptv-org.github.io/iptv/countries/ca.m3u |
| π¨π» Cape Verde | 1 | https://iptv-org.github.io/iptv/countries/cv.m3u |
| π¨π¬ Republic of the Congo | 1 | https://iptv-org.github.io/iptv/countries/cg.m3u |
| π·πͺ RΓ©union | 1 | https://iptv-org.github.io/iptv/countries/re.m3u |
| π·π΄ Romania | 1 | https://iptv-org.github.io/iptv/countries/ro.m3u |
| π·πΊ Russia | 2 | https://iptv-org.github.io/iptv/countries/ru.m3u |
| π·πΌ Rwanda | 1 | https://iptv-org.github.io/iptv/countries/rw.m3u |
| π§π± Saint BarthΓ©lemy | 1 | https://iptv-org.github.io/iptv/countries/bl.m3u |
| πΈπ Saint Helena | 1 | https://iptv-org.github.io/iptv/countries/sh.m3u |
| π°π³ Saint Kitts and Nevis | 1 | https://iptv-org.github.io/iptv/countries/kn.m3u |
| Undefined | 2 | https://iptv-org.github.io/iptv/countries/undefined.m3u |
https://iptv-org.github.io/iptv/countries/ad.m3u
+ - Canillo https://iptv-org.github.io/iptv/subdivisions/ad-02.m3u
+ - Canillo https://iptv-org.github.io/iptv/cities/adcan.m3u
+- π¨π² Cameroon https://iptv-org.github.io/iptv/countries/cm.m3u
+- π¨π¦ Canada https://iptv-org.github.io/iptv/countries/ca.m3u
+ - Ontario https://iptv-org.github.io/iptv/subdivisions/ca-on.m3u
+- π¨π» Cape Verde https://iptv-org.github.io/iptv/countries/cv.m3u
+- ππ° Hong Kong https://iptv-org.github.io/iptv/countries/hk.m3u
+ - Sai Kung https://iptv-org.github.io/iptv/cities/hk9sk.m3u
+- π¨π¬ Republic of the Congo https://iptv-org.github.io/iptv/countries/cg.m3u
+- π·πͺ RΓ©union https://iptv-org.github.io/iptv/countries/re.m3u
+- π·π΄ Romania https://iptv-org.github.io/iptv/countries/ro.m3u
+- π·πΊ Russia https://iptv-org.github.io/iptv/countries/ru.m3u
+- π·πΌ Rwanda https://iptv-org.github.io/iptv/countries/rw.m3u
+- π§π± Saint BarthΓ©lemy https://iptv-org.github.io/iptv/countries/bl.m3u
+- πΈπ Saint Helena https://iptv-org.github.io/iptv/countries/sh.m3u
+- π°π³ Saint Kitts and Nevis https://iptv-org.github.io/iptv/countries/kn.m3u
+- π International https://iptv-org.github.io/iptv/countries/int.m3u
+- Undefined https://iptv-org.github.io/iptv/countries/undefined.m3u
-| Subdivision | Channels | Playlist |
|---|---|---|
| Ontario | 1 | https://iptv-org.github.io/iptv/subdivisions/ca-on.m3u |
| Region | Channels | Playlist |
|---|---|---|
| Africa | 0 | https://iptv-org.github.io/iptv/regions/afr.m3u |
| Americas | 1 | https://iptv-org.github.io/iptv/regions/amer.m3u |
| Arab world | 0 | https://iptv-org.github.io/iptv/regions/arab.m3u |
| Asia | 2 | https://iptv-org.github.io/iptv/regions/asia.m3u |
| Asia-Pacific | 1 | https://iptv-org.github.io/iptv/regions/apac.m3u |
| Association of Southeast Asian Nations | 0 | https://iptv-org.github.io/iptv/regions/asean.m3u |
| Caribbean | 0 | https://iptv-org.github.io/iptv/regions/carib.m3u |
| Central America | 0 | https://iptv-org.github.io/iptv/regions/cenamer.m3u |
| Central Asia | 0 | https://iptv-org.github.io/iptv/regions/cas.m3u |
| Commonwealth of Independent States | 1 | https://iptv-org.github.io/iptv/regions/cis.m3u |
| Europe | 3 | https://iptv-org.github.io/iptv/regions/eur.m3u |
| Europe, the Middle East and Africa | 3 | https://iptv-org.github.io/iptv/regions/emea.m3u |
| Hispanic America | 0 | https://iptv-org.github.io/iptv/regions/hispam.m3u |
| Latin America | 0 | https://iptv-org.github.io/iptv/regions/latam.m3u |
| Latin America and the Caribbean | 0 | https://iptv-org.github.io/iptv/regions/lac.m3u |
| Maghreb | 0 | https://iptv-org.github.io/iptv/regions/maghreb.m3u |
| Middle East | 0 | https://iptv-org.github.io/iptv/regions/mideast.m3u |
| Middle East and North Africa | 0 | https://iptv-org.github.io/iptv/regions/mena.m3u |
| Nordics | 0 | https://iptv-org.github.io/iptv/regions/nord.m3u |
| North America | 1 | https://iptv-org.github.io/iptv/regions/noram.m3u |
| Northern America | 1 | https://iptv-org.github.io/iptv/regions/nam.m3u |
| Oceania | 0 | https://iptv-org.github.io/iptv/regions/oce.m3u |
| South America | 0 | https://iptv-org.github.io/iptv/regions/southam.m3u |
| South Asia | 1 | https://iptv-org.github.io/iptv/regions/sas.m3u |
| Sub-Saharan Africa | 0 | https://iptv-org.github.io/iptv/regions/ssa.m3u |
| West Africa | 0 | https://iptv-org.github.io/iptv/regions/wafr.m3u |
| Worldwide | 1 | https://iptv-org.github.io/iptv/regions/int.m3u |
| Undefined | 2 | https://iptv-org.github.io/iptv/regions/undefined.m3u |
https://iptv-org.github.io/iptv/regions/afr.m3u
+- Americas https://iptv-org.github.io/iptv/regions/amer.m3u
+- Arab world https://iptv-org.github.io/iptv/regions/arab.m3u
+- Asia https://iptv-org.github.io/iptv/regions/asia.m3u
+- Asia-Pacific https://iptv-org.github.io/iptv/regions/apac.m3u
+- Association of Southeast Asian Nations https://iptv-org.github.io/iptv/regions/asean.m3u
+- Caribbean https://iptv-org.github.io/iptv/regions/carib.m3u
+- Central America https://iptv-org.github.io/iptv/regions/cenamer.m3u
+- Central Asia https://iptv-org.github.io/iptv/regions/cas.m3u
+- Commonwealth of Independent States https://iptv-org.github.io/iptv/regions/cis.m3u
+- Europe https://iptv-org.github.io/iptv/regions/eur.m3u
+- Europe, the Middle East and Africa https://iptv-org.github.io/iptv/regions/emea.m3u
+- Hispanic America https://iptv-org.github.io/iptv/regions/hispam.m3u
+- Latin America https://iptv-org.github.io/iptv/regions/latam.m3u
+- Latin America and the Caribbean https://iptv-org.github.io/iptv/regions/lac.m3u
+- Maghreb https://iptv-org.github.io/iptv/regions/maghreb.m3u
+- Middle East https://iptv-org.github.io/iptv/regions/mideast.m3u
+- Middle East and North Africa https://iptv-org.github.io/iptv/regions/mena.m3u
+- Nordics https://iptv-org.github.io/iptv/regions/nord.m3u
+- North America https://iptv-org.github.io/iptv/regions/noram.m3u
+- Northern America https://iptv-org.github.io/iptv/regions/nam.m3u
+- Oceania https://iptv-org.github.io/iptv/regions/oce.m3u
+- South America https://iptv-org.github.io/iptv/regions/southam.m3u
+- South Asia https://iptv-org.github.io/iptv/regions/sas.m3u
+- Sub-Saharan Africa https://iptv-org.github.io/iptv/regions/ssa.m3u
+- West Africa https://iptv-org.github.io/iptv/regions/wafr.m3u