Merge pull request #1222 from iptv-org/fix-mediaklikk.hu

Fix mediaklikk.hu
This commit is contained in:
Aleksandr Statciuk 2022-10-28 06:57:03 +03:00 committed by GitHub
commit e07badcfca
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 1521 additions and 18 deletions

File diff suppressed because it is too large Load diff

View file

@ -1,11 +1,9 @@
const cheerio = require('cheerio') const cheerio = require('cheerio')
const dayjs = require('dayjs') const dayjs = require('dayjs')
const utc = require('dayjs/plugin/utc') const utc = require('dayjs/plugin/utc')
const timezone = require('dayjs/plugin/timezone')
const customParseFormat = require('dayjs/plugin/customParseFormat') const customParseFormat = require('dayjs/plugin/customParseFormat')
dayjs.extend(utc) dayjs.extend(utc)
dayjs.extend(timezone)
dayjs.extend(customParseFormat) dayjs.extend(customParseFormat)
module.exports = { module.exports = {
@ -48,14 +46,18 @@ module.exports = {
function parseStart($item) { function parseStart($item) {
const timeString = $item('*').data('from') const timeString = $item('*').data('from')
return dayjs.tz(timeString, 'YYYY-MM-DD HH:mm:ss', 'Europe/Budapest') return dayjs(timeString, 'YYYY-MM-DD HH:mm:ssZZ')
} }
function parseStop($item) { function parseStop($item) {
const timeString = $item('*').data('till') const timeString = $item('*').data('till')
if (!timeString) return null if (!timeString) return null
return dayjs.tz(timeString, 'YYYY-MM-DD HH:mm:ss', 'Europe/Budapest') try {
return dayjs(timeString, 'YYYY-MM-DD HH:mm:ssZZ')
} catch (err) {
return null
}
} }
function parseTitle($item) { function parseTitle($item) {
@ -70,8 +72,9 @@ function parseIcon($item) {
const backgroundImage = $item('.program_about > .program_photo').css('background-image') const backgroundImage = $item('.program_about > .program_photo').css('background-image')
if (!backgroundImage) return null if (!backgroundImage) return null
const [_, icon] = backgroundImage.match(/url\(\'(.*)'\)/) || [null, null] const [_, icon] = backgroundImage.match(/url\(\'(.*)'\)/) || [null, null]
if (!icon) return null
return icon return `https:${icon}`
} }
function parseItems(content) { function parseItems(content) {

View file

@ -1,6 +1,8 @@
// 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 // 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 { parser, url, request } = require('./mediaklikk.hu.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')
@ -36,24 +38,21 @@ it('can generate valid request data', () => {
}) })
it('can parse response', () => { 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 content = fs.readFileSync(path.resolve(__dirname, '__data__/content.html'))
const results = parser({ content }).map(p => {
const result = parser({ 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(results[0]).toMatchObject({
{ start: '2022-10-27T22:00:46.000Z',
start: '2022-03-09T23:35:35.000Z', stop: '2022-10-27T22:54:00.000Z',
stop: '2022-03-10T00:35:54.000Z', title: `A hegyi doktor - I. évad`,
title: `A tengeralattjáró (2018)`, description:
description: 'Maxl iskolatársának, Vroninak az anyja egy autóbalesetben meghal. A 20 éves testvér, Vinzenz magához szeretné venni a lányt, ám a gyámüggyel problémái akadnak, ezért megpróbálja elszöktetni.(Eredeti hang digitálisan.)',
'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/2019/10/A-hegyi-doktor-I-évad-e1571318391226-150x150.jpg'
icon: 'https://mediaklikk.hu/wp-content/uploads/sites/4/2020/06/00-150x150.jpg' })
}
])
}) })
it('can handle empty guide', () => { it('can handle empty guide', () => {