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,75 +1,75 @@
const axios = require('axios')
const iconv = require('iconv-lite')
const parser = require('epg-parser')
const { ungzip } = require('pako')
let cachedContent
module.exports = {
site: 'epgshare01.online',
days: 2,
url({ channel }) {
const [tag] = channel.site_id.split('#')
return `https://epgshare01.online/epgshare01/epg_ripper_${tag}.xml.gz`
},
request: {
cache: {
ttl: 24 * 60 * 60 * 1000 // 1 day
},
maxContentLength: 100000000 // 100 MB
},
parser({ 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({ tag }) {
const buffer = await axios
.get(`https://epgshare01.online/epgshare01/epg_ripper_${tag}.xml.gz`, {
responseType: 'arraybuffer'
})
.then(r => r.data)
.catch(console.error)
const content = ungzip(buffer)
const encoded = iconv.decode(content, 'utf8')
const { channels } = parser.parse(encoded)
return channels.map(channel => {
const displayName = channel.displayName[0]
return {
lang: displayName.lang || 'en',
site_id: `${tag}#${channel.id}`,
name: displayName.value
}
})
}
}
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
const [, channelId] = channel.site_id.split('#')
return programs.filter(p => p.channel === channelId && 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: 'epgshare01.online',
days: 2,
url({ channel }) {
const [tag] = channel.site_id.split('#')
return `https://epgshare01.online/epgshare01/epg_ripper_${tag}.xml.gz`
},
request: {
cache: {
ttl: 24 * 60 * 60 * 1000 // 1 day
},
maxContentLength: 100000000 // 100 MB
},
parser({ 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({ tag }) {
const buffer = await axios
.get(`https://epgshare01.online/epgshare01/epg_ripper_${tag}.xml.gz`, {
responseType: 'arraybuffer'
})
.then(r => r.data)
.catch(console.error)
const content = ungzip(buffer)
const encoded = iconv.decode(content, 'utf8')
const { channels } = parser.parse(encoded)
return channels.map(channel => {
const displayName = channel.displayName[0]
return {
lang: displayName.lang || 'en',
site_id: `${tag}#${channel.id}`,
name: displayName.value
}
})
}
}
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
const [, channelId] = channel.site_id.split('#')
return programs.filter(p => p.channel === channelId && date.isSame(p.start, 'day'))
}

View File

@@ -1,43 +1,43 @@
const { parser, url } = require('./epgshare01.online.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-02-09', 'YYYY-MM-DD').startOf('d')
const channel = { site_id: 'ALJAZEERA1#AlJazeera.English.net' }
it('can generate valid url', () => {
expect(url({ channel })).toBe('https://epgshare01.online/epgshare01/epg_ripper_ALJAZEERA1.xml.gz')
})
it('can parse response', () => {
const buffer = fs.readFileSync(path.resolve(__dirname, '__data__/content.xml.gz'))
const results = parser({ buffer, channel, date, cached: false })
expect(results.length).toBe(40)
expect(results[0]).toMatchObject({
title: 'The Palestine Laboratory',
description:
"Exposing how Israel's sales of military technology is aiding state control around the world.",
start: '2025-02-09T00:00:00.000Z',
stop: '2025-02-09T01:00:00.000Z'
})
expect(results[39]).toMatchObject({
title: 'Inside Story',
description:
'Beyond the headlines to the heart of the news of the day. Al Jazeera gets the Inside Story from some of the best minds from around the globe.',
start: '2025-02-09T23:30:00.000Z',
stop: '2025-02-10T00:00:00.000Z'
})
})
it('can handle empty guide', () => {
const results = parser({ content: '', channel, date, cached: false })
expect(results).toMatchObject([])
})
const { parser, url } = require('./epgshare01.online.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-02-09', 'YYYY-MM-DD').startOf('d')
const channel = { site_id: 'ALJAZEERA1#AlJazeera.English.net' }
it('can generate valid url', () => {
expect(url({ channel })).toBe('https://epgshare01.online/epgshare01/epg_ripper_ALJAZEERA1.xml.gz')
})
it('can parse response', () => {
const buffer = fs.readFileSync(path.resolve(__dirname, '__data__/content.xml.gz'))
const results = parser({ buffer, channel, date, cached: false })
expect(results.length).toBe(40)
expect(results[0]).toMatchObject({
title: 'The Palestine Laboratory',
description:
"Exposing how Israel's sales of military technology is aiding state control around the world.",
start: '2025-02-09T00:00:00.000Z',
stop: '2025-02-09T01:00:00.000Z'
})
expect(results[39]).toMatchObject({
title: 'Inside Story',
description:
'Beyond the headlines to the heart of the news of the day. Al Jazeera gets the Inside Story from some of the best minds from around the globe.',
start: '2025-02-09T23:30:00.000Z',
stop: '2025-02-10T00:00:00.000Z'
})
})
it('can handle empty guide', () => {
const results = parser({ content: '', channel, date, cached: false })
expect(results).toMatchObject([])
})