Replace LF line endings with CRLF

This commit is contained in:
freearhey
2025-09-28 17:55:05 +03:00
parent efc74efcf8
commit b6a589c62a
1192 changed files with 445631 additions and 445631 deletions
+21 -21
View File
@@ -1,21 +1,21 @@
# tvarenasport.hr
https://www.tvarenasport.hr/
### Download the guide
```sh
npm run grab --- --site=tvarenasport.hr
```
### Update channel list
```sh
npm run channels:parse --- --config=./sites/tvarenasport.hr/tvarenasport.hr.config.js --output=./sites/tvarenasport.hr/tvarenasport.hr.channels.xml
```
### Test
```sh
npm test --- tvarenasport.hr
```
# tvarenasport.hr
https://www.tvarenasport.hr/
### Download the guide
```sh
npm run grab --- --site=tvarenasport.hr
```
### Update channel list
```sh
npm run channels:parse --- --config=./sites/tvarenasport.hr/tvarenasport.hr.config.js --output=./sites/tvarenasport.hr/tvarenasport.hr.channels.xml
```
### Test
```sh
npm test --- tvarenasport.hr
```
@@ -1,13 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<channels>
<channel site="tvarenasport.hr" lang="hr" xmltv_id="ArenaSport1.hr" site_id="01">Arena Sport 1</channel>
<channel site="tvarenasport.hr" lang="hr" xmltv_id="ArenaSport2.hr" site_id="02">Arena Sport 2</channel>
<channel site="tvarenasport.hr" lang="hr" xmltv_id="ArenaSport3.hr" site_id="03">Arena Sport 3</channel>
<channel site="tvarenasport.hr" lang="hr" xmltv_id="ArenaSport4.hr" site_id="04">Arena Sport 4</channel>
<channel site="tvarenasport.hr" lang="hr" xmltv_id="ArenaSport5.hr" site_id="05">Arena Sport 5</channel>
<channel site="tvarenasport.hr" lang="hr" xmltv_id="ArenaSport6.hr" site_id="06">Arena Sport 6</channel>
<channel site="tvarenasport.hr" lang="hr" xmltv_id="ArenaSport7.hr" site_id="07">Arena Sport 7</channel>
<channel site="tvarenasport.hr" lang="hr" xmltv_id="ArenaSport8.hr" site_id="08">Arena Sport 8</channel>
<channel site="tvarenasport.hr" lang="hr" xmltv_id="ArenaSport9.hr" site_id="09">Arena Sport 9</channel>
<channel site="tvarenasport.hr" lang="hr" xmltv_id="ArenaSport10.hr" site_id="10">Arena Sport 10</channel>
</channels>
<?xml version="1.0" encoding="UTF-8"?>
<channels>
<channel site="tvarenasport.hr" lang="hr" xmltv_id="ArenaSport1.hr" site_id="01">Arena Sport 1</channel>
<channel site="tvarenasport.hr" lang="hr" xmltv_id="ArenaSport2.hr" site_id="02">Arena Sport 2</channel>
<channel site="tvarenasport.hr" lang="hr" xmltv_id="ArenaSport3.hr" site_id="03">Arena Sport 3</channel>
<channel site="tvarenasport.hr" lang="hr" xmltv_id="ArenaSport4.hr" site_id="04">Arena Sport 4</channel>
<channel site="tvarenasport.hr" lang="hr" xmltv_id="ArenaSport5.hr" site_id="05">Arena Sport 5</channel>
<channel site="tvarenasport.hr" lang="hr" xmltv_id="ArenaSport6.hr" site_id="06">Arena Sport 6</channel>
<channel site="tvarenasport.hr" lang="hr" xmltv_id="ArenaSport7.hr" site_id="07">Arena Sport 7</channel>
<channel site="tvarenasport.hr" lang="hr" xmltv_id="ArenaSport8.hr" site_id="08">Arena Sport 8</channel>
<channel site="tvarenasport.hr" lang="hr" xmltv_id="ArenaSport9.hr" site_id="09">Arena Sport 9</channel>
<channel site="tvarenasport.hr" lang="hr" xmltv_id="ArenaSport10.hr" site_id="10">Arena Sport 10</channel>
</channels>
+132 -132
View File
@@ -1,132 +1,132 @@
const cheerio = require('cheerio')
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: 'tvarenasport.hr',
tz: 'Europe/Budapest',
lang: 'hr',
url: 'https://tvarenaprogram.com/live/v2/hr',
days: 2,
request: {
cache: {
ttl: 24 * 60 * 60 * 1000 // 1 day
}
},
parser({ content, channel, date }) {
const programs = []
const expectedDate = date.format('YYYY-MM-DD')
if (content) {
const dates = []
const $ = cheerio.load(content)
const parent = $(
`.tv-scheme-chanel-header img[src*="chanel-${channel.site_id}.png"]`
).parents('div')
parent
.siblings('.tv-scheme-days')
.find('a')
.toArray()
.forEach(el => {
const a = $(el)
const dt = a.find('span:nth-child(3)').text()
dates.push(dayjs(dt + date.year(), 'DD.MM.YYYY'))
})
parent
.siblings('.tv-scheme-new-slider-wrapper')
.find('.tv-scheme-new-slider-item')
.toArray()
.forEach((el, i) => {
programs.push(...parseSchedules($(el), dates[i], module.exports.tz))
})
programs.forEach((s, i) => {
if (i < programs.length - 2) {
s.stop = programs[i + 1].start
} else {
s.stop = s.start.startOf('d').add(1, 'd')
}
})
}
return programs.filter(
p =>
p.start.format('YYYY-MM-DD') === expectedDate ||
p.stop.format('YYYY-MM-DD') === expectedDate
)
},
async channels() {
const channels = []
const data = await axios
.get(this.url)
.then(r => r.data)
.catch(console.error)
if (data) {
// channel naming rule
const names = id => {
let match = id.match(/^\d+$/)
if (match) {
return `Arena Sport ${parseInt(id)}`
}
match = id.match(/^\d/)
if (match) {
return `Arena Sport ${id}`
}
match = id.match(/^a(\d+)(p)?/)
if (match) {
return `Arena ${parseInt(match[1])}${match[2] === 'p' ? ' Premium' : ''}`
}
return `Arena ${id}`
}
const $ = cheerio.load(data)
const items = $('.tv-scheme-chanel-header img').toArray()
for (const item of items) {
const [, id] = $(item)
.attr('src')
.match(/chanel-([a-z0-9]+)\.png/) || [null, null]
if (id) {
channels.push({
lang: this.lang,
site_id: id,
name: names(id)
})
}
}
}
return channels
}
}
function parseSchedules($s, date, tz) {
const schedules = []
const $ = $s._make
$s.find('.slider-content')
.toArray()
.forEach(el => {
schedules.push(parseSchedule($(el), date, tz))
})
return schedules
}
function parseSchedule($s, date, tz) {
const time = $s.find('.slider-content-top span').text()
const start = dayjs.tz(`${date.format('YYYY-MM-DD')} ${time}`, 'YYYY-MM-DD HH:mm', tz)
const category = $s.find('.slider-content-middle span').text()
const title = $s.find('.slider-content-bottom p').text()
const description = $s.find('.slider-content-bottom span:first').text()
return {
title: description ? description : title,
description: description ? title : description,
category,
start
}
}
const cheerio = require('cheerio')
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: 'tvarenasport.hr',
tz: 'Europe/Budapest',
lang: 'hr',
url: 'https://tvarenaprogram.com/live/v2/hr',
days: 2,
request: {
cache: {
ttl: 24 * 60 * 60 * 1000 // 1 day
}
},
parser({ content, channel, date }) {
const programs = []
const expectedDate = date.format('YYYY-MM-DD')
if (content) {
const dates = []
const $ = cheerio.load(content)
const parent = $(
`.tv-scheme-chanel-header img[src*="chanel-${channel.site_id}.png"]`
).parents('div')
parent
.siblings('.tv-scheme-days')
.find('a')
.toArray()
.forEach(el => {
const a = $(el)
const dt = a.find('span:nth-child(3)').text()
dates.push(dayjs(dt + date.year(), 'DD.MM.YYYY'))
})
parent
.siblings('.tv-scheme-new-slider-wrapper')
.find('.tv-scheme-new-slider-item')
.toArray()
.forEach((el, i) => {
programs.push(...parseSchedules($(el), dates[i], module.exports.tz))
})
programs.forEach((s, i) => {
if (i < programs.length - 2) {
s.stop = programs[i + 1].start
} else {
s.stop = s.start.startOf('d').add(1, 'd')
}
})
}
return programs.filter(
p =>
p.start.format('YYYY-MM-DD') === expectedDate ||
p.stop.format('YYYY-MM-DD') === expectedDate
)
},
async channels() {
const channels = []
const data = await axios
.get(this.url)
.then(r => r.data)
.catch(console.error)
if (data) {
// channel naming rule
const names = id => {
let match = id.match(/^\d+$/)
if (match) {
return `Arena Sport ${parseInt(id)}`
}
match = id.match(/^\d/)
if (match) {
return `Arena Sport ${id}`
}
match = id.match(/^a(\d+)(p)?/)
if (match) {
return `Arena ${parseInt(match[1])}${match[2] === 'p' ? ' Premium' : ''}`
}
return `Arena ${id}`
}
const $ = cheerio.load(data)
const items = $('.tv-scheme-chanel-header img').toArray()
for (const item of items) {
const [, id] = $(item)
.attr('src')
.match(/chanel-([a-z0-9]+)\.png/) || [null, null]
if (id) {
channels.push({
lang: this.lang,
site_id: id,
name: names(id)
})
}
}
}
return channels
}
}
function parseSchedules($s, date, tz) {
const schedules = []
const $ = $s._make
$s.find('.slider-content')
.toArray()
.forEach(el => {
schedules.push(parseSchedule($(el), date, tz))
})
return schedules
}
function parseSchedule($s, date, tz) {
const time = $s.find('.slider-content-top span').text()
const start = dayjs.tz(`${date.format('YYYY-MM-DD')} ${time}`, 'YYYY-MM-DD HH:mm', tz)
const category = $s.find('.slider-content-middle span').text()
const title = $s.find('.slider-content-bottom p').text()
const description = $s.find('.slider-content-bottom span:first').text()
return {
title: description ? description : title,
description: description ? title : description,
category,
start
}
}
+53 -53
View File
@@ -1,53 +1,53 @@
const { parser, url } = require('./tvarenasport.hr.config.js')
const fs = require('fs')
const path = require('path')
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('2024-12-07', 'YYYY-MM-DD').startOf('d')
const channel = {
site_id: '01',
xmltv_id: 'ArenaSport1.hr'
}
it('can generate valid url', () => {
expect(url).toBe('https://tvarenaprogram.com/live/v2/hr')
})
it('can parse response', () => {
const content = fs.readFileSync(path.join(__dirname, '__data__', 'content.html'))
const result = parser({ channel, date, content }).map(p => {
p.start = p.start.toJSON()
p.stop = p.stop.toJSON()
return p
})
expect(result.length).toBe(15)
expect(result[0]).toMatchObject({
start: '2024-12-07T00:00:00.000Z',
stop: '2024-12-07T00:30:00.000Z',
title: 'MAGAZIN',
description: 'NBA ACTION',
category: 'Košarka'
})
expect(result[4]).toMatchObject({
start: '2024-12-07T06:00:00.000Z',
stop: '2024-12-07T07:30:00.000Z',
title: 'EHF LIGA PRVAKA',
description: 'DINAMO BUKUREŠT - PSG',
category: 'Rukomet'
})
})
it('can handle empty guide', () => {
const result = parser({
date,
channel,
content: ''
})
expect(result).toMatchObject([])
})
const { parser, url } = require('./tvarenasport.hr.config.js')
const fs = require('fs')
const path = require('path')
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('2024-12-07', 'YYYY-MM-DD').startOf('d')
const channel = {
site_id: '01',
xmltv_id: 'ArenaSport1.hr'
}
it('can generate valid url', () => {
expect(url).toBe('https://tvarenaprogram.com/live/v2/hr')
})
it('can parse response', () => {
const content = fs.readFileSync(path.join(__dirname, '__data__', 'content.html'))
const result = parser({ channel, date, content }).map(p => {
p.start = p.start.toJSON()
p.stop = p.stop.toJSON()
return p
})
expect(result.length).toBe(15)
expect(result[0]).toMatchObject({
start: '2024-12-07T00:00:00.000Z',
stop: '2024-12-07T00:30:00.000Z',
title: 'MAGAZIN',
description: 'NBA ACTION',
category: 'Košarka'
})
expect(result[4]).toMatchObject({
start: '2024-12-07T06:00:00.000Z',
stop: '2024-12-07T07:30:00.000Z',
title: 'EHF LIGA PRVAKA',
description: 'DINAMO BUKUREŠT - PSG',
category: 'Rukomet'
})
})
it('can handle empty guide', () => {
const result = parser({
date,
channel,
content: ''
})
expect(result).toMatchObject([])
})