mirror of
https://github.com/iptv-org/epg.git
synced 2025-05-10 09:00:07 -04:00
Merge pull request #597 from iptv-org/add-mediaklikk.hu
Add guide from mediaklikk.hu
This commit is contained in:
commit
1cd5bbcc95
4 changed files with 177 additions and 0 deletions
17
.github/workflows/mediaklikk.hu.yml
vendored
Normal file
17
.github/workflows/mediaklikk.hu.yml
vendored
Normal file
|
@ -0,0 +1,17 @@
|
|||
name: mediaklikk.hu
|
||||
on:
|
||||
schedule:
|
||||
- cron: '0 0 * * *'
|
||||
workflow_dispatch:
|
||||
workflow_run:
|
||||
workflows: [_trigger]
|
||||
types:
|
||||
- completed
|
||||
jobs:
|
||||
load:
|
||||
uses: ./.github/workflows/_load.yml
|
||||
with:
|
||||
site: ${{github.workflow}}
|
||||
secrets:
|
||||
APP_ID: ${{ secrets.APP_ID }}
|
||||
APP_PRIVATE_KEY: ${{ secrets.APP_PRIVATE_KEY }}
|
81
sites/mediaklikk.hu/mediaklikk.hu.config.js
Normal file
81
sites/mediaklikk.hu/mediaklikk.hu.config.js
Normal file
|
@ -0,0 +1,81 @@
|
|||
const cheerio = require('cheerio')
|
||||
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: 'mediaklikk.hu',
|
||||
url: 'https://mediaklikk.hu/wp-content/plugins/hms-global-widgets/widgets/programGuide/programGuideInterface.php',
|
||||
request: {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/x-www-form-urlencoded'
|
||||
},
|
||||
data: function ({ date, channel }) {
|
||||
const params = new URLSearchParams()
|
||||
params.append('ChannelIds', `${channel.site_id},`)
|
||||
params.append('Date', date.format('YYYY-MM-DD'))
|
||||
|
||||
return params
|
||||
}
|
||||
},
|
||||
parser: function ({ content }) {
|
||||
const programs = []
|
||||
const items = parseItems(content)
|
||||
items.forEach(item => {
|
||||
const $item = cheerio.load(item)
|
||||
const start = parseStart($item)
|
||||
let stop = parseStop($item)
|
||||
if (!stop) stop = start.add(30, 'm')
|
||||
programs.push({
|
||||
title: parseTitle($item),
|
||||
description: parseDescription($item),
|
||||
icon: parseIcon($item),
|
||||
start,
|
||||
stop
|
||||
})
|
||||
})
|
||||
|
||||
return programs
|
||||
}
|
||||
}
|
||||
|
||||
function parseStart($item) {
|
||||
const timeString = $item('*').data('from')
|
||||
|
||||
return dayjs.tz(timeString, 'YYYY-MM-DD HH:mm:ss', 'Europe/Budapest')
|
||||
}
|
||||
|
||||
function parseStop($item) {
|
||||
const timeString = $item('*').data('till')
|
||||
if (!timeString) return null
|
||||
|
||||
return dayjs.tz(timeString, 'YYYY-MM-DD HH:mm:ss', 'Europe/Budapest')
|
||||
}
|
||||
|
||||
function parseTitle($item) {
|
||||
return $item('.program_info > h1').text().trim()
|
||||
}
|
||||
|
||||
function parseDescription($item) {
|
||||
return $item('.program_about > .program_description > p').text().trim()
|
||||
}
|
||||
|
||||
function parseIcon($item) {
|
||||
const backgroundImage = $item('.program_about > .program_photo').css('background-image')
|
||||
if (!backgroundImage) return null
|
||||
const [_, icon] = backgroundImage.match(/url\(\'(.*)'\)/) || [null, null]
|
||||
|
||||
return icon
|
||||
}
|
||||
|
||||
function parseItems(content) {
|
||||
const $ = cheerio.load(content)
|
||||
|
||||
return $('li.program_body').toArray()
|
||||
}
|
66
sites/mediaklikk.hu/mediaklikk.hu.test.js
Normal file
66
sites/mediaklikk.hu/mediaklikk.hu.test.js
Normal file
|
@ -0,0 +1,66 @@
|
|||
// npx epg-grabber --config=sites/mediaklikk.hu/mediaklikk.hu.config.js --channels=sites/mediaklikk.hu/mediaklikk.hu_hu.channels.xml --output=guide.xml --days=2
|
||||
|
||||
const { parser, url, request } = require('./mediaklikk.hu.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('2022-03-10', 'YYYY-MM-DD').startOf('d')
|
||||
const channel = {
|
||||
site_id: '3',
|
||||
xmltv_id: 'DuneTV.hu'
|
||||
}
|
||||
|
||||
it('can generate valid url', () => {
|
||||
expect(url).toBe(
|
||||
'https://mediaklikk.hu/wp-content/plugins/hms-global-widgets/widgets/programGuide/programGuideInterface.php'
|
||||
)
|
||||
})
|
||||
|
||||
it('can generate valid request method', () => {
|
||||
expect(request.method).toBe('POST')
|
||||
})
|
||||
|
||||
it('can generate valid request headers', () => {
|
||||
expect(request.headers).toMatchObject({
|
||||
'Content-Type': 'application/x-www-form-urlencoded'
|
||||
})
|
||||
})
|
||||
|
||||
it('can generate valid request data', () => {
|
||||
const result = request.data({ date, channel })
|
||||
expect(result.get('ChannelIds')).toBe('3,')
|
||||
expect(result.get('Date')).toBe('2022-03-10')
|
||||
})
|
||||
|
||||
it('can parse response', () => {
|
||||
const content = `<div class="mediaklikkOwlWrapper channels_num_1"> <div class="mediaklikkOwlItem" data-channelid="3" data-channelshortcode="" data-buttontype="" data-channelname="" data-date="2022-03-10" data-videoPageUrl="" > <div class="tvguide channel mainsite"> <div data-thisdate="2022-03-10" class="channel_body" data-type="0"> <ul> <li class="program_body " style="" data-from="2022-03-10 00:35:35" data-till="2022-03-10 01:35:54" data-bci="1" data-vpi=" "data-vpslug="" > <div class="time"> <time >00:35</time> <div class="elo " style="display: none"><span class="live_play"></span>Élő</div><button style="display: none" ></button> </div><div class="program_info"> <h1> A tengeralattjáró (2018) </h1> <span class="status disabled "></span><span class="agelimitico tizennyolc" ></span> <p>4. rész, 57 perc, 2018</p></div><div class="program_about" style="display: none;"> <div class="program_photo" style="background-image:url('https://mediaklikk.hu/wp-content/uploads/sites/4/2020/06/00-150x150.jpg')"></div><div class="program_description"> <p> A La Rochelle-ben történt robbanás után a polgármester parancsot kap néhány súlyos intézkedés meghozatalára. Az ellenséges támadás után az U-612 fedélzetén a bajtársiasság terén gondok mutatkoznak. Hoffmann és Tennstedt rivalizálása és a legénység közt tapasztalható feszültség veszélybe sodorja küldetésüket.<br/>(Eredeti hang digitálisan.) </p></div><div class="notifications" style="" > <div class="notice" style="display: none;"> <span></span> <p>Értesítést kérek</p></div><div class="program_site" onclick="location.href='https://mediaklikk.hu/musor/a-tengeralattjaro'"> <span></span> <p>Műsoroldal</p></div></div><button style="display: none" ></button> </div></li></ul> </div></div></div></div>`
|
||||
|
||||
const result = parser({ content }).map(p => {
|
||||
p.start = p.start.toJSON()
|
||||
p.stop = p.stop.toJSON()
|
||||
return p
|
||||
})
|
||||
|
||||
expect(result).toMatchObject([
|
||||
{
|
||||
start: '2022-03-09T23:35:35.000Z',
|
||||
stop: '2022-03-10T00:35:54.000Z',
|
||||
title: `A tengeralattjáró (2018)`,
|
||||
description:
|
||||
'A La Rochelle-ben történt robbanás után a polgármester parancsot kap néhány súlyos intézkedés meghozatalára. Az ellenséges támadás után az U-612 fedélzetén a bajtársiasság terén gondok mutatkoznak. Hoffmann és Tennstedt rivalizálása és a legénység közt tapasztalható feszültség veszélybe sodorja küldetésüket.(Eredeti hang digitálisan.)',
|
||||
icon: 'https://mediaklikk.hu/wp-content/uploads/sites/4/2020/06/00-150x150.jpg'
|
||||
}
|
||||
])
|
||||
})
|
||||
|
||||
it('can handle empty guide', () => {
|
||||
const result = parser({
|
||||
date,
|
||||
channel,
|
||||
content: `<!DOCTYPE html><html><head></head><body></body></html>`
|
||||
})
|
||||
expect(result).toMatchObject([])
|
||||
})
|
13
sites/mediaklikk.hu/mediaklikk.hu_hu.channels.xml
Normal file
13
sites/mediaklikk.hu/mediaklikk.hu_hu.channels.xml
Normal file
|
@ -0,0 +1,13 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<site site="mediaklikk.hu">
|
||||
<channels>
|
||||
<channel lang="hu" xmltv_id="DunaTV.hu" site_id="3">Duna</channel>
|
||||
<channel lang="hu" xmltv_id="DunaWorld.hu" site_id="4">Duna World</channel>
|
||||
<channel lang="hu" xmltv_id="M1.hu" site_id="1">M1</channel>
|
||||
<channel lang="hu" xmltv_id="M2.hu" site_id="2">M2</channel>
|
||||
<channel lang="hu" xmltv_id="M3.hu" site_id="26">M3</channel>
|
||||
<channel lang="hu" xmltv_id="M4Sport.hu" site_id="30">M4 Sport</channel>
|
||||
<channel lang="hu" xmltv_id="M4SportPlus.hu" site_id="34">M4 Sport +</channel>
|
||||
<channel lang="hu" xmltv_id="M5.hu" site_id="33">M5</channel>
|
||||
</channels>
|
||||
</site>
|
Loading…
Add table
Add a link
Reference in a new issue