mirror of
https://github.com/iptv-org/epg
synced 2026-09-10 22:06:56 -04:00
Update tv.mail.ru
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
const { DateTime } = require('luxon')
|
||||
const axios = require('axios')
|
||||
|
||||
module.exports = {
|
||||
site: 'tv.mail.ru',
|
||||
@@ -32,9 +33,55 @@ module.exports = {
|
||||
})
|
||||
|
||||
return programs
|
||||
},
|
||||
async channels() {
|
||||
const _ = require('lodash')
|
||||
|
||||
const regions = [5506, 1096, 1125, 285]
|
||||
|
||||
let channels = []
|
||||
for (let region of regions) {
|
||||
const totalPages = await getTotalPageCount(region)
|
||||
const pages = Array.from(Array(totalPages).keys())
|
||||
for (let page of pages) {
|
||||
const data = await axios
|
||||
.get('https://tv.mail.ru/ajax/channel/list/', {
|
||||
params: { page },
|
||||
headers: {
|
||||
cookie: `s=fver=0|geo=${region};`
|
||||
}
|
||||
})
|
||||
.then(r => r.data)
|
||||
.catch(console.log)
|
||||
|
||||
data.channels.forEach(item => {
|
||||
channels.push({
|
||||
lang: 'ru',
|
||||
name: item.name,
|
||||
site_id: item.id
|
||||
})
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
return _.uniqBy(channels, 'site_id')
|
||||
}
|
||||
}
|
||||
|
||||
async function getTotalPageCount(region) {
|
||||
const data = await axios
|
||||
.get(`https://tv.mail.ru/ajax/channel/list/`, {
|
||||
params: { page: 0 },
|
||||
headers: {
|
||||
cookie: `s=fver=0|geo=${region};`
|
||||
}
|
||||
})
|
||||
.then(r => r.data)
|
||||
.catch(console.log)
|
||||
|
||||
return data.total
|
||||
}
|
||||
|
||||
function parseStart(item, date) {
|
||||
const dateString = `${date.format('YYYY-MM-DD')} ${item.start}`
|
||||
|
||||
|
||||
Reference in New Issue
Block a user