From ec8ced475c40cfa5cbac9604ccba48ca2d4c50d7 Mon Sep 17 00:00:00 2001 From: BastyPro112 <157334602+BastyPro112@users.noreply.github.com> Date: Wed, 1 Jul 2026 20:23:04 -0400 Subject: [PATCH 1/2] Fix mi.tv time parsing and cheerio stuff --- package-lock.json | 48 ------------------------------------- sites/mi.tv/mi.tv.config.js | 42 ++++++++++++++++++-------------- sites/mi.tv/mi.tv.test.js | 2 +- 3 files changed, 25 insertions(+), 67 deletions(-) diff --git a/package-lock.json b/package-lock.json index d8f395a52..9bf2497ee 100644 --- a/package-lock.json +++ b/package-lock.json @@ -3119,9 +3119,6 @@ "cpu": [ "arm64" ], - "libc": [ - "glibc" - ], "license": "Apache-2.0 AND MIT", "optional": true, "os": [ @@ -3138,9 +3135,6 @@ "cpu": [ "arm64" ], - "libc": [ - "musl" - ], "license": "Apache-2.0 AND MIT", "optional": true, "os": [ @@ -3157,9 +3151,6 @@ "cpu": [ "ppc64" ], - "libc": [ - "glibc" - ], "license": "Apache-2.0 AND MIT", "optional": true, "os": [ @@ -3176,9 +3167,6 @@ "cpu": [ "s390x" ], - "libc": [ - "glibc" - ], "license": "Apache-2.0 AND MIT", "optional": true, "os": [ @@ -3195,9 +3183,6 @@ "cpu": [ "x64" ], - "libc": [ - "glibc" - ], "license": "Apache-2.0 AND MIT", "optional": true, "os": [ @@ -3214,9 +3199,6 @@ "cpu": [ "x64" ], - "libc": [ - "musl" - ], "license": "Apache-2.0 AND MIT", "optional": true, "os": [ @@ -3959,9 +3941,6 @@ "cpu": [ "arm64" ], - "libc": [ - "glibc" - ], "license": "MIT", "optional": true, "os": [ @@ -3975,9 +3954,6 @@ "cpu": [ "arm64" ], - "libc": [ - "musl" - ], "license": "MIT", "optional": true, "os": [ @@ -3991,9 +3967,6 @@ "cpu": [ "loong64" ], - "libc": [ - "glibc" - ], "license": "MIT", "optional": true, "os": [ @@ -4007,9 +3980,6 @@ "cpu": [ "loong64" ], - "libc": [ - "musl" - ], "license": "MIT", "optional": true, "os": [ @@ -4023,9 +3993,6 @@ "cpu": [ "ppc64" ], - "libc": [ - "glibc" - ], "license": "MIT", "optional": true, "os": [ @@ -4039,9 +4006,6 @@ "cpu": [ "riscv64" ], - "libc": [ - "glibc" - ], "license": "MIT", "optional": true, "os": [ @@ -4055,9 +4019,6 @@ "cpu": [ "riscv64" ], - "libc": [ - "musl" - ], "license": "MIT", "optional": true, "os": [ @@ -4071,9 +4032,6 @@ "cpu": [ "s390x" ], - "libc": [ - "glibc" - ], "license": "MIT", "optional": true, "os": [ @@ -4087,9 +4045,6 @@ "cpu": [ "x64" ], - "libc": [ - "glibc" - ], "license": "MIT", "optional": true, "os": [ @@ -4103,9 +4058,6 @@ "cpu": [ "x64" ], - "libc": [ - "musl" - ], "license": "MIT", "optional": true, "os": [ diff --git a/sites/mi.tv/mi.tv.config.js b/sites/mi.tv/mi.tv.config.js index 569259bb1..60fbeae0e 100644 --- a/sites/mi.tv/mi.tv.config.js +++ b/sites/mi.tv/mi.tv.config.js @@ -23,14 +23,22 @@ module.exports = { const [country, id] = channel.site_id.split('#') return `https://mi.tv/${country}/async/channel/${id}/${date.format('YYYY-MM-DD')}/0` }, - parser({ content, date }) { + parser({ content, date, channel }) { + const country = channel?.site_id?.split('#')?.[0] || null + let hourformat + if (country === 'co') { // Colombia uses h:mma instead of HH:mm + hourformat = 'h:mma' + } else { + hourformat = 'HH:mm' + } const programs = [] - const items = parseItems(content) - items.forEach(item => { + const $ = cheerio.load(content) + const items = parseItems($) + for (const item of items) { const prev = programs[programs.length - 1] - const $item = cheerio.load(item) - let start = parseStart($item, date) - if (!start) return + const $item = $(item) + let start = parseStart($item, date, hourformat) + if (!start) continue if (prev) { if (start.isBefore(prev.start)) { start = start.add(1, 'd') @@ -47,7 +55,7 @@ module.exports = { start, stop }) - }) + } return programs }, @@ -82,29 +90,29 @@ module.exports = { } } -function parseStart($item, date) { - const timeString = $item('a > div.content > span.time').text() +function parseStart($item, date, hourformat) { + const timeString = $item.find('a > div.content > span.time').text() if (!timeString) return null const dateString = `${date.format('MM/DD/YYYY')} ${timeString}` - return dayjs.utc(dateString, 'MM/DD/YYYY HH:mm') + return dayjs.utc(dateString, `MM/DD/YYYY ${hourformat}`) } function parseTitle($item) { - return $item('a > div.content > h2').text().trim() + return $item.find('a > div.content > h2').text().trim() } function parseCategory($item) { - return $item('a > div.content > span.sub-title').text().trim() + return $item.find('a > div.content > span.sub-title').text().trim() } function parseDescription($item) { - return $item('a > div.content > p.synopsis').text().trim() + return $item.find('a > div.content > p.synopsis').text().trim() } function parseImage($item) { - const styleAttr = $item('a > div.image-parent > div.image').attr('style') + const styleAttr = $item.find('a > div.image-parent > div.image').attr('style') if (styleAttr) { const match = styleAttr.match(/background-image:\s*url\(['"]?(.*?)['"]?\)/) @@ -113,7 +121,7 @@ function parseImage($item) { } } - const backgroundImage = $item('a > div.image-parent > div.image').css('background-image') + const backgroundImage = $item.find('a > div.image-parent > div.image').css('background-image') if (backgroundImage && backgroundImage !== 'none') { const match = backgroundImage.match(/url\(['"]?(.*?)['"]?\)/) @@ -137,8 +145,6 @@ function cleanUrl(url) { } -function parseItems(content) { - const $ = cheerio.load(content) - +function parseItems($) { return $('#listings > ul > li').toArray() } \ No newline at end of file diff --git a/sites/mi.tv/mi.tv.test.js b/sites/mi.tv/mi.tv.test.js index ec5652e02..acc8fce79 100644 --- a/sites/mi.tv/mi.tv.test.js +++ b/sites/mi.tv/mi.tv.test.js @@ -21,7 +21,7 @@ it('can generate valid url', () => { it('can parse response', () => { const content = fs.readFileSync(path.resolve(__dirname, '__data__/content.html'), 'utf8') - const result = parser({ content, date }).map(p => { + const result = parser({ content, date, channel }).map(p => { p.start = p.start.toJSON() p.stop = p.stop.toJSON() return p From a2b4e51b71651d3c348f952a3f14d842b802357a Mon Sep 17 00:00:00 2001 From: BastyPro112 <157334602+BastyPro112@users.noreply.github.com> Date: Wed, 1 Jul 2026 22:30:46 -0400 Subject: [PATCH 2/2] Revert --- package-lock.json | 48 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/package-lock.json b/package-lock.json index 9bf2497ee..d8f395a52 100644 --- a/package-lock.json +++ b/package-lock.json @@ -3119,6 +3119,9 @@ "cpu": [ "arm64" ], + "libc": [ + "glibc" + ], "license": "Apache-2.0 AND MIT", "optional": true, "os": [ @@ -3135,6 +3138,9 @@ "cpu": [ "arm64" ], + "libc": [ + "musl" + ], "license": "Apache-2.0 AND MIT", "optional": true, "os": [ @@ -3151,6 +3157,9 @@ "cpu": [ "ppc64" ], + "libc": [ + "glibc" + ], "license": "Apache-2.0 AND MIT", "optional": true, "os": [ @@ -3167,6 +3176,9 @@ "cpu": [ "s390x" ], + "libc": [ + "glibc" + ], "license": "Apache-2.0 AND MIT", "optional": true, "os": [ @@ -3183,6 +3195,9 @@ "cpu": [ "x64" ], + "libc": [ + "glibc" + ], "license": "Apache-2.0 AND MIT", "optional": true, "os": [ @@ -3199,6 +3214,9 @@ "cpu": [ "x64" ], + "libc": [ + "musl" + ], "license": "Apache-2.0 AND MIT", "optional": true, "os": [ @@ -3941,6 +3959,9 @@ "cpu": [ "arm64" ], + "libc": [ + "glibc" + ], "license": "MIT", "optional": true, "os": [ @@ -3954,6 +3975,9 @@ "cpu": [ "arm64" ], + "libc": [ + "musl" + ], "license": "MIT", "optional": true, "os": [ @@ -3967,6 +3991,9 @@ "cpu": [ "loong64" ], + "libc": [ + "glibc" + ], "license": "MIT", "optional": true, "os": [ @@ -3980,6 +4007,9 @@ "cpu": [ "loong64" ], + "libc": [ + "musl" + ], "license": "MIT", "optional": true, "os": [ @@ -3993,6 +4023,9 @@ "cpu": [ "ppc64" ], + "libc": [ + "glibc" + ], "license": "MIT", "optional": true, "os": [ @@ -4006,6 +4039,9 @@ "cpu": [ "riscv64" ], + "libc": [ + "glibc" + ], "license": "MIT", "optional": true, "os": [ @@ -4019,6 +4055,9 @@ "cpu": [ "riscv64" ], + "libc": [ + "musl" + ], "license": "MIT", "optional": true, "os": [ @@ -4032,6 +4071,9 @@ "cpu": [ "s390x" ], + "libc": [ + "glibc" + ], "license": "MIT", "optional": true, "os": [ @@ -4045,6 +4087,9 @@ "cpu": [ "x64" ], + "libc": [ + "glibc" + ], "license": "MIT", "optional": true, "os": [ @@ -4058,6 +4103,9 @@ "cpu": [ "x64" ], + "libc": [ + "musl" + ], "license": "MIT", "optional": true, "os": [