mirror of
https://github.com/iptv-org/epg
synced 2026-05-28 03:59:23 -04:00
Fix linter issues in sites/
This commit is contained in:
@@ -23,14 +23,15 @@ module.exports = {
|
||||
channel.site_id
|
||||
}.html?dt=${date.format('YYYY-MM-DD')}`
|
||||
},
|
||||
async parser({ content, date, channel }) {
|
||||
async parser({ content, date }) {
|
||||
const programs = []
|
||||
|
||||
if (content) {
|
||||
const queues = []
|
||||
const $ = cheerio.load(content)
|
||||
|
||||
$('table.table > tbody > tr').toArray()
|
||||
$('table.table > tbody > tr')
|
||||
.toArray()
|
||||
.forEach(el => {
|
||||
const td = $(el).find('td:eq(1)')
|
||||
const title = td.find('h5 a')
|
||||
@@ -66,12 +67,16 @@ module.exports = {
|
||||
const subTitle = parseText($('.tab-pane > h5 > strong'))
|
||||
const description = parseText($('.tab-pane > .tvbody > p'))
|
||||
const image = $('.program-media-image img').attr('src')
|
||||
const category = $('.schedule-attributes-genres span').toArray()
|
||||
const category = $('.schedule-attributes-genres span')
|
||||
.toArray()
|
||||
.map(el => $(el).text())
|
||||
const casts = $('.single-cast-head:not([id])').toArray()
|
||||
const casts = $('.single-cast-head:not([id])')
|
||||
.toArray()
|
||||
.map(el => {
|
||||
const cast = { name: parseText($(el).find('a')) }
|
||||
const [, role] = $(el).text().match(/\((.*)\)/) || [null, null]
|
||||
const [, role] = $(el)
|
||||
.text()
|
||||
.match(/\((.*)\)/) || [null, null]
|
||||
if (role) {
|
||||
cast.role = role
|
||||
}
|
||||
@@ -102,7 +107,7 @@ module.exports = {
|
||||
start,
|
||||
stop
|
||||
})
|
||||
})
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -115,11 +120,17 @@ module.exports = {
|
||||
// process form -> provider
|
||||
if (queue.t === 'p') {
|
||||
const $ = cheerio.load(res)
|
||||
$('#guide_provider option').toArray()
|
||||
$('#guide_provider option')
|
||||
.toArray()
|
||||
.forEach(el => {
|
||||
const opt = $(el)
|
||||
const provider = opt.attr('value')
|
||||
queues.push({ t: 'r', method: 'post', url: 'https://www.mytelly.co.uk/getregions', params: { provider } })
|
||||
queues.push({
|
||||
t: 'r',
|
||||
method: 'post',
|
||||
url: 'https://www.mytelly.co.uk/getregions',
|
||||
params: { provider }
|
||||
})
|
||||
})
|
||||
}
|
||||
// process provider -> region
|
||||
@@ -135,26 +146,30 @@ module.exports = {
|
||||
u_time: now.format('HHmm'),
|
||||
is_mobile: 1
|
||||
}
|
||||
queues.push({ t: 's', method: 'post', url: 'https://www.mytelly.co.uk/tv-guide/schedule', params })
|
||||
queues.push({
|
||||
t: 's',
|
||||
method: 'post',
|
||||
url: 'https://www.mytelly.co.uk/tv-guide/schedule',
|
||||
params
|
||||
})
|
||||
}
|
||||
}
|
||||
// process schedule -> channels
|
||||
if (queue.t === 's') {
|
||||
const $ = cheerio.load(res)
|
||||
$('.channelname')
|
||||
.each((i, el) => {
|
||||
const name = $(el).find('center > a:eq(1)').text()
|
||||
const url = $(el).find('center > a:eq(1)').attr('href')
|
||||
const [, number, slug] = url.match(/\/(\d+)\/(.*)\.html$/)
|
||||
const site_id = `${number}/${slug}`
|
||||
if (channels[site_id] === undefined) {
|
||||
channels[site_id] = {
|
||||
lang: 'en',
|
||||
site_id,
|
||||
name
|
||||
}
|
||||
$('.channelname').each((i, el) => {
|
||||
const name = $(el).find('center > a:eq(1)').text()
|
||||
const url = $(el).find('center > a:eq(1)').attr('href')
|
||||
const [, number, slug] = url.match(/\/(\d+)\/(.*)\.html$/)
|
||||
const site_id = `${number}/${slug}`
|
||||
if (channels[site_id] === undefined) {
|
||||
channels[site_id] = {
|
||||
lang: 'en',
|
||||
site_id,
|
||||
name
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
@@ -178,13 +193,10 @@ function parseTime(date, time) {
|
||||
}
|
||||
|
||||
function parseText($item) {
|
||||
let text = $item.text()
|
||||
.replace(/\t/g, '')
|
||||
.replace(/\n/g, ' ')
|
||||
.trim()
|
||||
let text = $item.text().replace(/\t/g, '').replace(/\n/g, ' ').trim()
|
||||
while (true) {
|
||||
if (text.match(/ /)) {
|
||||
text = text.replace(/ /g, ' ')
|
||||
if (text.match(/\s\s/)) {
|
||||
text = text.replace(/\s\s/g, ' ')
|
||||
continue
|
||||
}
|
||||
break
|
||||
|
||||
@@ -17,16 +17,18 @@ const channel = {
|
||||
xmltv_id: 'BBCOneLondon.uk'
|
||||
}
|
||||
|
||||
axios.get.mockImplementation((url, opts) => {
|
||||
axios.get.mockImplementation(url => {
|
||||
if (
|
||||
url === 'https://www.mytelly.co.uk/tv-guide/listings/programme?cid=713&pid=1906433&tm=2024-12-07+00%3A00%3A00'
|
||||
url ===
|
||||
'https://www.mytelly.co.uk/tv-guide/listings/programme?cid=713&pid=1906433&tm=2024-12-07+00%3A00%3A00'
|
||||
) {
|
||||
return Promise.resolve({
|
||||
data: fs.readFileSync(path.join(__dirname, '__data__', 'programme.html'))
|
||||
})
|
||||
}
|
||||
if (
|
||||
url === 'https://www.mytelly.co.uk/tv-guide/listings/programme?cid=713&pid=5656624&tm=2024-12-07+23%3A35%3A00'
|
||||
url ===
|
||||
'https://www.mytelly.co.uk/tv-guide/listings/programme?cid=713&pid=5656624&tm=2024-12-07+23%3A35%3A00'
|
||||
) {
|
||||
return Promise.resolve({
|
||||
data: fs.readFileSync(path.join(__dirname, '__data__', 'programme2.html'))
|
||||
@@ -57,7 +59,8 @@ it('can parse response', async () => {
|
||||
title: 'Captain Phillips',
|
||||
description:
|
||||
'An American cargo ship sets a dangerous course around the coast of Somalia, while inland, four men are pressed into service as pirates by the local warlords. The captain is taken hostage when the raiding party hijacks the vessel, resulting in a tense five-day crisis. Fact-based thriller, starring Tom Hanks and Barkhad Abdi',
|
||||
image: 'https://d16ia5iwuvax6y.cloudfront.net/uk-prog-images/c44ce7b0d3ae602c0c93ece5af140815.jpg?k=VeeNdUjml3bSHdlZ0OXbGLy%2BmsLdYPwTV6iAxGkzq4dsylOCGGE7OWlqwSWt0cd0Qtrin4DkEMC0Zzdp8ZeNk2vNIQzjMF0DG0h3IeTR5NM%3D',
|
||||
image:
|
||||
'https://d16ia5iwuvax6y.cloudfront.net/uk-prog-images/c44ce7b0d3ae602c0c93ece5af140815.jpg?k=VeeNdUjml3bSHdlZ0OXbGLy%2BmsLdYPwTV6iAxGkzq4dsylOCGGE7OWlqwSWt0cd0Qtrin4DkEMC0Zzdp8ZeNk2vNIQzjMF0DG0h3IeTR5NM%3D',
|
||||
category: ['Factual', 'Movie/Drama', 'Thriller']
|
||||
})
|
||||
expect(results[1]).toMatchObject({
|
||||
@@ -67,7 +70,8 @@ it('can parse response', async () => {
|
||||
subTitle: 'Past and Pressure Season 6, Episode 5',
|
||||
description:
|
||||
'The artists are tasked with writing a song about their heritage. For some, the pressure of the competition proves too much for them to match. In their final challenge, they are put face to face with industry experts who grill them about their plans after the competition. Some impress, while others leave the mentors confused',
|
||||
image: 'https://d16ia5iwuvax6y.cloudfront.net/uk-prog-images/2039278182b27cc279570b9ab9b89379.jpg?k=VeeNdUjml3bSHdlZ0OXbGLy%2BmsLdYPwTV6iAxGkzq4cDhR7jXTNFW3tgwQCdOPUobhXwlT81mIsqOe93HPusDG6tw1aoeYOgafojtynNWxc%3D',
|
||||
image:
|
||||
'https://d16ia5iwuvax6y.cloudfront.net/uk-prog-images/2039278182b27cc279570b9ab9b89379.jpg?k=VeeNdUjml3bSHdlZ0OXbGLy%2BmsLdYPwTV6iAxGkzq4cDhR7jXTNFW3tgwQCdOPUobhXwlT81mIsqOe93HPusDG6tw1aoeYOgafojtynNWxc%3D',
|
||||
category: ['Challenge/Reality Show', 'Show/Game Show'],
|
||||
season: 6,
|
||||
episode: 5
|
||||
|
||||
Reference in New Issue
Block a user