From 130b130946115bed3123fe3184b6ce264da44cc6 Mon Sep 17 00:00:00 2001
From: freearhey <7253922+freearhey@users.noreply.github.com>
Date: Tue, 21 Jan 2025 18:48:24 +0300
Subject: [PATCH 1/8] Update tests/__data__
---
tests/__data__/expected/SITES.md | 14 ++
tests/__data__/expected/_sites.md | 13 --
tests/__data__/input/.sites/config.json | 4 -
tests/__data__/input/.sites/template.md | 4 -
.../iltalehti.fi/iltalehti.fi.channels.xml | 145 ++++++++++++++++++
.../indihometv.com.channels.xml | 133 ++++++++++++++++
.../kan.org.il/kan.org.il_1.channels.xml | 6 +
.../kan.org.il/kan.org.il_2.channels.xml | 6 +
tests/commands/sites/update.test.ts | 20 +--
9 files changed, 308 insertions(+), 37 deletions(-)
create mode 100644 tests/__data__/expected/SITES.md
delete mode 100644 tests/__data__/expected/_sites.md
delete mode 100644 tests/__data__/input/.sites/config.json
delete mode 100644 tests/__data__/input/.sites/template.md
create mode 100644 tests/__data__/input/sites-update/sites/iltalehti.fi/iltalehti.fi.channels.xml
create mode 100644 tests/__data__/input/sites-update/sites/indihometv.com/indihometv.com.channels.xml
create mode 100644 tests/__data__/input/sites-update/sites/kan.org.il/kan.org.il_1.channels.xml
create mode 100644 tests/__data__/input/sites-update/sites/kan.org.il/kan.org.il_2.channels.xml
diff --git a/tests/__data__/expected/SITES.md b/tests/__data__/expected/SITES.md
new file mode 100644
index 00000000..5f8597e3
--- /dev/null
+++ b/tests/__data__/expected/SITES.md
@@ -0,0 +1,14 @@
+# Sites
+
+\* Total number of channels / with a valid `xmltv-id`
+
+
+
+ Site | Channels * | Status | Notes |
+
+
+ iltalehti.fi | 142 / 44 | 🟡 | https://github.com/iptv-org/epg/issues/2396 |
+ indihometv.com | 130 / 124 | 🟢 | |
+ kan.org.il | 6 / 6 | 🔴 | https://github.com/iptv-org/epg/issues/2273 |
+
+
diff --git a/tests/__data__/expected/_sites.md b/tests/__data__/expected/_sites.md
deleted file mode 100644
index bd63aa62..00000000
--- a/tests/__data__/expected/_sites.md
+++ /dev/null
@@ -1,13 +0,0 @@
-# Sites
-
-
-
diff --git a/tests/__data__/input/.sites/config.json b/tests/__data__/input/.sites/config.json
deleted file mode 100644
index 2574a566..00000000
--- a/tests/__data__/input/.sites/config.json
+++ /dev/null
@@ -1,4 +0,0 @@
-{
- "build" : "tests/__data__/output/sites.md",
- "files" : ["tests/__data__/output/.sites/template.md"]
-}
\ No newline at end of file
diff --git a/tests/__data__/input/.sites/template.md b/tests/__data__/input/.sites/template.md
deleted file mode 100644
index c630b91b..00000000
--- a/tests/__data__/input/.sites/template.md
+++ /dev/null
@@ -1,4 +0,0 @@
-# Sites
-
-
-#include "tests/__data__/output/.sites/_table.md"
diff --git a/tests/__data__/input/sites-update/sites/iltalehti.fi/iltalehti.fi.channels.xml b/tests/__data__/input/sites-update/sites/iltalehti.fi/iltalehti.fi.channels.xml
new file mode 100644
index 00000000..253417a5
--- /dev/null
+++ b/tests/__data__/input/sites-update/sites/iltalehti.fi/iltalehti.fi.channels.xml
@@ -0,0 +1,145 @@
+
+
+ Viron ETV
+ National Geographic
+ Disney Channel
+ Disney Junior
+ Nat Geo Wild Scandinavia
+ V sport 1 Suomi
+ V sport 2 Suomi
+ Viasat Nature/Crime
+ V sport
+ V sport + Suomi
+ V Sport Live 1
+ V Sport Live 2
+ V Sport Live 3
+ V Sport Live 4
+ V Sport Live 5
+ Discovery Science
+ The History Channel
+ Investigation Discovery
+ Nat Geo Wild Scandinavia
+ National Geographic
+ Travel Channel
+ Viasat Explore
+ Viasat History
+ Viasat Nature/Crime
+ Barnkanalen
+ Cartoon Network
+ Cartoonito
+ Disney Channel
+ Disney Junior
+ MTV juniori
+ Nick Jr.
+ V film FAMILY
+ iConcerts
+ Club MTV
+ MTV Finland
+ MTV Live HD
+ VH1 Classic
+ Al Jazeera
+ BBC World News
+ Bloomberg TV
+ CNBC
+ CNN
+ Deutsche Welle
+ EuroNews
+ Sky News
+ MTV Ava
+ Fashion TV
+ Food Network
+ Frii
+ Liv
+ TLC
+ Travel Channel
+ V film FAMILY
+ V film HITS
+ BBC Nordic
+ RTL
+ TV Finland
+ TV5 Monde
+ Barnkanalen
+ SF-kanalen
+ MTV Urheilu 3
+ MTV Aitio
+ MTV Viihde
+ V film PREMIERE
+ V film ACTION
+ V film FAMILY
+ V film HITS
+ Eurosport
+ Eurosport 2
+ MTV Liiga 1
+ MTV Liiga 2
+ MTV Liiga 3
+ MTV Liiga 4
+ MTV Liiga 5
+ MTV Liiga 6
+ MTV Liiga 7
+ MTV Liiga UHD
+ MTV Max
+ MTV Urheilu 1
+ MTV Urheilu 2
+ MTV Urheilu 3
+ V sport FOOTBALL
+ V sport GOLF
+ V sport vinter
+ V sport 1 Suomi
+ V sport 2 Suomi
+ V sport
+ V sport PREMIUM
+ V sport + Suomi
+ V Sport Live 1
+ V Sport Live 2
+ V Sport Live 3
+ V Sport Live 4
+ V Sport Live 5
+ Animal Planet
+ MTV Ava
+ Cartoon Network
+ MTV juniori
+ MTV Max
+ MTV Urheilu 1
+ MTV Urheilu 2
+ Discovery Channel
+ Extreme Sports
+ Star
+ Frii
+ Hero
+ Himlen TV7
+ Jim
+ Kanal5
+ Kutonen
+ Liv
+ MTV3
+ MTV Aitio
+ MTV Viihde
+ National Geographic
+ Nelonen
+ SF-kanalen
+ MTV Sub
+ SVT 1
+ SVT 2
+ SVT24
+ TV7
+ TLC
+ TV3
+ TV4
+ TV5
+ TV6
+ V film ACTION
+ V film FAMILY
+ V film HITS
+ V film PREMIERE
+ Viasat Explore
+ Viasat History
+ H2
+ V sport FOOTBALL
+ V sport GOLF
+ V sport PREMIUM
+ V sport ULTRA HD
+ V sport vinter
+ Yle Teema Fem
+ Yle TV1
+ Yle TV2
+
\ No newline at end of file
diff --git a/tests/__data__/input/sites-update/sites/indihometv.com/indihometv.com.channels.xml b/tests/__data__/input/sites-update/sites/indihometv.com/indihometv.com.channels.xml
new file mode 100644
index 00000000..6eb233d8
--- /dev/null
+++ b/tests/__data__/input/sites-update/sites/indihometv.com/indihometv.com.channels.xml
@@ -0,0 +1,133 @@
+
+
+ ABC Australia
+ Aljazeera
+ Animal Planet
+ Animax
+ Aniplus
+ Antara
+ ANTV
+ Arirang
+ Asian Food Network
+ ATV
+ AXN
+ Bali TV
+ Bioskop Indonesia
+ Bloomberg
+ BTV
+ Cartoonito
+ Cartoon Network
+ CCTV4
+ Celestial Movie
+ CGTN Documentary
+ Chinese Drama
+ Cinema World
+ Citra Dangdut
+ Citra Drama
+ News Asia
+ CNBC Asia
+ CNBC Indonesia
+ CNN Indonesia
+ CNN International
+ Crime Investigation
+ Curiosity
+ Daai TV
+ Da Vinci Learning
+ Discovery Asia
+ Discovery Channel
+ Dreamworks
+ Dunia anak
+ Dunia Lain
+ DW (English)
+ Eat & Go
+ Euronews
+ FashionTV
+ Fight Sport
+ Flik
+ France 24
+ Galaxy
+ Galaxy Premium
+ HGTV
+ History
+ Hits
+ HIts Movie
+ HITS Now
+ Horee
+ Horizon Sports
+ I-Konser
+ IDTV
+ IDX
+ IMC
+ FunPlanet
+ Indonesiana TV
+ Indosiar
+ iNews
+ JakTV
+ Jawa Pos TV
+ JTV
+ KBS World
+ Kix
+ Kompas TV
+ Kplus
+ Lifetime
+ Lingua
+ Love Nature
+ Maxstream
+ Mentari TV
+ Metro TV
+ MOJI
+ Moonbug
+ MQTV
+ MTATV
+ MTV Live
+ Musik Indonesia
+ MyKidz
+ NBA
+ Net.
+ New Tv Comprehensive
+ New Tv Finance
+ New Tv Variety
+ nhk world Japan
+ Nickelodeon
+ Nick Junior
+ Insert
+ Nusantara TV
+ SONE
+ Phoenix Chinese
+ Phoenix InfoNews
+ Prambors
+ AlQuran Kareem
+ Rajawali TV
+ Rock Entertainment
+ Rock Action
+ Rodja TV
+ RRI NET
+ SCTV
+ SEA Today
+ Seru!
+ Shenzen
+ SINDO News TV
+ SPOTV 2
+ SPOTV
+ Studio Universal
+ Tawaf TV
+ Tech Storm
+ Thrill
+ TLC
+ Trans7
+ TransTV
+ TV5Monde
+ TV9 NU
+ TVBS News
+ Muhammadiyah TV
+ MUI TV
+ TVN
+ TVN Movies
+ TV One
+ TVRI
+ UChannel
+ AllPlay Ent
+ Warner
+ ZBioskop
+ Zhejiang
+
diff --git a/tests/__data__/input/sites-update/sites/kan.org.il/kan.org.il_1.channels.xml b/tests/__data__/input/sites-update/sites/kan.org.il/kan.org.il_1.channels.xml
new file mode 100644
index 00000000..c89752bc
--- /dev/null
+++ b/tests/__data__/input/sites-update/sites/kan.org.il/kan.org.il_1.channels.xml
@@ -0,0 +1,6 @@
+
+
+ مكان
+ כאן 11
+ חינוכית
+
diff --git a/tests/__data__/input/sites-update/sites/kan.org.il/kan.org.il_2.channels.xml b/tests/__data__/input/sites-update/sites/kan.org.il/kan.org.il_2.channels.xml
new file mode 100644
index 00000000..c89752bc
--- /dev/null
+++ b/tests/__data__/input/sites-update/sites/kan.org.il/kan.org.il_2.channels.xml
@@ -0,0 +1,6 @@
+
+
+ مكان
+ כאן 11
+ חינוכית
+
diff --git a/tests/commands/sites/update.test.ts b/tests/commands/sites/update.test.ts
index 0af18d4c..c14a7370 100644
--- a/tests/commands/sites/update.test.ts
+++ b/tests/commands/sites/update.test.ts
@@ -3,24 +3,14 @@ import fs from 'fs-extra'
import { pathToFileURL } from 'node:url'
import os from 'os'
-let ENV_VAR =
- 'DOT_SITES_DIR=tests/__data__/output/.sites SITES_DIR=tests/__data__/input/sites-update/sites'
+let ENV_VAR = 'SITES_DIR=tests/__data__/input/sites-update/sites ROOT_DIR=tests/__data__/output'
if (os.platform() === 'win32') {
ENV_VAR =
- 'SET "DOT_SITES_DIR=tests/__data__/output/.sites" && SET "SITES_DIR=tests/__data__/input/sites-update/sites" &&'
+ 'SET "SITES_DIR=tests/__data__/input/sites-update/sites" && SET "ROOT_DIR=tests/__data__/output" &&'
}
beforeEach(() => {
fs.emptyDirSync('tests/__data__/output')
- fs.mkdirSync('tests/__data__/output/.sites')
- fs.copyFileSync(
- 'tests/__data__/input/.sites/config.json',
- 'tests/__data__/output/.sites/config.json'
- )
- fs.copyFileSync(
- 'tests/__data__/input/.sites/template.md',
- 'tests/__data__/output/.sites/template.md'
- )
})
it('can update SITES.md', () => {
@@ -29,11 +19,9 @@ it('can update SITES.md', () => {
const stdout = execSync(cmd, { encoding: 'utf8' })
if (process.env.DEBUG === 'true') console.log(cmd, stdout)
- expect(content('tests/__data__/output/sites.md')).toEqual(
- content('tests/__data__/expected/_sites.md')
+ expect(content('tests/__data__/output/SITES.md')).toEqual(
+ content('tests/__data__/expected/SITES.md')
)
-
- expect(true).toBe(true)
})
function content(filepath: string) {
From bb31e873bf386c35b3dc35e73097f693cae76e00 Mon Sep 17 00:00:00 2001
From: freearhey <7253922+freearhey@users.noreply.github.com>
Date: Tue, 21 Jan 2025 18:48:45 +0300
Subject: [PATCH 2/8] Remove .sites/
---
.sites/.gitignore | 1 -
.sites/config.json | 4 ----
.sites/template.md | 4 ----
3 files changed, 9 deletions(-)
delete mode 100644 .sites/.gitignore
delete mode 100644 .sites/config.json
delete mode 100644 .sites/template.md
diff --git a/.sites/.gitignore b/.sites/.gitignore
deleted file mode 100644
index 3eab715b..00000000
--- a/.sites/.gitignore
+++ /dev/null
@@ -1 +0,0 @@
-_table.md
\ No newline at end of file
diff --git a/.sites/config.json b/.sites/config.json
deleted file mode 100644
index d77113c1..00000000
--- a/.sites/config.json
+++ /dev/null
@@ -1,4 +0,0 @@
-{
- "build" : "SITES.md",
- "files" : ["./.sites/template.md"]
-}
\ No newline at end of file
diff --git a/.sites/template.md b/.sites/template.md
deleted file mode 100644
index 0f16f542..00000000
--- a/.sites/template.md
+++ /dev/null
@@ -1,4 +0,0 @@
-# Sites
-
-
-#include "./.sites/_table.md"
From 700de1b737184d514504c419f1cd93aa58e64888 Mon Sep 17 00:00:00 2001
From: freearhey <7253922+freearhey@users.noreply.github.com>
Date: Tue, 21 Jan 2025 18:50:04 +0300
Subject: [PATCH 3/8] Create _sites.md
---
scripts/templates/_sites.md | 5 +++++
1 file changed, 5 insertions(+)
create mode 100644 scripts/templates/_sites.md
diff --git a/scripts/templates/_sites.md b/scripts/templates/_sites.md
new file mode 100644
index 00000000..a4c4b906
--- /dev/null
+++ b/scripts/templates/_sites.md
@@ -0,0 +1,5 @@
+# Sites
+
+\* Total number of channels / with a valid `xmltv-id`
+
+_TABLE_
From 002a3ec5c6966b9d6f21782c84e64d0b57b13404 Mon Sep 17 00:00:00 2001
From: freearhey <7253922+freearhey@users.noreply.github.com>
Date: Tue, 21 Jan 2025 18:50:53 +0300
Subject: [PATCH 4/8] Delete markdown-include package
---
package-lock.json | 34 ----------------------------------
package.json | 1 -
scripts/core/index.ts | 1 -
scripts/core/markdown.ts | 13 -------------
yarn.lock | 12 ------------
5 files changed, 61 deletions(-)
delete mode 100644 scripts/core/markdown.ts
diff --git a/package-lock.json b/package-lock.json
index 39b678c5..31a33148 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -56,7 +56,6 @@
"libxml2-wasm": "^0.5.0",
"lodash": "^4.17.21",
"luxon": "^3.3.0",
- "markdown-include": "^0.4.3",
"mockdate": "^3.0.5",
"nedb-promises": "^6.0.3",
"node-cleanup": "^2.1.2",
@@ -6420,17 +6419,6 @@
"tmpl": "1.0.5"
}
},
- "node_modules/markdown-include": {
- "version": "0.4.3",
- "resolved": "https://registry.npmjs.org/markdown-include/-/markdown-include-0.4.3.tgz",
- "integrity": "sha512-kw1f+iJ8jAH9SYljv2RXmhRQFr2oMPPVdyoKaZIH+uA1rrQqDjLk6EQZW65oVz1Y+BkC3V//9lEvKKjRZNb1Jg==",
- "dependencies": {
- "q": "^1.2.0"
- },
- "bin": {
- "markdown-include": "bin/cli.js"
- }
- },
"node_modules/merge-stream": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/merge-stream/-/merge-stream-2.0.0.tgz",
@@ -7144,15 +7132,6 @@
}
]
},
- "node_modules/q": {
- "version": "1.5.1",
- "resolved": "https://registry.npmjs.org/q/-/q-1.5.1.tgz",
- "integrity": "sha1-fjL3W0E4EpHQRhHxvxQQmsAGUdc=",
- "engines": {
- "node": ">=0.6.0",
- "teleport": ">=0.2.0"
- }
- },
"node_modules/queue-microtask": {
"version": "1.2.3",
"resolved": "https://registry.npmjs.org/queue-microtask/-/queue-microtask-1.2.3.tgz",
@@ -12894,14 +12873,6 @@
"tmpl": "1.0.5"
}
},
- "markdown-include": {
- "version": "0.4.3",
- "resolved": "https://registry.npmjs.org/markdown-include/-/markdown-include-0.4.3.tgz",
- "integrity": "sha512-kw1f+iJ8jAH9SYljv2RXmhRQFr2oMPPVdyoKaZIH+uA1rrQqDjLk6EQZW65oVz1Y+BkC3V//9lEvKKjRZNb1Jg==",
- "requires": {
- "q": "^1.2.0"
- }
- },
"merge-stream": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/merge-stream/-/merge-stream-2.0.0.tgz",
@@ -13432,11 +13403,6 @@
"resolved": "https://registry.npmjs.org/pure-rand/-/pure-rand-6.0.4.tgz",
"integrity": "sha512-LA0Y9kxMYv47GIPJy6MI84fqTd2HmYZI83W/kM/SkKfDlajnZYfmXFTxkbY+xSBPkLJxltMa9hIkmdc29eguMA=="
},
- "q": {
- "version": "1.5.1",
- "resolved": "https://registry.npmjs.org/q/-/q-1.5.1.tgz",
- "integrity": "sha1-fjL3W0E4EpHQRhHxvxQQmsAGUdc="
- },
"queue-microtask": {
"version": "1.2.3",
"resolved": "https://registry.npmjs.org/queue-microtask/-/queue-microtask-1.2.3.tgz",
diff --git a/package.json b/package.json
index a755815b..46dcb653 100644
--- a/package.json
+++ b/package.json
@@ -85,7 +85,6 @@
"libxml2-wasm": "^0.5.0",
"lodash": "^4.17.21",
"luxon": "^3.3.0",
- "markdown-include": "^0.4.3",
"mockdate": "^3.0.5",
"nedb-promises": "^6.0.3",
"node-cleanup": "^2.1.2",
diff --git a/scripts/core/index.ts b/scripts/core/index.ts
index 14a0ffa0..2c7309ed 100644
--- a/scripts/core/index.ts
+++ b/scripts/core/index.ts
@@ -13,4 +13,3 @@ export * from './queueCreator'
export * from './issueLoader'
export * from './issueParser'
export * from './htmlTable'
-export * from './markdown'
diff --git a/scripts/core/markdown.ts b/scripts/core/markdown.ts
deleted file mode 100644
index 4efaddb0..00000000
--- a/scripts/core/markdown.ts
+++ /dev/null
@@ -1,13 +0,0 @@
-import markdownInclude from 'markdown-include'
-
-export class Markdown {
- filepath: string
-
- constructor(filepath: string) {
- this.filepath = filepath
- }
-
- compile() {
- markdownInclude.compileFiles(this.filepath)
- }
-}
diff --git a/yarn.lock b/yarn.lock
index b715fa72..1ba3d3bd 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -3600,13 +3600,6 @@ makeerror@1.0.12:
dependencies:
tmpl "1.0.5"
-markdown-include@^0.4.3:
- version "0.4.3"
- resolved "https://registry.npmjs.org/markdown-include/-/markdown-include-0.4.3.tgz"
- integrity sha512-kw1f+iJ8jAH9SYljv2RXmhRQFr2oMPPVdyoKaZIH+uA1rrQqDjLk6EQZW65oVz1Y+BkC3V//9lEvKKjRZNb1Jg==
- dependencies:
- q "^1.2.0"
-
merge-stream@^2.0.0:
version "2.0.0"
resolved "https://registry.npmjs.org/merge-stream/-/merge-stream-2.0.0.tgz"
@@ -4109,11 +4102,6 @@ pure-rand@^6.0.0:
resolved "https://registry.npmjs.org/pure-rand/-/pure-rand-6.0.4.tgz"
integrity sha512-LA0Y9kxMYv47GIPJy6MI84fqTd2HmYZI83W/kM/SkKfDlajnZYfmXFTxkbY+xSBPkLJxltMa9hIkmdc29eguMA==
-q@^1.2.0:
- version "1.5.1"
- resolved "https://registry.npmjs.org/q/-/q-1.5.1.tgz"
- integrity sha1-fjL3W0E4EpHQRhHxvxQQmsAGUdc=
-
queue-microtask@^1.2.2:
version "1.2.3"
resolved "https://registry.npmjs.org/queue-microtask/-/queue-microtask-1.2.3.tgz"
From 81f2665235f64973b66cebe87b084abe7ea8a3a1 Mon Sep 17 00:00:00 2001
From: freearhey <7253922+freearhey@users.noreply.github.com>
Date: Tue, 21 Jan 2025 18:51:04 +0300
Subject: [PATCH 5/8] Update constants.ts
---
scripts/constants.ts | 1 +
1 file changed, 1 insertion(+)
diff --git a/scripts/constants.ts b/scripts/constants.ts
index e15b8b45..8af78b1d 100644
--- a/scripts/constants.ts
+++ b/scripts/constants.ts
@@ -1,3 +1,4 @@
+export const ROOT_DIR = process.env.ROOT_DIR || '.'
export const SITES_DIR = process.env.SITES_DIR || './sites'
export const GUIDES_DIR = process.env.GUIDES_DIR || './guides'
export const DATA_DIR = process.env.DATA_DIR || './temp/data'
From 7e07f408096e8b6b92f84af9cc10ec33d9fb3e58 Mon Sep 17 00:00:00 2001
From: freearhey <7253922+freearhey@users.noreply.github.com>
Date: Tue, 21 Jan 2025 18:51:12 +0300
Subject: [PATCH 6/8] Update site.ts
---
scripts/models/site.ts | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/scripts/models/site.ts b/scripts/models/site.ts
index 4fd5b33a..fa95165f 100644
--- a/scripts/models/site.ts
+++ b/scripts/models/site.ts
@@ -14,15 +14,21 @@ type Status = {
type SiteProps = {
domain: string
+ totalChannels?: number
+ markedChannels?: number
issues: Collection
}
export class Site {
domain: string
+ totalChannels: number
+ markedChannels: number
issues: Collection
- constructor({ domain, issues }: SiteProps) {
+ constructor({ domain, totalChannels = 0, markedChannels = 0, issues }: SiteProps) {
this.domain = domain
+ this.totalChannels = totalChannels
+ this.markedChannels = markedChannels
this.issues = issues
}
From 44bb8a5788cac2b26f2873bbb75f5c09cdb68427 Mon Sep 17 00:00:00 2001
From: freearhey <7253922+freearhey@users.noreply.github.com>
Date: Tue, 21 Jan 2025 18:53:55 +0300
Subject: [PATCH 7/8] Update update.ts
---
scripts/commands/sites/update.ts | 42 ++++++++++++++++++++------------
1 file changed, 27 insertions(+), 15 deletions(-)
diff --git a/scripts/commands/sites/update.ts b/scripts/commands/sites/update.ts
index b9550550..4b587df4 100644
--- a/scripts/commands/sites/update.ts
+++ b/scripts/commands/sites/update.ts
@@ -1,51 +1,63 @@
+import { Channel } from 'epg-grabber'
import { Logger, Storage, Collection } from '@freearhey/core'
-import { IssueLoader, HTMLTable, Markdown } from '../../core'
+import { IssueLoader, HTMLTable, ChannelsParser } from '../../core'
import { Issue, Site } from '../../models'
-import { SITES_DIR, DOT_SITES_DIR } from '../../constants'
-import path from 'path'
+import { SITES_DIR, ROOT_DIR } from '../../constants'
async function main() {
const logger = new Logger({ disabled: true })
const loader = new IssueLoader()
- const storage = new Storage(SITES_DIR)
+ const sitesStorage = new Storage(SITES_DIR)
+ const channelsParser = new ChannelsParser({ storage: sitesStorage })
const sites = new Collection()
logger.info('loading list of sites')
- const folders = await storage.list('*/')
+ const folders = await sitesStorage.list('*/')
logger.info('loading issues...')
const issues = await loadIssues(loader)
logger.info('putting the data together...')
- folders.forEach((domain: string) => {
+ for (const domain of folders) {
const filteredIssues = issues.filter((issue: Issue) => domain === issue.data.get('site'))
const site = new Site({
domain,
issues: filteredIssues
})
+ const files = await sitesStorage.list(`${domain}/*.channels.xml`)
+ for (const filepath of files) {
+ const channels = await channelsParser.parse(filepath)
+
+ site.totalChannels += channels.count()
+ site.markedChannels += channels.filter((channel: Channel) => channel.xmltv_id).count()
+ }
+
sites.add(site)
- })
+ }
logger.info('creating sites table...')
const data = new Collection()
sites.forEach((site: Site) => {
data.add([
`${site.domain}`,
+ `${site.totalChannels} / ${site.markedChannels}`,
site.getStatus().emoji,
site.getIssues().all().join(', ')
])
})
- const table = new HTMLTable(data.all(), [{ name: 'Site' }, { name: 'Status' }, { name: 'Notes' }])
-
- const readmeStorage = new Storage(DOT_SITES_DIR)
- await readmeStorage.save('_table.md', table.toString())
-
logger.info('updating sites.md...')
- const configPath = path.join(DOT_SITES_DIR, 'config.json')
- const sitesMarkdown = new Markdown(configPath)
- sitesMarkdown.compile()
+ const table = new HTMLTable(data.all(), [
+ { name: 'Site' },
+ { name: 'Channels *', align: 'center' },
+ { name: 'Status' },
+ { name: 'Notes' }
+ ])
+ const rootStorage = new Storage(ROOT_DIR)
+ const sitesTemplate = await new Storage().load('scripts/templates/_sites.md')
+ const sitesContent = sitesTemplate.replace('_TABLE_', table.toString())
+ await rootStorage.save('SITES.md', sitesContent)
}
main()
From bd3bfa460df4e6cbf68910454aff25359df6abba Mon Sep 17 00:00:00 2001
From: freearhey <7253922+freearhey@users.noreply.github.com>
Date: Tue, 21 Jan 2025 18:54:13 +0300
Subject: [PATCH 8/8] Update SITES.md
---
SITES.md | 445 ++++++++++++++++++++++++++++---------------------------
1 file changed, 223 insertions(+), 222 deletions(-)
diff --git a/SITES.md b/SITES.md
index 619235de..6324c2ee 100644
--- a/SITES.md
+++ b/SITES.md
@@ -1,230 +1,231 @@
# Sites
-
+\* Total number of channels / with a valid `xmltv-id`
+