mirror of
https://github.com/iptv-org/epg
synced 2026-04-18 00:29:23 -04:00
Merge pull request #2615 from iptv-org/add-antennasatellite.gr
Add antennasatellite.gr
This commit is contained in:
7
sites/antennasatellite.gr/__data__/content.html
Normal file
7
sites/antennasatellite.gr/__data__/content.html
Normal file
File diff suppressed because one or more lines are too long
7
sites/antennasatellite.gr/__data__/no_content.html
Normal file
7
sites/antennasatellite.gr/__data__/no_content.html
Normal file
File diff suppressed because one or more lines are too long
@@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<channels>
|
||||
<channel site="antennasatellite.gr" lang="el" xmltv_id="ANT1Satellite.gr" site_id="#">ANT1 SATELLITE</channel>
|
||||
</channels>
|
||||
59
sites/antennasatellite.gr/antennasatellite.gr.config.js
Normal file
59
sites/antennasatellite.gr/antennasatellite.gr.config.js
Normal file
@@ -0,0 +1,59 @@
|
||||
const cheerio = require('cheerio')
|
||||
const dayjs = require('dayjs')
|
||||
const utc = require('dayjs/plugin/utc')
|
||||
const timezone = require('dayjs/plugin/timezone')
|
||||
const customParseFormat = require('dayjs/plugin/customParseFormat')
|
||||
|
||||
dayjs.extend(utc)
|
||||
dayjs.extend(timezone)
|
||||
dayjs.extend(customParseFormat)
|
||||
|
||||
module.exports = {
|
||||
site: 'antennasatellite.gr',
|
||||
days: 2,
|
||||
url({ date }) {
|
||||
return `https://www.antennasatellite.gr/el/tvguide.html?date=${date.format('YYYY-MM-DD')}`
|
||||
},
|
||||
parser({ content, date }) {
|
||||
const programs = []
|
||||
const items = parseItems(content, date)
|
||||
items.forEach(item => {
|
||||
const $item = cheerio.load(item)
|
||||
const prev = programs[programs.length - 1]
|
||||
let start = parseStart($item, date)
|
||||
if (prev) {
|
||||
if (start.isBefore(prev.start)) {
|
||||
start = start.add(1, 'd')
|
||||
date = date.add(1, 'd')
|
||||
}
|
||||
prev.stop = start
|
||||
}
|
||||
const stop = start.add(30, 'm')
|
||||
programs.push({
|
||||
title: parseTitle($item),
|
||||
start,
|
||||
stop
|
||||
})
|
||||
})
|
||||
|
||||
return programs
|
||||
}
|
||||
}
|
||||
|
||||
function parseTitle($item) {
|
||||
return $item('.title').text().trim()
|
||||
}
|
||||
|
||||
function parseStart($item, date) {
|
||||
const time = $item('dt.col-time').clone().children().remove().end().text().trim()
|
||||
|
||||
return time
|
||||
? dayjs.tz(`${date.format('YYYY-MM-DD')} ${time}`, 'YYYY-MM-DD HH:mm', 'Europe/Athens')
|
||||
: null
|
||||
}
|
||||
|
||||
function parseItems(content) {
|
||||
const $ = cheerio.load(content)
|
||||
|
||||
return $('dl.show').toArray()
|
||||
}
|
||||
46
sites/antennasatellite.gr/antennasatellite.gr.test.js
Normal file
46
sites/antennasatellite.gr/antennasatellite.gr.test.js
Normal file
@@ -0,0 +1,46 @@
|
||||
const { parser, url } = require('./antennasatellite.gr.config.js')
|
||||
const fs = require('fs')
|
||||
const path = require('path')
|
||||
const dayjs = require('dayjs')
|
||||
const utc = require('dayjs/plugin/utc')
|
||||
const customParseFormat = require('dayjs/plugin/customParseFormat')
|
||||
dayjs.extend(customParseFormat)
|
||||
dayjs.extend(utc)
|
||||
|
||||
const date = dayjs.utc('2025-01-21', 'YYYY-MM-DD').startOf('d')
|
||||
|
||||
it('can generate valid url', () => {
|
||||
expect(url({ date })).toBe('https://www.antennasatellite.gr/el/tvguide.html?date=2025-01-21')
|
||||
})
|
||||
|
||||
it('can parse response', () => {
|
||||
const content = fs.readFileSync(path.resolve(__dirname, '__data__/content.html'), 'utf8')
|
||||
let results = parser({ content, date })
|
||||
results = results.map(p => {
|
||||
p.start = p.start.toJSON()
|
||||
p.stop = p.stop.toJSON()
|
||||
return p
|
||||
})
|
||||
|
||||
expect(results.length).toBe(16)
|
||||
|
||||
expect(results[0]).toMatchObject({
|
||||
start: '2025-01-21T04:00:00.000Z',
|
||||
stop: '2025-01-21T04:40:00.000Z',
|
||||
title: 'ANT1 NEWS'
|
||||
})
|
||||
|
||||
expect(results[15]).toMatchObject({
|
||||
start: '2025-01-22T00:50:00.000Z',
|
||||
stop: '2025-01-22T01:20:00.000Z',
|
||||
title: 'ΤΟ ΠΡΩΙΝΟ'
|
||||
})
|
||||
})
|
||||
|
||||
it('can handle empty guide', () => {
|
||||
const results = parser({
|
||||
date,
|
||||
content: fs.readFileSync(path.resolve(__dirname, '__data__/no_content.html'), 'utf8')
|
||||
})
|
||||
expect(results).toMatchObject([])
|
||||
})
|
||||
15
sites/antennasatellite.gr/readme.md
Normal file
15
sites/antennasatellite.gr/readme.md
Normal file
@@ -0,0 +1,15 @@
|
||||
# antennasatellite.gr
|
||||
|
||||
https://www.antennasatellite.gr/el/tvguide.html
|
||||
|
||||
### Download the guide
|
||||
|
||||
```sh
|
||||
npm run grab --- --site=antennasatellite.gr
|
||||
```
|
||||
|
||||
### Test
|
||||
|
||||
```sh
|
||||
npm test --- antennasatellite.gr
|
||||
```
|
||||
Reference in New Issue
Block a user