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 cheerio = require('cheerio')
|
||||||
const dayjs = require('dayjs')
|
const { DateTime } = require('luxon')
|
||||||
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)
|
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
site: 'bein.com',
|
site: 'bein.com',
|
||||||
days: 2,
|
days: 2,
|
||||||
|
timeout: 30000, // 30 seconds
|
||||||
request: {
|
request: {
|
||||||
cache: {
|
cache: {
|
||||||
ttl: 60 * 60 * 1000 // 1 hour
|
ttl: 60 * 60 * 1000 // 1 hour
|
||||||
|
@ -18,16 +12,18 @@ module.exports = {
|
||||||
},
|
},
|
||||||
url: function ({ date, channel }) {
|
url: function ({ date, channel }) {
|
||||||
const [category] = channel.site_id.split('#')
|
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'
|
'YYYY-MM-DD'
|
||||||
)}&language=${channel.lang.toUpperCase()}&loadindex=0&mins=00&offset=0&postid=${postid}&serviceidentity=bein.net`
|
)}&language=${channel.lang.toUpperCase()}&loadindex=0&mins=00&offset=0&postid=${postid}&serviceidentity=bein.net`
|
||||||
},
|
},
|
||||||
parser: function ({ content, channel, date }) {
|
parser: function ({ content, channel, date }) {
|
||||||
let programs = []
|
let programs = []
|
||||||
const items = parseItems(content, channel)
|
const items = parseItems(content, channel)
|
||||||
date = date.subtract(1, 'd')
|
date = DateTime.fromMillis(date.valueOf()).minus({ days: 1 })
|
||||||
items.forEach(item => {
|
items.forEach(item => {
|
||||||
const $item = cheerio.load(item)
|
const $item = cheerio.load(item)
|
||||||
const title = parseTitle($item)
|
const title = parseTitle($item)
|
||||||
|
@ -36,15 +32,15 @@ module.exports = {
|
||||||
const prev = programs[programs.length - 1]
|
const prev = programs[programs.length - 1]
|
||||||
let start = parseTime($item, date)
|
let start = parseTime($item, date)
|
||||||
if (prev) {
|
if (prev) {
|
||||||
if (start.isBefore(prev.start)) {
|
if (start < prev.start) {
|
||||||
start = start.add(1, 'd')
|
start = start.plus({ days: 1 })
|
||||||
date = date.add(1, 'd')
|
date = date.plus({ days: 1 })
|
||||||
}
|
}
|
||||||
prev.stop = start
|
prev.stop = start
|
||||||
}
|
}
|
||||||
let stop = parseTime($item, start)
|
let stop = parseTime($item, start)
|
||||||
if (stop.isBefore(start)) {
|
if (stop < start) {
|
||||||
stop = stop.add(1, 'd')
|
stop = stop.plus({ days: 1 })
|
||||||
}
|
}
|
||||||
programs.push({
|
programs.push({
|
||||||
title,
|
title,
|
||||||
|
@ -71,9 +67,9 @@ function parseTime($item, date) {
|
||||||
.text()
|
.text()
|
||||||
.match(/^(\d{2}:\d{2})/) || [null, null]
|
.match(/^(\d{2}:\d{2})/) || [null, null]
|
||||||
if (!time) return 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) {
|
function parseItems(content, channel) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue