Replace LF endings with CRLF

This commit is contained in:
freearhey
2025-07-31 22:29:01 +03:00
parent 17e3b4ddda
commit 29aa427923
379 changed files with 29332 additions and 29332 deletions

View File

@@ -1,64 +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'))
}
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

@@ -1,46 +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([])
})
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([])
})