Initial Commit

This commit is contained in:
2023-09-10 21:48:48 +02:00
commit 227cca7d31
791 changed files with 165200 additions and 0 deletions

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,95 @@
<?xml version="1.0" encoding="UTF-8"?>
<site site="tvmusor.hu">
<channels>
<channel lang="en" xmltv_id="BBCWorldNewsEurope.uk" site_id="126">BBC World News</channel>
<channel lang="en" xmltv_id="CNNInternationalEurope.us" site_id="4">CNN</channel>
<channel lang="en" xmltv_id="EuronewsEnglish.fr" site_id="71">EuroNews</channel>
<channel lang="en" xmltv_id="SkyNewsInternational.uk" site_id="158">Sky News International</channel>
<channel lang="hu" xmltv_id="AMCHungary.hu" site_id="139">AMC</channel>
<channel lang="hu" xmltv_id="AnimalPlanetHungary.hu" site_id="231">Animal Planet</channel>
<channel lang="hu" xmltv_id="ATV.hu" site_id="15">ATV</channel>
<channel lang="hu" xmltv_id="AXNHungary.hu" site_id="42">AXN</channel>
<channel lang="hu" xmltv_id="BBCEarthRomania.ro" site_id="251">BBC Earth</channel>
<channel lang="hu" xmltv_id="BoomerangCEE.us" site_id="77">Boomerang</channel>
<channel lang="hu" xmltv_id="CartoonNetworkHungary.hu" site_id="91">Cartoon Network</channel>
<channel lang="hu" xmltv_id="CinemaxHungary.hu" site_id="47">Cinemax</channel>
<channel lang="hu" xmltv_id="ComedyCentralFamilyHungary.hu" site_id="316">Comedy Central Family</channel>
<channel lang="hu" xmltv_id="ComedyCentralHungary.hu" site_id="194">Comedy Central</channel>
<channel lang="hu" xmltv_id="CoolTV.hu" site_id="79">Cool</channel>
<channel lang="hu" xmltv_id="DaVinciHungary.hu" site_id="202">Da Vinci</channel>
<channel lang="hu" xmltv_id="DigiAnimalWorldRomania.ro" site_id="249">Digi Animal World</channel>
<channel lang="hu" xmltv_id="DigiLifeHungary.hu" site_id="247">Digi Life</channel>
<channel lang="hu" xmltv_id="DigiSport1Hungary.hu" site_id="211">Digi Sport 1</channel>
<channel lang="hu" xmltv_id="DigiSport2Hungary.hu" site_id="230">Digi Sport 2</channel>
<channel lang="hu" xmltv_id="DigiWorldHungary.hu" site_id="248">Digi World</channel>
<channel lang="hu" xmltv_id="DiscoveryChannelHungary.hu" site_id="83">Discovery Channel</channel>
<channel lang="hu" xmltv_id="DiscoveryScience.us" site_id="85">Discovery Science</channel>
<channel lang="hu" xmltv_id="DisneyChannelHungary.hu" site_id="35">Disney Channel</channel>
<channel lang="hu" xmltv_id="DuckTV.sk" site_id="156">Duck TV</channel>
<channel lang="hu" xmltv_id="DunaTV.hu" site_id="6">Duna TV</channel>
<channel lang="hu" xmltv_id="DunaWorld.hu" site_id="103">Duna World</channel>
<channel lang="hu" xmltv_id="Eurosport1.fr" site_id="94">Eurosport 1</channel>
<channel lang="hu" xmltv_id="Eurosport2.fr" site_id="37">Eurosport 2</channel>
<channel lang="hu" xmltv_id="FEM3.hu" site_id="307">FEM3</channel>
<channel lang="hu" xmltv_id="FilmCafeHungary.hu" site_id="89">Film Café</channel>
<channel lang="hu" xmltv_id="FilmMania.hu" site_id="95">Film Mánia</channel>
<channel lang="hu" xmltv_id="FilmNowHungary.hu" site_id="245">Film Now</channel>
<channel lang="hu" xmltv_id="FilmPlusHungary.hu" site_id="32">Film+</channel>
<channel lang="hu" xmltv_id="FoodNetworkEMEA.us" site_id="285">Food Network</channel>
<channel lang="hu" xmltv_id="Hatoscsatorna.hu" site_id="246">Hatoscsatorna</channel>
<channel lang="hu" xmltv_id="HBO2Hungary.hu" site_id="59">HBO 2</channel>
<channel lang="hu" xmltv_id="HBO3Hungary.hu" site_id="143">HBO 3</channel>
<channel lang="hu" xmltv_id="HBOHungary.hu" site_id="8">HBO</channel>
<channel lang="hu" xmltv_id="HirTV.hu" site_id="10">Hír TV</channel>
<channel lang="hu" xmltv_id="HtMusicChannelHungary.hu" site_id="253">H!t Music Channel</channel>
<channel lang="hu" xmltv_id="IzauraTV.hu" site_id="304">Izaura TV</channel>
<channel lang="hu" xmltv_id="JimJamHungary.hu" site_id="197">JimJam</channel>
<channel lang="hu" xmltv_id="LifeTV.hu" site_id="212">Life TV</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="M4Sport.hu" site_id="290">M4 Sport</channel>
<channel lang="hu" xmltv_id="M5.hu" site_id="301">M5</channel>
<channel lang="hu" xmltv_id="MinimaxHungary.hu" site_id="16">Minimax</channel>
<channel lang="hu" xmltv_id="MoziPlus.hu" site_id="229">Mozi+</channel>
<channel lang="hu" xmltv_id="MTVGlobal.uk" site_id="144">MTV Global</channel>
<channel lang="hu" xmltv_id="MusicChannelHungary.hu" site_id="235">Music Channel Hungary</channel>
<channel lang="hu" xmltv_id="MuzsikaTV.hu" site_id="217">Muzsika TV</channel>
<channel lang="hu" xmltv_id="NationalGeographicHungary.hu" site_id="14">National Geographic</channel>
<channel lang="hu" xmltv_id="NationalGeographicWildHungary.hu" site_id="141">National Geographic Wild</channel>
<channel lang="hu" xmltv_id="NickelodeonHungary.hu" site_id="41">Nickelodeon</channel>
<channel lang="hu" xmltv_id="NickJrHungary.hu" site_id="236">Nick Jr</channel>
<channel lang="hu" xmltv_id="OzoneTV.hu" site_id="213">Ozone TV</channel>
<channel lang="hu" xmltv_id="ParamountNetworkHungary.hu" site_id="257">Paramount Network</channel>
<channel lang="hu" xmltv_id="Prime.hu" site_id="215">Prime</channel>
<channel lang="hu" xmltv_id="RTLGold.hu" site_id="180">RTL Gold</channel>
<channel lang="hu" xmltv_id="RTLKETTO.hu" site_id="241">RTL KETTŐ</channel>
<channel lang="hu" xmltv_id="RTLHAROM.hu" site_id="178">RTL HÁROM</channel>
<channel lang="hu" xmltv_id="RTLHungary.hu" site_id="5">RTL</channel>
<channel lang="hu" xmltv_id="SlagerTV.hu" site_id="216">Sláger TV</channel>
<channel lang="hu" xmltv_id="SorozatPlus.hu" site_id="179">Sorozat+</channel>
<channel lang="hu" xmltv_id="SpektrumHungary.hu" site_id="9">Spektrum</channel>
<channel lang="hu" xmltv_id="Spiler1TV.hu" site_id="305">Spíler1 TV</channel>
<channel lang="hu" xmltv_id="Sport1Hungary.hu" site_id="90">Sport1</channel>
<channel lang="hu" xmltv_id="Sport2Hungary.hu" site_id="44">Sport2</channel>
<channel lang="hu" xmltv_id="Story4.hu" site_id="228">Story5</channel>
<channel lang="hu" xmltv_id="SuperTV2.hu" site_id="244">Super TV2</channel>
<channel lang="hu" xmltv_id="TeenNickHungary.hu" site_id="312">TeenNick</channel>
<channel lang="hu" xmltv_id="TheFishingHuntingChannel.hu" site_id="176">The Fishing &amp; Hunting Channel</channel>
<channel lang="hu" xmltv_id="TLCPanregional.us" site_id="233">TLC Pan Regional</channel>
<channel lang="hu" xmltv_id="TravelChannelEMEA.uk" site_id="84">Travel Channel</channel>
<channel lang="hu" xmltv_id="TV2.hu" site_id="3">TV2</channel>
<channel lang="hu" xmltv_id="TV2Kids.hu" site_id="310">TV2 Kids</channel>
<channel lang="hu" xmltv_id="TV2Sef.hu" site_id="309">TV2 Séf</channel>
<channel lang="hu" xmltv_id="TV4.hu" site_id="38">Story4</channel>
<channel lang="hu" xmltv_id="TVPaprikaHungary.hu" site_id="46">TV Paprika</channel>
<channel lang="hu" xmltv_id="VH1Europe.uk" site_id="99">VH1</channel>
<channel lang="hu" xmltv_id="Viasat2.hu" site_id="132">Viasat2</channel>
<channel lang="hu" xmltv_id="Viasat3.hu" site_id="21">Viasat3</channel>
<channel lang="hu" xmltv_id="Viasat6.hu" site_id="164">Viasat6</channel>
<channel lang="hu" xmltv_id="ViasatExplore.se" site_id="65">Viasat Explore</channel>
<channel lang="hu" xmltv_id="ViasatFilm.hu" site_id="138">Viasat Film</channel>
<channel lang="hu" xmltv_id="ViasatHistory.se" site_id="66">Viasat History</channel>
<channel lang="hu" xmltv_id="ViasatNature.se" site_id="223">Viasat Nature</channel>
<!-- <channel lang="hu" xmltv_id="" site_id="226">FilmBox</channel> -->
</channels>
</site>

View File

@@ -0,0 +1,81 @@
const axios = require('axios')
const dayjs = require('dayjs')
const _ = require('lodash')
module.exports = {
site: 'tvmusor.hu',
days: 2,
url: 'http://www.tvmusor.hu/a/get-events/',
request: {
method: 'POST',
headers: {
'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
},
data({ channel, date }) {
const params = new URLSearchParams()
params.append(
'data',
JSON.stringify({
blocks: [`${channel.site_id}|${date.format('YYYY-MM-DD')}`]
})
)
return params
}
},
parser({ content, channel, date }) {
let programs = []
const items = parseItems(content, channel, date)
items.forEach(item => {
const prev = programs[programs.length - 1]
let start = dayjs(item.e)
let stop = dayjs(item.f)
if (prev) {
start = prev.stop
}
programs.push({
title: item.j,
category: item.h,
description: item.c,
icon: parseIcon(item),
start,
stop
})
})
return programs
},
async channels() {
const data = await axios
.get(`http://www.tvmusor.hu/most/`)
.then(r => r.data)
.catch(console.log)
const [_, channelData] = data.match(/const CHANNEL_DATA = (.*);/)
const json = channelData.replace('},}', '}}').replace(/(\d+):/g, '"$1":')
const channels = JSON.parse(json)
return Object.values(channels).map(item => {
return {
lang: 'hu',
site_id: item.id,
name: item.name
}
})
}
}
function parseIcon(item) {
return item.z ? `http://www.tvmusor.hu/images/events/408/${item.z}` : null
}
function parseItems(content, channel, date) {
const data = JSON.parse(content)
if (!data || !data.data || !data.data.loadedBlocks) return []
const blocks = data.data.loadedBlocks
const blockId = `${channel.site_id}_${date.format('YYYY-MM-DD')}`
if (!Array.isArray(blocks[blockId])) return []
return _.uniqBy(_.uniqBy(blocks[blockId], 'e'), 'b')
}

View File

@@ -0,0 +1,71 @@
// npm run channels:parse -- --config=./sites/tvmusor.hu/tvmusor.hu.config.js --output=./sites/tvmusor.hu/tvmusor.hu.channels.xml
// npx epg-grabber --config=sites/tvmusor.hu/tvmusor.hu.config.js --channels=sites/tvmusor.hu/tvmusor.hu.channels.xml --output=guide.xml --days=2
const { parser, url, request } = require('./tvmusor.hu.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('2022-11-19', 'YYYY-MM-DD').startOf('d')
const channel = {
site_id: '290',
xmltv_id: 'M4Sport.hu'
}
it('can generate valid url', () => {
expect(url).toBe('http://www.tvmusor.hu/a/get-events/')
})
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; charset=UTF-8'
})
})
it('can generate valid request data', () => {
const result = request.data({ channel, date })
expect(result.get('data')).toBe('{"blocks":["290|2022-11-19"]}')
})
it('can parse response', () => {
const content = fs.readFileSync(path.resolve(__dirname, '__data__/content.json'))
let results = parser({ content, channel, date })
results = results.map(p => {
p.start = p.start.toJSON()
p.stop = p.stop.toJSON()
return p
})
expect(results[0]).toMatchObject({
start: '2022-11-18T23:30:00.000Z',
stop: '2022-11-19T00:55:00.000Z',
title: `Rövidpályás Úszó Országos Bajnokság`,
category: 'sportműsor',
description: 'Forma-1 magazin. Hírek, információk, érdekességek a Forma-1 világából.',
icon: 'http://www.tvmusor.hu/images/events/408/f1e45193930943d9ee29769e0afa902aff0e4a90-better-call-saul.jpg'
})
expect(results[1]).toMatchObject({
start: '2022-11-19T00:55:00.000Z',
stop: '2022-11-19T01:10:00.000Z',
title: `Sportlövészet`,
category: 'sportműsor'
})
})
it('can handle empty guide', () => {
const result = parser({
date,
channel,
content: `{"status":"error","reason":"invalid blocks"}`
})
expect(result).toMatchObject([])
})