Merge pull request #2587 from iptv-org/add-epg.iptvx.one

Add epg.iptvx.one
This commit is contained in:
PopeyeTheSai10r
2025-01-15 17:33:42 -08:00
committed by GitHub
8 changed files with 3027 additions and 0 deletions

Binary file not shown.

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,64 @@
const axios = require('axios')
const iconv = require('iconv-lite')
const parser = require('epg-parser')
const { ungzip } = require('pako')
let cachedContent
module.exports = {
site: 'epg.iptvx.one',
days: 2,
url: 'https://iptvx.one/epg/epg_noarch.xml.gz',
request: {
maxContentLength: 500000000, // 500 MB
cache: {
ttl: 24 * 60 * 60 * 1000 // 1 day
}
},
parser: function ({ buffer, channel, date, cached }) {
if (!cached) cachedContent = undefined
let programs = []
const items = parseItems(buffer, channel, date)
items.forEach(item => {
programs.push({
title: item.title?.[0]?.value,
description: item.desc?.[0]?.value,
start: item.start,
stop: item.stop
})
})
return programs
},
async channels() {
const data = await axios
.get('https://epg.iptvx.one/api/channels.json')
.then(r => r.data)
.catch(console.log)
return data.channels.map(channel => {
const [name] = channel.chan_names.split(' • ')
return {
lang: 'ru',
site_id: channel.chan_id,
name
}
})
}
}
function parseItems(buffer, channel, date) {
if (!buffer) return []
if (!cachedContent) {
const content = ungzip(buffer)
const encoded = iconv.decode(content, 'utf8')
cachedContent = parser.parse(encoded)
}
const { programs } = cachedContent
return programs.filter(p => p.channel === channel.site_id && date.isSame(p.start, 'day'))
}

View File

@@ -0,0 +1,46 @@
const { parser, url } = require('./epg.iptvx.one.config.js')
const dayjs = require('dayjs')
const utc = require('dayjs/plugin/utc')
const timezone = require('dayjs/plugin/timezone')
const fs = require('fs')
const path = require('path')
dayjs.extend(utc)
dayjs.extend(timezone)
const date = dayjs.utc('2025-01-13', 'YYYY-MM-DD').startOf('d')
const channel = { site_id: '12-omsk', xmltv_id: 'Channel12.ru' }
it('can generate valid url', () => {
expect(url).toBe('https://iptvx.one/epg/epg_noarch.xml.gz')
})
it('can parse response', () => {
const buffer = fs.readFileSync(path.resolve(__dirname, '__data__/content.xml.gz'))
const results = parser({ date, buffer, channel })
expect(results.length).toBe(29)
expect(results[0]).toMatchObject({
start: '2025-01-13T00:00:00.000Z',
stop: '2025-01-13T00:55:00.000Z',
title: 'Акценты недели',
description:
'Программа расскажет зрителям о том, как развивались самые яркие события недели, поможет расставить акценты над самыми обсуждаемыми новостями. Россия, ток-шоу'
})
expect(results[28]).toMatchObject({
start: '2025-01-13T22:15:00.000Z',
stop: '2025-01-14T00:00:00.000Z',
title: 'д/с Необыкновенные люди',
description:
'Герои цикла врачи, спортсмены, представители творческих профессий, волонтеры и многие-многие другие. Их деятельность связана с жизнью особенных людей. Россия, док. сериал'
})
})
it('can handle empty guide', () => {
const result = parser({
date,
channel,
buffer: ''
})
expect(result).toMatchObject([])
})

View File

@@ -0,0 +1,35 @@
# epg.iptvx.one
https://epg.iptvx.one/
### Download the guide
Windows (Command Prompt):
```sh
SET "NODE_OPTIONS=--max-old-space-size=5000" && npm run grab --- --site=epg.iptvx.one
```
Windows (PowerShell):
```sh
$env:NODE_OPTIONS="--max-old-space-size=5000"; npm run grab --- --site=epg.iptvx.one
```
Linux and macOS:
```sh
NODE_OPTIONS=--max-old-space-size=5000 npm run grab --- --site=epg.iptvx.one
```
### Update channel list
```sh
npm run channels:parse --- --config=./sites/epg.iptvx.one/epg.iptvx.one.config.js --output=./sites/epg.iptvx.one/epg.iptvx.one.channels.xml
```
### Test
```sh
npm test --- epg.iptvx.one
```