Update tv24.co.uk.config.js

This commit is contained in:
freearhey 2025-03-29 08:45:27 +03:00
parent f3c4918d44
commit ff60520443

View file

@ -40,35 +40,33 @@ module.exports = {
},
async channels() {
let html = await axios
.get('https://tv24.co.uk/x/settings/addremove')
.then(r => r.data)
.catch(console.log)
let $ = cheerio.load(html)
const nums = $('li')
.toArray()
.map(item => $(item).data('channel'))
html = await axios
.get('https://tv24.co.uk', {
.get('https://tv24.co.uk/x/settings/addremove', {
headers: {
Cookie: `selectedChannels=${nums.join(',')}`
Cookie: 'selectedPostcode=-; selectedProvider=1000193'
}
})
.then(r => r.data)
.catch(console.log)
$ = cheerio.load(html)
const items = $('li.c').toArray()
let $ = cheerio.load(html)
return items.map(item => {
const name = $(item).find('h3').text().trim()
const link = $(item).find('.channel').attr('href')
const [, site_id] = link.match(/\/channel\/(.*)/) || [null, null]
let channels = []
$('li')
.toArray()
.forEach(item => {
const link = $(item).find('img').attr('src')
if (!link || link.includes('ic_channel_default')) return
const [, filename] = link.match(/channels\/(.*)\./)
const site_id = filename.replace('-l', '')
const name = $(item).find('h3').text().trim()
return {
lang: 'en',
site_id,
name
}
})
channels.push({
lang: 'en',
site_id,
name
})
})
return channels
}
}