mirror of
https://github.com/iptv-org/epg.git
synced 2025-05-11 17:40:07 -04:00
Fix beinsports.com
This commit is contained in:
parent
71c8b659a5
commit
227bf6df78
3 changed files with 1246 additions and 20 deletions
1202
sites/beinsports.com/__data__/content_us.html
Normal file
1202
sites/beinsports.com/__data__/content_us.html
Normal file
File diff suppressed because it is too large
Load diff
|
@ -11,6 +11,12 @@ dayjs.extend(customParseFormat)
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
site: 'beinsports.com',
|
site: 'beinsports.com',
|
||||||
|
request: {
|
||||||
|
cache: {
|
||||||
|
ttl: 60 * 60 * 1000, // 1h
|
||||||
|
interpretHeader: false
|
||||||
|
}
|
||||||
|
},
|
||||||
url: function ({ date, channel }) {
|
url: function ({ date, channel }) {
|
||||||
let [region] = channel.site_id.split('#')
|
let [region] = channel.site_id.split('#')
|
||||||
region = region ? `_${region}` : ''
|
region = region ? `_${region}` : ''
|
||||||
|
@ -19,7 +25,7 @@ module.exports = {
|
||||||
'YYYY-MM-DD'
|
'YYYY-MM-DD'
|
||||||
)}`
|
)}`
|
||||||
},
|
},
|
||||||
parser: function ({ content, channel, date }) {
|
parser: function ({ content, channel, date, cached }) {
|
||||||
let programs = []
|
let programs = []
|
||||||
const items = parseItems(content, channel)
|
const items = parseItems(content, channel)
|
||||||
date = date.subtract(1, 'd')
|
date = date.subtract(1, 'd')
|
||||||
|
@ -41,12 +47,8 @@ module.exports = {
|
||||||
if (stop.isBefore(start)) {
|
if (stop.isBefore(start)) {
|
||||||
stop = stop.add(1, 'd')
|
stop = stop.add(1, 'd')
|
||||||
}
|
}
|
||||||
programs.push({
|
|
||||||
title,
|
programs.push({ title, category, start, stop })
|
||||||
category,
|
|
||||||
start,
|
|
||||||
stop
|
|
||||||
})
|
|
||||||
})
|
})
|
||||||
|
|
||||||
return programs
|
return programs
|
||||||
|
@ -85,27 +87,33 @@ function parseTitle($item) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function parseCategory($item) {
|
function parseCategory($item) {
|
||||||
return $item('.format').text()
|
return $item('.format')
|
||||||
|
.map(function () {
|
||||||
|
return $item(this).text()
|
||||||
|
})
|
||||||
|
.get()
|
||||||
}
|
}
|
||||||
|
|
||||||
function parseStart($item, date) {
|
function parseStart($item, date) {
|
||||||
let [_, time] = $item('.time')
|
let time = $item('.time').text()
|
||||||
.text()
|
|
||||||
.match(/^(\d{2}:\d{2})/) || [null, null]
|
|
||||||
if (!time) return null
|
if (!time) return null
|
||||||
time = `${date.format('YYYY-MM-DD')} ${time}`
|
let [_, start, period] = time.match(/^(\d{2}:\d{2})( AM| PM|)/) || [null, null, null]
|
||||||
|
if (!start) return null
|
||||||
|
start = `${date.format('YYYY-MM-DD')} ${start}${period}`
|
||||||
|
const format = period ? 'YYYY-MM-DD hh:mm A' : 'YYYY-MM-DD HH:mm'
|
||||||
|
|
||||||
return dayjs.tz(time, 'YYYY-MM-DD HH:mm', 'Asia/Qatar')
|
return dayjs.tz(start, format, 'Asia/Qatar')
|
||||||
}
|
}
|
||||||
|
|
||||||
function parseStop($item, date) {
|
function parseStop($item, date) {
|
||||||
let [_, time] = $item('.time')
|
let time = $item('.time').text()
|
||||||
.text()
|
|
||||||
.match(/(\d{2}:\d{2})$/) || [null, null]
|
|
||||||
if (!time) return null
|
if (!time) return null
|
||||||
time = `${date.format('YYYY-MM-DD')} ${time}`
|
let [_, stop, period] = time.match(/(\d{2}:\d{2})( AM| PM|)$/) || [null, null, null]
|
||||||
|
if (!stop) return null
|
||||||
|
stop = `${date.format('YYYY-MM-DD')} ${stop}${period}`
|
||||||
|
const format = period ? 'YYYY-MM-DD hh:mm A' : 'YYYY-MM-DD HH:mm'
|
||||||
|
|
||||||
return dayjs.tz(time, 'YYYY-MM-DD HH:mm', 'Asia/Qatar')
|
return dayjs.tz(stop, format, 'Asia/Qatar')
|
||||||
}
|
}
|
||||||
|
|
||||||
function parseItems(content, channel) {
|
function parseItems(content, channel) {
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
// npm run channels:parse -- --config=./sites/beinsports.com/beinsports.com.config.js --output=./sites/beinsports.com/beinsports.com_qa-ar.channels.xml --set=lang:ar --set=region:ar
|
// npm run channels:parse -- --config=./sites/beinsports.com/beinsports.com.config.js --output=./sites/beinsports.com/beinsports.com_qa-ar.channels.xml --set=lang:ar --set=region:ar
|
||||||
// npx epg-grabber --config=sites/beinsports.com/beinsports.com.config.js --channels=sites/beinsports.com/beinsports.com_qa-en.channels.xml --output=guide.xml --timeout=30000 --days=2
|
// npx epg-grabber --config=sites/beinsports.com/beinsports.com.config.js --channels=sites/beinsports.com/beinsports.com_qa-en.channels.xml --output=guide.xml --timeout=30000 --days=2
|
||||||
// npx epg-grabber --config=sites/beinsports.com/beinsports.com.config.js --channels=sites/beinsports.com/beinsports.com_qa-ar.channels.xml --output=guide.xml --timeout=30000 --days=2
|
// npx epg-grabber --config=sites/beinsports.com/beinsports.com.config.js --channels=sites/beinsports.com/beinsports.com_us-en.channels.xml --output=guide.xml --timeout=30000 --days=2
|
||||||
|
|
||||||
const { parser, url } = require('./beinsports.com.config.js')
|
const { parser, url } = require('./beinsports.com.config.js')
|
||||||
const fs = require('fs')
|
const fs = require('fs')
|
||||||
|
@ -41,7 +41,23 @@ it('can parse response', () => {
|
||||||
start: '2022-05-07T19:45:00.000Z',
|
start: '2022-05-07T19:45:00.000Z',
|
||||||
stop: '2022-05-07T21:30:00.000Z',
|
stop: '2022-05-07T21:30:00.000Z',
|
||||||
title: 'Al Arabi vs Al Khor - Qatar Stars League 2021/2022',
|
title: 'Al Arabi vs Al Khor - Qatar Stars League 2021/2022',
|
||||||
category: 'Qatar Stars League'
|
category: ['Qatar Stars League']
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
it('can parse US response', () => {
|
||||||
|
const content = fs.readFileSync(path.resolve('sites/beinsports.com/__data__/content_us.html'))
|
||||||
|
const results = parser({ date, channel, content }).map(p => {
|
||||||
|
p.start = p.start.toJSON()
|
||||||
|
p.stop = p.stop.toJSON()
|
||||||
|
return p
|
||||||
|
})
|
||||||
|
|
||||||
|
expect(results[0]).toMatchObject({
|
||||||
|
start: '2022-05-07T19:30:00.000Z',
|
||||||
|
stop: '2022-05-07T21:30:00.000Z',
|
||||||
|
title: 'Basaksehir vs. Galatasaray',
|
||||||
|
category: ['Turkish Super Lig Soccer', 'Soccer']
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue