mirror of
https://github.com/iptv-org/epg.git
synced 2025-05-10 00:50:09 -04:00
Update bein.com.config.js
This commit is contained in:
parent
1df47d34cb
commit
4c440c0a3a
1 changed files with 14 additions and 18 deletions
|
@ -1,16 +1,10 @@
|
|||
const cheerio = require('cheerio')
|
||||
const dayjs = require('dayjs')
|
||||
const utc = require('dayjs/plugin/utc')
|
||||
const timezone = require('dayjs/plugin/timezone')
|
||||
const customParseFormat = require('dayjs/plugin/customParseFormat')
|
||||
|
||||
dayjs.extend(utc)
|
||||
dayjs.extend(timezone)
|
||||
dayjs.extend(customParseFormat)
|
||||
const { DateTime } = require('luxon')
|
||||
|
||||
module.exports = {
|
||||
site: 'bein.com',
|
||||
days: 2,
|
||||
timeout: 30000, // 30 seconds
|
||||
request: {
|
||||
cache: {
|
||||
ttl: 60 * 60 * 1000 // 1 hour
|
||||
|
@ -18,16 +12,18 @@ module.exports = {
|
|||
},
|
||||
url: function ({ date, channel }) {
|
||||
const [category] = channel.site_id.split('#')
|
||||
const postid = (channel.lang === 'ar') ? '25344' : '25356'
|
||||
const postid = channel.lang === 'ar' ? '25344' : '25356'
|
||||
|
||||
return `https://www.bein.com/${channel.lang}/epg-ajax-template/?action=epg_fetch&category=${category}&cdate=${date.format(
|
||||
return `https://www.bein.com/${
|
||||
channel.lang
|
||||
}/epg-ajax-template/?action=epg_fetch&category=${category}&cdate=${date.format(
|
||||
'YYYY-MM-DD'
|
||||
)}&language=${channel.lang.toUpperCase()}&loadindex=0&mins=00&offset=0&postid=${postid}&serviceidentity=bein.net`
|
||||
},
|
||||
parser: function ({ content, channel, date }) {
|
||||
let programs = []
|
||||
const items = parseItems(content, channel)
|
||||
date = date.subtract(1, 'd')
|
||||
date = DateTime.fromMillis(date.valueOf()).minus({ days: 1 })
|
||||
items.forEach(item => {
|
||||
const $item = cheerio.load(item)
|
||||
const title = parseTitle($item)
|
||||
|
@ -36,15 +32,15 @@ module.exports = {
|
|||
const prev = programs[programs.length - 1]
|
||||
let start = parseTime($item, date)
|
||||
if (prev) {
|
||||
if (start.isBefore(prev.start)) {
|
||||
start = start.add(1, 'd')
|
||||
date = date.add(1, 'd')
|
||||
if (start < prev.start) {
|
||||
start = start.plus({ days: 1 })
|
||||
date = date.plus({ days: 1 })
|
||||
}
|
||||
prev.stop = start
|
||||
}
|
||||
let stop = parseTime($item, start)
|
||||
if (stop.isBefore(start)) {
|
||||
stop = stop.add(1, 'd')
|
||||
if (stop < start) {
|
||||
stop = stop.plus({ days: 1 })
|
||||
}
|
||||
programs.push({
|
||||
title,
|
||||
|
@ -71,9 +67,9 @@ function parseTime($item, date) {
|
|||
.text()
|
||||
.match(/^(\d{2}:\d{2})/) || [null, null]
|
||||
if (!time) return null
|
||||
time = `${date.format('YYYY-MM-DD')} ${time}`
|
||||
time = `${date.toFormat('yyyy-MM-dd')} ${time}`
|
||||
|
||||
return dayjs.tz(time, 'YYYY-MM-DD HH:mm', 'Asia/Qatar')
|
||||
return DateTime.fromFormat(time, 'yyyy-MM-dd HH:mm', { zone: 'Asia/Qatar' }).toUTC()
|
||||
}
|
||||
|
||||
function parseItems(content, channel) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue