Merge branch 'master' into freearhey-patch-5

This commit is contained in:
Ismaël Moret 2025-01-03 11:24:40 +01:00 committed by GitHub
commit a3caf2393d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 22 additions and 19 deletions

View file

@ -16,7 +16,7 @@ module.exports = {
channel.site_id channel.site_id
}` }`
}, },
parser({ content, channel }) { parser({ content, channel, date }) {
const programs = [] const programs = []
if (content) { if (content) {
const items = JSON.parse(content) || null const items = JSON.parse(content) || null
@ -25,16 +25,19 @@ module.exports = {
.filter(schedule => schedule.sid === channel.site_id) .filter(schedule => schedule.sid === channel.site_id)
.forEach(schedule => { .forEach(schedule => {
if (Array.isArray(schedule.events)) { if (Array.isArray(schedule.events)) {
schedule.events.forEach(event => { schedule.events
.forEach(event => {
const start = dayjs.utc(event.st * 1000) const start = dayjs.utc(event.st * 1000)
const stop = start.add(event.d, 's') if (start.isSame(date, 'd')) {
programs.push({ programs.push({
title: event.t, title: event.t,
description: event.sy, description: event.sy,
season: event.seasonnumber, season: event.seasonnumber,
episode: event.episodenumber, episode: event.episodenumber,
start, start,
stop stop: start.add(event.d, 's')
})
}
}) })
}) })
} }

View file

@ -26,17 +26,17 @@ it('can parse response', () => {
return p return p
}) })
expect(result.length).toBe(33) expect(result.length).toBe(31)
expect(result[0]).toMatchObject({ expect(result[0]).toMatchObject({
start: '2024-12-13T22:00:00.000Z', start: '2024-12-14T00:00:00.000Z',
stop: '2024-12-13T23:00:00.000Z', stop: '2024-12-14T00:30:00.000Z',
title: 'The UnXplained With...', title: 'Storage Wars',
description: description:
"The Hunt for Jack the Ripper: Jack the Ripper's identity has eluded police, historians and armchair detectives for over a century. What do we know about the notorious killer? (S3, ep 21)", 'A Sale Of Two Cities: Emily brings her mother along with her to Walnut, and Darrell wastes no time finding an advantage. Ivy and Ivy jr clean up with their locker. (S12, ep 4)',
season: 4, season: 12,
episode: 14 episode: 4
}) })
expect(result[4]).toMatchObject({ expect(result[2]).toMatchObject({
start: '2024-12-14T01:00:00.000Z', start: '2024-12-14T01:00:00.000Z',
stop: '2024-12-14T01:30:00.000Z', stop: '2024-12-14T01:30:00.000Z',
title: 'Storage Wars', title: 'Storage Wars',