mirror of
https://github.com/iptv-org/epg
synced 2026-04-30 22:46:58 -04:00
Replace LF endings with CRLF
This commit is contained in:
@@ -1,86 +1,86 @@
|
||||
const cheerio = require('cheerio')
|
||||
const axios = require('axios')
|
||||
const { DateTime } = require('luxon')
|
||||
|
||||
module.exports = {
|
||||
site: 'awilime.com',
|
||||
days: 2,
|
||||
url({ channel, date }) {
|
||||
return `https://www.awilime.com/tv/napi_musor/${channel.site_id}/${date.format('YYYY_MM_DD')}`
|
||||
},
|
||||
parser({ content, date }) {
|
||||
const programs = []
|
||||
const items = parseItems(content)
|
||||
items.forEach(item => {
|
||||
const prev = programs[programs.length - 1]
|
||||
const $item = cheerio.load(item)
|
||||
let start = parseStart($item, date)
|
||||
if (!start) return
|
||||
if (prev) {
|
||||
prev.stop = start
|
||||
}
|
||||
const stop = start.plus({ minute: 30 })
|
||||
|
||||
programs.push({
|
||||
title: parseTitle($item),
|
||||
sub_title: parseSubTitle($item),
|
||||
description: parseDescription($item),
|
||||
start,
|
||||
stop
|
||||
})
|
||||
})
|
||||
|
||||
return programs
|
||||
},
|
||||
async channels() {
|
||||
const html = await axios
|
||||
.get('https://www.awilime.com/tv/napi_musor')
|
||||
.then(r => r.data)
|
||||
.catch(console.log)
|
||||
const $ = cheerio.load(html)
|
||||
const items = $('#body > div.tk > div > div').toArray()
|
||||
|
||||
const channels = []
|
||||
items.forEach(item => {
|
||||
const name = $(item).find('a').text().trim()
|
||||
const url = $(item).find('a').attr('href')
|
||||
const [, site_id] = url.match(/\/tv\/napi_musor\/(.*)/) || [null, null]
|
||||
if (!site_id) return
|
||||
if (channels.find(channel => channel.site_id === site_id)) return
|
||||
|
||||
channels.push({
|
||||
lang: 'hu',
|
||||
site_id,
|
||||
name
|
||||
})
|
||||
})
|
||||
|
||||
return channels
|
||||
}
|
||||
}
|
||||
|
||||
function parseTitle($item) {
|
||||
return $item('b > a').text().trim()
|
||||
}
|
||||
|
||||
function parseSubTitle($item) {
|
||||
return $item('i').clone().children().remove('s').end().text().trim()
|
||||
}
|
||||
|
||||
function parseDescription($item) {
|
||||
return $item('p').text().trim()
|
||||
}
|
||||
|
||||
function parseStart($item, date) {
|
||||
let time = $item('b').clone().children().remove().end().text().trim()
|
||||
if (!time || !/^\d/.test(time)) return null
|
||||
time = `${date.format('YYYY-MM-DD')} ${time}`
|
||||
|
||||
return DateTime.fromFormat(time, 'yyyy-MM-dd HH:mm', { zone: 'Europe/Budapest' }).toUTC()
|
||||
}
|
||||
|
||||
function parseItems(content) {
|
||||
const $ = cheerio.load(content)
|
||||
|
||||
return $('#body > div.tdc > div.td2 > div').toArray()
|
||||
}
|
||||
const cheerio = require('cheerio')
|
||||
const axios = require('axios')
|
||||
const { DateTime } = require('luxon')
|
||||
|
||||
module.exports = {
|
||||
site: 'awilime.com',
|
||||
days: 2,
|
||||
url({ channel, date }) {
|
||||
return `https://www.awilime.com/tv/napi_musor/${channel.site_id}/${date.format('YYYY_MM_DD')}`
|
||||
},
|
||||
parser({ content, date }) {
|
||||
const programs = []
|
||||
const items = parseItems(content)
|
||||
items.forEach(item => {
|
||||
const prev = programs[programs.length - 1]
|
||||
const $item = cheerio.load(item)
|
||||
let start = parseStart($item, date)
|
||||
if (!start) return
|
||||
if (prev) {
|
||||
prev.stop = start
|
||||
}
|
||||
const stop = start.plus({ minute: 30 })
|
||||
|
||||
programs.push({
|
||||
title: parseTitle($item),
|
||||
sub_title: parseSubTitle($item),
|
||||
description: parseDescription($item),
|
||||
start,
|
||||
stop
|
||||
})
|
||||
})
|
||||
|
||||
return programs
|
||||
},
|
||||
async channels() {
|
||||
const html = await axios
|
||||
.get('https://www.awilime.com/tv/napi_musor')
|
||||
.then(r => r.data)
|
||||
.catch(console.log)
|
||||
const $ = cheerio.load(html)
|
||||
const items = $('#body > div.tk > div > div').toArray()
|
||||
|
||||
const channels = []
|
||||
items.forEach(item => {
|
||||
const name = $(item).find('a').text().trim()
|
||||
const url = $(item).find('a').attr('href')
|
||||
const [, site_id] = url.match(/\/tv\/napi_musor\/(.*)/) || [null, null]
|
||||
if (!site_id) return
|
||||
if (channels.find(channel => channel.site_id === site_id)) return
|
||||
|
||||
channels.push({
|
||||
lang: 'hu',
|
||||
site_id,
|
||||
name
|
||||
})
|
||||
})
|
||||
|
||||
return channels
|
||||
}
|
||||
}
|
||||
|
||||
function parseTitle($item) {
|
||||
return $item('b > a').text().trim()
|
||||
}
|
||||
|
||||
function parseSubTitle($item) {
|
||||
return $item('i').clone().children().remove('s').end().text().trim()
|
||||
}
|
||||
|
||||
function parseDescription($item) {
|
||||
return $item('p').text().trim()
|
||||
}
|
||||
|
||||
function parseStart($item, date) {
|
||||
let time = $item('b').clone().children().remove().end().text().trim()
|
||||
if (!time || !/^\d/.test(time)) return null
|
||||
time = `${date.format('YYYY-MM-DD')} ${time}`
|
||||
|
||||
return DateTime.fromFormat(time, 'yyyy-MM-dd HH:mm', { zone: 'Europe/Budapest' }).toUTC()
|
||||
}
|
||||
|
||||
function parseItems(content) {
|
||||
const $ = cheerio.load(content)
|
||||
|
||||
return $('#body > div.tdc > div.td2 > div').toArray()
|
||||
}
|
||||
|
||||
@@ -1,49 +1,49 @@
|
||||
const { parser, url } = require('./awilime.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('2024-06-26', 'YYYY-MM-DD').startOf('d')
|
||||
const channel = {
|
||||
site_id: 'budapest_europa_tv',
|
||||
xmltv_id: 'BudapestEuropaTelevizio.hu'
|
||||
}
|
||||
|
||||
it('can generate valid url', () => {
|
||||
expect(url({ channel, date })).toBe(
|
||||
'https://www.awilime.com/tv/napi_musor/budapest_europa_tv/2024_06_26'
|
||||
)
|
||||
})
|
||||
|
||||
it('can parse response', () => {
|
||||
const content = fs.readFileSync(path.resolve(__dirname, '__data__/content.html'))
|
||||
const results = parser({ content, date }).map(p => {
|
||||
p.start = p.start.toJSON()
|
||||
p.stop = p.stop.toJSON()
|
||||
return p
|
||||
})
|
||||
|
||||
expect(results.length).toBe(15)
|
||||
|
||||
expect(results[3]).toMatchObject({
|
||||
start: '2024-06-26T07:00:00.000Z',
|
||||
stop: '2024-06-26T08:00:00.000Z',
|
||||
title: 'Ébredés',
|
||||
sub_title: 'Amerikai dokumentumfilm (2018)',
|
||||
description: 'Balla Tibor misszionárius'
|
||||
})
|
||||
})
|
||||
|
||||
it('can handle empty guide', () => {
|
||||
const result = parser({
|
||||
date,
|
||||
channel,
|
||||
content:
|
||||
'<html><head><title>Object moved</title></head><body><h2>Object moved to <a href="/tv/napi_musor/budapest_europa_tv/2024_06_24">here</a>.</h2></body></html>'
|
||||
})
|
||||
expect(result).toMatchObject([])
|
||||
})
|
||||
const { parser, url } = require('./awilime.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('2024-06-26', 'YYYY-MM-DD').startOf('d')
|
||||
const channel = {
|
||||
site_id: 'budapest_europa_tv',
|
||||
xmltv_id: 'BudapestEuropaTelevizio.hu'
|
||||
}
|
||||
|
||||
it('can generate valid url', () => {
|
||||
expect(url({ channel, date })).toBe(
|
||||
'https://www.awilime.com/tv/napi_musor/budapest_europa_tv/2024_06_26'
|
||||
)
|
||||
})
|
||||
|
||||
it('can parse response', () => {
|
||||
const content = fs.readFileSync(path.resolve(__dirname, '__data__/content.html'))
|
||||
const results = parser({ content, date }).map(p => {
|
||||
p.start = p.start.toJSON()
|
||||
p.stop = p.stop.toJSON()
|
||||
return p
|
||||
})
|
||||
|
||||
expect(results.length).toBe(15)
|
||||
|
||||
expect(results[3]).toMatchObject({
|
||||
start: '2024-06-26T07:00:00.000Z',
|
||||
stop: '2024-06-26T08:00:00.000Z',
|
||||
title: 'Ébredés',
|
||||
sub_title: 'Amerikai dokumentumfilm (2018)',
|
||||
description: 'Balla Tibor misszionárius'
|
||||
})
|
||||
})
|
||||
|
||||
it('can handle empty guide', () => {
|
||||
const result = parser({
|
||||
date,
|
||||
channel,
|
||||
content:
|
||||
'<html><head><title>Object moved</title></head><body><h2>Object moved to <a href="/tv/napi_musor/budapest_europa_tv/2024_06_24">here</a>.</h2></body></html>'
|
||||
})
|
||||
expect(result).toMatchObject([])
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user