mirror of
https://github.com/iptv-org/epg.git
synced 2025-05-10 09:00:07 -04:00
Update tvarenasport.hr guide.
It is now derived from tvarenasport.com. Test: ```sh npm test -- tvarenasport.com > test > run-script-os tvarenasport.com > test:win32 > SET "TZ=Pacific/Nauru" && npx jest --runInBand tvarenasport.com PASS sites/tvarenasport.com/tvarenasport.com.test.js (5.391 s) √ can generate valid url (3 ms) √ can parse response (877 ms) √ can handle empty guide (1 ms) Test Suites: 1 passed, 1 total Tests: 3 passed, 3 total Snapshots: 0 total Time: 5.555 s, estimated 6 s Ran all test suites matching /tvarenasport.com/i. ``` ```sh npm test -- tvarenasport.hr > test > run-script-os tvarenasport.hr > test:win32 > SET "TZ=Pacific/Nauru" && npx jest --runInBand tvarenasport.hr PASS sites/tvarenasport.hr/tvarenasport.hr.test.js (5.578 s) √ can generate valid url (4 ms) √ can parse response (327 ms) √ can handle empty guide (1 ms) Test Suites: 1 passed, 1 total Tests: 3 passed, 3 total Snapshots: 0 total Time: 5.774 s Ran all test suites matching /tvarenasport.hr/i. ``` Grab: ```sh npm run grab -- --site=tvarenasport.hr > grab > npx tsx scripts/commands/epg/grab.ts --site=tvarenasport.hr starting... config: output: guide.xml maxConnections: 1 gzip: false site: tvarenasport.hr loading channels... found 10 channel(s) run #1: [1/20] tvarenasport.hr (hr) - ArenaSport1.hr - Dec 10, 2024 (17 programs) [2/20] tvarenasport.hr (hr) - ArenaSport1.hr - Dec 11, 2024 (17 programs) ... [19/20] tvarenasport.hr (hr) - ArenaSport2.hr - Dec 11, 2024 (12 programs) [20/20] tvarenasport.hr (hr) - ArenaSport2.hr - Dec 10, 2024 (12 programs) saving to "guide.xml"... done in 00h 00m 11s ``` Signed-off-by: Toha <tohenk@yahoo.com>
This commit is contained in:
parent
32c32206a0
commit
37505d391b
6 changed files with 5219 additions and 83 deletions
|
@ -9,10 +9,10 @@ dayjs.extend(utc)
|
||||||
dayjs.extend(timezone)
|
dayjs.extend(timezone)
|
||||||
dayjs.extend(customParseFormat)
|
dayjs.extend(customParseFormat)
|
||||||
|
|
||||||
const tz = 'Europe/Belgrade'
|
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
site: 'tvarenasport.com',
|
site: 'tvarenasport.com',
|
||||||
|
tz: 'Europe/Belgrade',
|
||||||
|
lang: 'sr',
|
||||||
days: 2,
|
days: 2,
|
||||||
request: {
|
request: {
|
||||||
cache: {
|
cache: {
|
||||||
|
@ -40,7 +40,7 @@ module.exports = {
|
||||||
.siblings('.tv-scheme-new-slider-wrapper')
|
.siblings('.tv-scheme-new-slider-wrapper')
|
||||||
.find('.tv-scheme-new-slider-item').toArray()
|
.find('.tv-scheme-new-slider-item').toArray()
|
||||||
.forEach((el, i) => {
|
.forEach((el, i) => {
|
||||||
programs.push(...parseSchedules($(el), dates[i]))
|
programs.push(...parseSchedules($(el), dates[i], module.exports.tz))
|
||||||
})
|
})
|
||||||
programs.forEach((s, i) => {
|
programs.forEach((s, i) => {
|
||||||
if (i < programs.length - 2) {
|
if (i < programs.length - 2) {
|
||||||
|
@ -57,7 +57,7 @@ module.exports = {
|
||||||
async channels() {
|
async channels() {
|
||||||
const channels = []
|
const channels = []
|
||||||
const data = await axios
|
const data = await axios
|
||||||
.get('https://www.tvarenasport.com/tv-scheme')
|
.get(this.url)
|
||||||
.then(r => r.data)
|
.then(r => r.data)
|
||||||
.catch(console.error)
|
.catch(console.error)
|
||||||
|
|
||||||
|
@ -84,7 +84,7 @@ module.exports = {
|
||||||
const [, id] = $(item).attr('src').match(/chanel-([a-z0-9]+)\.png/) || [null, null]
|
const [, id] = $(item).attr('src').match(/chanel-([a-z0-9]+)\.png/) || [null, null]
|
||||||
if (id) {
|
if (id) {
|
||||||
channels.push({
|
channels.push({
|
||||||
lang: 'sr',
|
lang: this.lang,
|
||||||
site_id: id,
|
site_id: id,
|
||||||
name: names(id)
|
name: names(id)
|
||||||
})
|
})
|
||||||
|
@ -96,18 +96,18 @@ module.exports = {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function parseSchedules($s, date) {
|
function parseSchedules($s, date, tz) {
|
||||||
const schedules = []
|
const schedules = []
|
||||||
const $ = $s._make
|
const $ = $s._make
|
||||||
$s.find('.slider-content').toArray()
|
$s.find('.slider-content').toArray()
|
||||||
.forEach(el => {
|
.forEach(el => {
|
||||||
schedules.push(parseSchedule($(el), date))
|
schedules.push(parseSchedule($(el), date, tz))
|
||||||
})
|
})
|
||||||
|
|
||||||
return schedules
|
return schedules
|
||||||
}
|
}
|
||||||
|
|
||||||
function parseSchedule($s, date) {
|
function parseSchedule($s, date, tz) {
|
||||||
const time = $s.find('.slider-content-top span').text()
|
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 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 category = $s.find('.slider-content-middle span').text()
|
||||||
|
|
|
@ -14,6 +14,10 @@ const channel = {
|
||||||
xmltv_id: 'ArenaSport1Premium.rs'
|
xmltv_id: 'ArenaSport1Premium.rs'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
it('can generate valid url', () => {
|
||||||
|
expect(url).toBe('https://www.tvarenasport.com/tv-scheme')
|
||||||
|
})
|
||||||
|
|
||||||
it('can parse response', () => {
|
it('can parse response', () => {
|
||||||
const content = fs.readFileSync(path.join(__dirname, '__data__', 'content.html'))
|
const content = fs.readFileSync(path.join(__dirname, '__data__', 'content.html'))
|
||||||
const result = parser({ channel, date, content }).map(p => {
|
const result = parser({ channel, date, content }).map(p => {
|
||||||
|
|
5166
sites/tvarenasport.hr/__data__/content.html
Normal file
5166
sites/tvarenasport.hr/__data__/content.html
Normal file
File diff suppressed because it is too large
Load diff
|
@ -1,13 +1,13 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<channels>
|
<channels>
|
||||||
<channel site="tvarenasport.hr" lang="hr" xmltv_id="ArenaSport10.hr" site_id="1294">Arena Sport 10 Hrvatska</channel>
|
<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="ArenaSport1.hr" site_id="380">Arena Sport 1 Hrvatska</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="ArenaSport2.hr" site_id="381">Arena Sport 2 Hrvatska</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="ArenaSport3.hr" site_id="382">Arena Sport 3 Hrvatska</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="ArenaSport4.hr" site_id="383">Arena Sport 4 Hrvatska</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="ArenaSport5.hr" site_id="384">Arena Sport 5 Hrvatska</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="ArenaSport6.hr" site_id="1175">Arena Sport 6 Hrvatska</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="ArenaSport7.hr" site_id="1291">Arena Sport 7 Hrvatska</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="ArenaSport8.hr" site_id="1292">Arena Sport 8 Hrvatska</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="ArenaSport9.hr" site_id="1293">Arena Sport 9 Hrvatska</channel>
|
<channel site="tvarenasport.hr" lang="hr" xmltv_id="ArenaSport10.hr" site_id="10">Arena Sport 10</channel>
|
||||||
</channels>
|
</channels>
|
||||||
|
|
|
@ -1,50 +1,8 @@
|
||||||
const axios = require('axios')
|
const tvarenasport = require('../tvarenasport.com/tvarenasport.com.config')
|
||||||
const dayjs = require('dayjs')
|
|
||||||
|
|
||||||
module.exports = {
|
module.exports = Object.assign(tvarenasport, {
|
||||||
site: 'tvarenasport.hr',
|
site: 'tvarenasport.hr',
|
||||||
days: 2,
|
tz: 'Europe/Budapest',
|
||||||
url: function ({ date }) {
|
lang: 'hr',
|
||||||
return `https://www.tvarenasport.hr/api/schedule?date=${date.format('DD-MM-YYYY')}`
|
url: 'https://tvarenaprogram.com/live/v2/hr',
|
||||||
},
|
})
|
||||||
parser: function ({ content, channel }) {
|
|
||||||
let programs = []
|
|
||||||
const items = parseItems(content, channel)
|
|
||||||
items.forEach(item => {
|
|
||||||
programs.push({
|
|
||||||
title: item.title.trim(),
|
|
||||||
category: item.sport,
|
|
||||||
description: item.league.trim(),
|
|
||||||
start: dayjs(item.start),
|
|
||||||
stop: dayjs(item.end)
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
||||||
return programs
|
|
||||||
},
|
|
||||||
async channels() {
|
|
||||||
const data = await axios
|
|
||||||
.get('https://www.tvarenasport.hr/api/schedule')
|
|
||||||
.then(r => r.data)
|
|
||||||
.catch(console.log)
|
|
||||||
|
|
||||||
const channels = []
|
|
||||||
for (let id in data.channels) {
|
|
||||||
const item = data.channels[id]
|
|
||||||
channels.push({
|
|
||||||
lang: 'hr',
|
|
||||||
site_id: id,
|
|
||||||
name: item.name
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
return channels
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function parseItems(content, channel) {
|
|
||||||
const data = JSON.parse(content)
|
|
||||||
if (!data || !Array.isArray(data.items)) return []
|
|
||||||
|
|
||||||
return data.items.filter(i => i.group === channel.site_id)
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,45 +1,53 @@
|
||||||
const { parser, url } = require('./tvarenasport.hr.config.js')
|
const { parser, url } = require('./tvarenasport.hr.config.js')
|
||||||
|
const fs = require('fs')
|
||||||
|
const path = require('path')
|
||||||
const dayjs = require('dayjs')
|
const dayjs = require('dayjs')
|
||||||
const utc = require('dayjs/plugin/utc')
|
const utc = require('dayjs/plugin/utc')
|
||||||
const customParseFormat = require('dayjs/plugin/customParseFormat')
|
const customParseFormat = require('dayjs/plugin/customParseFormat')
|
||||||
|
|
||||||
dayjs.extend(customParseFormat)
|
dayjs.extend(customParseFormat)
|
||||||
dayjs.extend(utc)
|
dayjs.extend(utc)
|
||||||
|
|
||||||
const date = dayjs.utc('2021-11-17', 'YYYY-MM-DD').startOf('d')
|
const date = dayjs.utc('2024-12-07', 'YYYY-MM-DD').startOf('d')
|
||||||
const channel = {
|
const channel = {
|
||||||
site_id: '380',
|
site_id: '01',
|
||||||
xmltv_id: 'ArenaSport1Croatia.hr'
|
xmltv_id: 'ArenaSport1.hr'
|
||||||
}
|
}
|
||||||
|
|
||||||
it('can generate valid url', () => {
|
it('can generate valid url', () => {
|
||||||
expect(url({ channel, date })).toBe('https://www.tvarenasport.hr/api/schedule?date=17-11-2021')
|
expect(url).toBe('https://tvarenaprogram.com/live/v2/hr')
|
||||||
})
|
})
|
||||||
|
|
||||||
it('can parse response', () => {
|
it('can parse response', () => {
|
||||||
const content =
|
const content = fs.readFileSync(path.join(__dirname, '__data__', 'content.html'))
|
||||||
'{"items":[{"id":6104,"title":"NAJAVA PROGRAMA","start":"2021-11-16T23:00:00Z","end":"2021-11-17T23:00:00Z","sport":"Najava programa","league":"NAJAVA PROGRAMA","group":"1294","isLive":false,"doNotMiss":false,"domain":"cro"},{"id":6000,"title":" DIJON - UNICAJA","start":"2021-11-16T23:30:00Z","end":"2021-11-17T01:00:00Z","sport":"Košarka","league":" LIGA PRVAKA","group":"380","isLive":false,"doNotMiss":false,"domain":"cro"}]}'
|
const result = parser({ channel, date, content }).map(p => {
|
||||||
const result = parser({ channel, content }).map(p => {
|
|
||||||
p.start = p.start.toJSON()
|
p.start = p.start.toJSON()
|
||||||
p.stop = p.stop.toJSON()
|
p.stop = p.stop.toJSON()
|
||||||
return p
|
return p
|
||||||
})
|
})
|
||||||
|
|
||||||
expect(result).toMatchObject([
|
expect(result.length).toBe(15)
|
||||||
{
|
expect(result[0]).toMatchObject({
|
||||||
start: '2021-11-16T23:30:00.000Z',
|
start: '2024-12-07T00:00:00.000Z',
|
||||||
stop: '2021-11-17T01:00:00.000Z',
|
stop: '2024-12-07T00:30:00.000Z',
|
||||||
title: 'DIJON - UNICAJA',
|
title: 'MAGAZIN',
|
||||||
category: 'Košarka',
|
description: 'NBA ACTION',
|
||||||
description: 'LIGA PRVAKA'
|
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', () => {
|
it('can handle empty guide', () => {
|
||||||
const result = parser({
|
const result = parser({
|
||||||
date,
|
date,
|
||||||
channel,
|
channel,
|
||||||
content: '{"channels":[]}'
|
content: ''
|
||||||
})
|
})
|
||||||
expect(result).toMatchObject([])
|
expect(result).toMatchObject([])
|
||||||
})
|
})
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue