mirror of
https://github.com/iptv-org/epg
synced 2026-04-22 10:37:02 -04:00
Merge pull request #2765 from iptv-org/add-epgmaster.com
Add epgmaster.com
This commit is contained in:
1
sites/epgmaster.com/__data__/content.json
Normal file
1
sites/epgmaster.com/__data__/content.json
Normal file
File diff suppressed because one or more lines are too long
4
sites/epgmaster.com/epgmaster.com.channels.xml
Normal file
4
sites/epgmaster.com/epgmaster.com.channels.xml
Normal file
@@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<channels>
|
||||
<channel site="epgmaster.com" lang="ne" xmltv_id="NepalTelevision.np" site_id="ntv">NTV</channel>
|
||||
</channels>
|
||||
45
sites/epgmaster.com/epgmaster.com.config.js
Normal file
45
sites/epgmaster.com/epgmaster.com.config.js
Normal file
@@ -0,0 +1,45 @@
|
||||
const dayjs = require('dayjs')
|
||||
const utc = require('dayjs/plugin/utc')
|
||||
const customParseFormat = require('dayjs/plugin/customParseFormat')
|
||||
|
||||
dayjs.extend(customParseFormat)
|
||||
dayjs.extend(utc)
|
||||
|
||||
const TOKEN = '1610283054'
|
||||
|
||||
module.exports = {
|
||||
site: 'epgmaster.com',
|
||||
url({ channel }) {
|
||||
return `https://epgmaster.com/api/channels/${channel.site_id}/epgs?token=${TOKEN}`
|
||||
},
|
||||
parser({ content, date }) {
|
||||
return parseItems(content, date).map(item => {
|
||||
return {
|
||||
title: item.programName,
|
||||
start: parseStart(item),
|
||||
stop: parseStop(item)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
function parseStart(item) {
|
||||
return dayjs.utc(`${item.startDate} ${item.startTime}`, 'YYYY-MM-DD HH:mm:ss')
|
||||
}
|
||||
|
||||
function parseStop(item) {
|
||||
return dayjs.utc(`${item.startDate} ${item.endTime}`, 'YYYY-MM-DD HH:mm:ss')
|
||||
}
|
||||
|
||||
function parseItems(content, date) {
|
||||
try {
|
||||
const data = JSON.parse(content)
|
||||
if (!data || !Array.isArray(data)) return []
|
||||
const filtered = data.find(group => date.format('YYYY-MM-DD') === group.date)
|
||||
if (!filtered || !Array.isArray(filtered.epgTokenList)) return []
|
||||
|
||||
return filtered.epgTokenList
|
||||
} catch {
|
||||
return []
|
||||
}
|
||||
}
|
||||
45
sites/epgmaster.com/epgmaster.com.test.js
Normal file
45
sites/epgmaster.com/epgmaster.com.test.js
Normal file
@@ -0,0 +1,45 @@
|
||||
const { parser, url } = require('./epgmaster.com.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-05-18', 'YYYY-MM-DD').startOf('d')
|
||||
const channel = { site_id: 'ntv' }
|
||||
|
||||
it('can generate valid url', () => {
|
||||
expect(url({ channel })).toBe('https://epgmaster.com/api/channels/ntv/epgs?token=1610283054')
|
||||
})
|
||||
|
||||
it('can parse response', () => {
|
||||
const content = fs.readFileSync(path.resolve(__dirname, '__data__/content.json'))
|
||||
|
||||
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(46)
|
||||
expect(results[0]).toMatchObject({
|
||||
title: 'Krishi Teleflim-Bharosa Yuwama',
|
||||
start: '2025-05-18T00:00:00.000Z',
|
||||
stop: '2025-05-18T00:15:00.000Z'
|
||||
})
|
||||
expect(results[1]).toMatchObject({
|
||||
title: 'News in Nepali [Rec.]',
|
||||
start: '2025-05-18T00:15:00.000Z',
|
||||
stop: '2025-05-18T00:45:00.000Z'
|
||||
})
|
||||
})
|
||||
|
||||
it('can handle empty guide', () => {
|
||||
const results = parser({ content: '', date })
|
||||
|
||||
expect(results).toMatchObject([])
|
||||
})
|
||||
15
sites/epgmaster.com/readme.md
Normal file
15
sites/epgmaster.com/readme.md
Normal file
@@ -0,0 +1,15 @@
|
||||
# epgmaster.com
|
||||
|
||||
https://epgmaster.com
|
||||
|
||||
### Download the guide
|
||||
|
||||
```sh
|
||||
npm run grab --- --site=epgmaster.com
|
||||
```
|
||||
|
||||
### Test
|
||||
|
||||
```sh
|
||||
npm test --- epgmaster.com
|
||||
```
|
||||
Reference in New Issue
Block a user