Replace LF endings with CRLF

This commit is contained in:
freearhey
2025-07-31 22:29:01 +03:00
parent 17e3b4ddda
commit 29aa427923
379 changed files with 29332 additions and 29332 deletions
+73 -73
View File
@@ -1,73 +1,73 @@
const axios = require('axios')
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)
module.exports = {
site: 'beinsports.com',
days: 2,
request: {
headers: {
'User-Agent':
'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/112.0.0.0 Safari/537.36'
}
},
url: function ({ date, channel }) {
return `https://www.beinsports.com/api/opta/tv-event?&startBefore=${date
.add(1, 'd')
.format('YYYY-MM-DDTHH:mm:ss.SSS')}Z&endAfter=${date.format(
'YYYY-MM-DDTHH:mm:ss.SSS'
)}Z&channelIds=${channel.site_id}`
},
parser: function ({ content }) {
let programs = []
const items = parseItems(content)
if (!items.length == 0) {
items.forEach(item => {
const start = dayjs.utc(item.startDate)
const stop = dayjs.utc(item.endDate)
programs.push({
title: item.title,
description: item.description,
start,
stop
})
})
}
return programs
},
async channels({ region, lang }) {
const data = await axios
.get(`https://www.beinsports.com/api/opta/tv-channel?region=${lang}-${region}`, this.request)
.then(r => r.data)
.catch(console.log)
return data.rows.map(item => {
return {
lang,
site_id: item.id,
name: item.name
}
})
}
}
function parseItems(content) {
let data
try {
data = JSON.parse(content)
} catch {
return []
}
if (!data || !data['rows']) {
return []
}
return data.rows
}
const axios = require('axios')
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)
module.exports = {
site: 'beinsports.com',
days: 2,
request: {
headers: {
'User-Agent':
'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/112.0.0.0 Safari/537.36'
}
},
url: function ({ date, channel }) {
return `https://www.beinsports.com/api/opta/tv-event?&startBefore=${date
.add(1, 'd')
.format('YYYY-MM-DDTHH:mm:ss.SSS')}Z&endAfter=${date.format(
'YYYY-MM-DDTHH:mm:ss.SSS'
)}Z&channelIds=${channel.site_id}`
},
parser: function ({ content }) {
let programs = []
const items = parseItems(content)
if (!items.length == 0) {
items.forEach(item => {
const start = dayjs.utc(item.startDate)
const stop = dayjs.utc(item.endDate)
programs.push({
title: item.title,
description: item.description,
start,
stop
})
})
}
return programs
},
async channels({ region, lang }) {
const data = await axios
.get(`https://www.beinsports.com/api/opta/tv-channel?region=${lang}-${region}`, this.request)
.then(r => r.data)
.catch(console.log)
return data.rows.map(item => {
return {
lang,
site_id: item.id,
name: item.name
}
})
}
}
function parseItems(content) {
let data
try {
data = JSON.parse(content)
} catch {
return []
}
if (!data || !data['rows']) {
return []
}
return data.rows
}
+43 -43
View File
@@ -1,43 +1,43 @@
const { parser, url } = require('./beinsports.com.config.js')
const dayjs = require('dayjs')
const utc = require('dayjs/plugin/utc')
const customParseFormat = require('dayjs/plugin/customParseFormat')
dayjs.extend(customParseFormat)
dayjs.extend(utc)
const date = dayjs.utc('2023-10-22T00:00:00.000', '"YYYY-MM-DDTHH:mm:ss.SSS').startOf('d')
const channel = { site_id: 'C244C48D-3B54-406A-94C9-D63B16318267', xmltv_id: 'beINSportsUSA.us' }
it('can generate valid url', () => {
const result = url({ date, channel })
expect(result).toBe(
'https://www.beinsports.com/api/opta/tv-event?&startBefore=2023-10-23T00:00:00.000Z&endAfter=2023-10-22T00:00:00.000Z&channelIds=C244C48D-3B54-406A-94C9-D63B16318267'
)
})
const content =
'{"count":1,"rows":[{"data":{"eventId":"2028126","eventDate":"2023-10-21T10:30:00","utcEventDate":"2023-10-20T23:30:00","duration":"90","programId":"106230","programTypeId":"5","title":"ATP 500"},"duration":5400000,"title":"Tokyo Day 5 QF 2","startDate":"2023-10-20T23:30:00.000Z","endDate":"2023-10-21T01:00:00.000Z","description":"Exclusive coverage of the 2023 ATP Tour on beIN SPORTS","channelId":"164C0EDA-EBCE-4AA6-9DDA-D603E0948B9F"}]}'
it('can parse response', () => {
const result = parser({ content, channel, date }).map(p => {
p.start = p.start.toJSON()
p.stop = p.stop.toJSON()
return p
})
expect(result).toMatchObject([
{
start: '2023-10-20T23:30:00.000Z',
stop: '2023-10-21T01:00:00.000Z',
title: 'Tokyo Day 5 QF 2',
description: 'Exclusive coverage of the 2023 ATP Tour on beIN SPORTS'
}
])
})
it('can handle empty guide', () => {
const result = parser({
content: '[]'
})
expect(result).toMatchObject([])
})
const { parser, url } = require('./beinsports.com.config.js')
const dayjs = require('dayjs')
const utc = require('dayjs/plugin/utc')
const customParseFormat = require('dayjs/plugin/customParseFormat')
dayjs.extend(customParseFormat)
dayjs.extend(utc)
const date = dayjs.utc('2023-10-22T00:00:00.000', '"YYYY-MM-DDTHH:mm:ss.SSS').startOf('d')
const channel = { site_id: 'C244C48D-3B54-406A-94C9-D63B16318267', xmltv_id: 'beINSportsUSA.us' }
it('can generate valid url', () => {
const result = url({ date, channel })
expect(result).toBe(
'https://www.beinsports.com/api/opta/tv-event?&startBefore=2023-10-23T00:00:00.000Z&endAfter=2023-10-22T00:00:00.000Z&channelIds=C244C48D-3B54-406A-94C9-D63B16318267'
)
})
const content =
'{"count":1,"rows":[{"data":{"eventId":"2028126","eventDate":"2023-10-21T10:30:00","utcEventDate":"2023-10-20T23:30:00","duration":"90","programId":"106230","programTypeId":"5","title":"ATP 500"},"duration":5400000,"title":"Tokyo Day 5 QF 2","startDate":"2023-10-20T23:30:00.000Z","endDate":"2023-10-21T01:00:00.000Z","description":"Exclusive coverage of the 2023 ATP Tour on beIN SPORTS","channelId":"164C0EDA-EBCE-4AA6-9DDA-D603E0948B9F"}]}'
it('can parse response', () => {
const result = parser({ content, channel, date }).map(p => {
p.start = p.start.toJSON()
p.stop = p.stop.toJSON()
return p
})
expect(result).toMatchObject([
{
start: '2023-10-20T23:30:00.000Z',
stop: '2023-10-21T01:00:00.000Z',
title: 'Tokyo Day 5 QF 2',
description: 'Exclusive coverage of the 2023 ATP Tour on beIN SPORTS'
}
])
})
it('can handle empty guide', () => {
const result = parser({
content: '[]'
})
expect(result).toMatchObject([])
})