Merge pull request #284 from iptv-org/add-tvmusor-hu

Add guide from tvmusor.hu
This commit is contained in:
Aleksandr Statciuk 2021-11-24 05:05:35 +03:00 committed by GitHub
commit cf1bd944d3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 231 additions and 0 deletions

View file

@ -0,0 +1,72 @@
const FormData = require('form-data')
const axios = require('axios')
const dayjs = require('dayjs')
module.exports = {
site: 'tvmusor.hu',
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 => {
programs.push({
title: item.j,
category: item.h,
description: item.c,
icon: parseIcon(item),
start: dayjs(item.e),
stop: dayjs(item.f)
})
})
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')}`
return Array.isArray(blocks[blockId]) ? blocks[blockId] : []
}

View file

@ -0,0 +1,63 @@
// node ./scripts/channels.js --config=./sites/tvmusor.hu/tvmusor.hu.config.js --output=./sites/tvmusor.hu/tvmusor.hu_hu.channels.xml
// npx epg-grabber --config=sites/tvmusor.hu/tvmusor.hu.config.js --channels=sites/tvmusor.hu/tvmusor.hu_hu.channels.xml --output=.gh-pages/guides/hu/tvmusor.hu.epg.xml --days=2
const { parser, url, request } = require('./tvmusor.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('2021-11-24', 'YYYY-MM-DD').startOf('d')
const channel = {
site_id: '139',
xmltv_id: 'AMCMagyarorszag.us'
}
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":["139|2021-11-24"]}')
})
it('can parse response', () => {
const content = `{"status":"success","data":{"time":0.00033187866210938,"loadedBlocks":{"139_2021-11-24":[{"a":903037163,"b":167085,"c":"Milyen volt a vil\\u00e1g, amikor elkezdett \\u00e1talakulni azz\\u00e1 a horrorisztikus apokalipsziss\\u00e9, amelyet a The Walking Dead festett le? A Los Angeles-ben j\\u00e1tsz\\u00f3d\\u00f3 t\\u00e1rs-sorozat pontosan erre a k\\u00e9rd\\u00e9sre v\\u00e1laszol.","d":65,"e":1637712900000,"f":1637716800000,"g":2021,"h":"filmsorozat","i":"1:15","j":"Fear the Walking Dead","l":"18","n":"fear-the-walking-dead","z":"d6310651d2be559cc4e49498a21edd7477c19244_6345563D34F3542B1649E80.jpg"}]}}}`
const result = parser({ content, channel, date }).map(p => {
p.start = p.start.toJSON()
p.stop = p.stop.toJSON()
return p
})
expect(result).toMatchObject([
{
start: '2021-11-24T00:15:00.000Z',
stop: '2021-11-24T01:20:00.000Z',
title: `Fear the Walking Dead`,
category: 'filmsorozat',
description: `Milyen volt a világ, amikor elkezdett átalakulni azzá a horrorisztikus apokalipszissé, amelyet a The Walking Dead festett le? A Los Angeles-ben játszódó társ-sorozat pontosan erre a kérdésre válaszol.`,
icon: 'http://www.tvmusor.hu/images/events/408/d6310651d2be559cc4e49498a21edd7477c19244_6345563D34F3542B1649E80.jpg'
}
])
})
it('can handle empty guide', () => {
const result = parser({
date,
channel,
content: `{"status":"error","reason":"invalid blocks"}`
})
expect(result).toMatchObject([])
})

View file

@ -0,0 +1,96 @@
<?xml version="1.0" encoding="UTF-8"?>
<site site="tvmusor.hu">
<channels>
<channel lang="hu" xmltv_id="AMCMagyarorszag.us" site_id="139">AMC Magyarország</channel>
<channel lang="hu" xmltv_id="AnimalPlanetEurope.us" site_id="231">Animal Planet Europe</channel>
<channel lang="hu" xmltv_id="ATV.hu" site_id="15">ATV</channel>
<channel lang="hu" xmltv_id="AXNCentralEurope.us" site_id="42">AXN Central Europe</channel>
<channel lang="hu" xmltv_id="BBCEarthRomania.uk" site_id="251">BBC Earth Romania</channel>
<channel lang="hu" xmltv_id="BBCWorldNewsEurope.uk" site_id="126">BBC World News Europe</channel>
<channel lang="hu" xmltv_id="BoomerangCentralEasternEurope.us" site_id="77">Boomerang Central &amp; Eastern Europe</channel>
<channel lang="hu" xmltv_id="CartoonNetworkCentralEasternEurope.us" site_id="91">Cartoon Network Central &amp; Eastern Europe</channel>
<channel lang="hu" xmltv_id="CinemaxCentralEurope.us" site_id="47">Cinemax Central Europe</channel>
<channel lang="hu" xmltv_id="CNNInternationalEurope.us" site_id="4">CNN International Europe</channel>
<channel lang="hu" xmltv_id="ComedyCentralFamilyHungary.us" site_id="316">Comedy Central Family Hungary</channel>
<channel lang="hu" xmltv_id="ComedyCentralHungary.us" site_id="194">Comedy Central Hungary</channel>
<channel lang="hu" xmltv_id="CoolTV.hu" site_id="79">Cool TV</channel>
<channel lang="hu" xmltv_id="DaVinciHungary.de" site_id="202">Da Vinci Hungary</channel>
<channel lang="hu" xmltv_id="DigiAnimalWorld.ro" site_id="249">Digi Animal World</channel>
<channel lang="hu" xmltv_id="DigiLifeHungary.ro" site_id="247">Digi Life Hungary</channel>
<channel lang="hu" xmltv_id="DigiSport1Hungary.ro" site_id="211">Digi Sport 1 Hungary</channel>
<channel lang="hu" xmltv_id="DigiSport2Hungary.ro" site_id="230">Digi Sport 2 Hungary</channel>
<channel lang="hu" xmltv_id="DigiWorldHungary.ro" site_id="248">Digi World Hungary</channel>
<channel lang="hu" xmltv_id="DiscoveryChannelHungary.us" site_id="83">Discovery Channel Hungary</channel>
<channel lang="hu" xmltv_id="DiscoveryScience.us" site_id="85">Discovery Science</channel>
<channel lang="hu" xmltv_id="DisneyChannelHungaryCzechia.us" site_id="35">Disney Channel Hungary &amp; Czechia</channel>
<channel lang="hu" xmltv_id="DuckTVSD.sk" site_id="156">Duck TV SD</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="EuroNewsEnglish.fr" site_id="71">EuroNews English</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">Fem 3</channel>
<channel lang="hu" xmltv_id="FilmBoxCentralEurope.us" site_id="226">FilmBox Central Europe</channel>
<channel lang="hu" xmltv_id="FilmCafeHungary.hu" site_id="89">Film Café Hungary</channel>
<channel lang="hu" xmltv_id="FilmMania.hu" site_id="95">Film Mánia</channel>
<channel lang="hu" xmltv_id="FilmNowHungary.ro" site_id="245">Film Now Hungary</channel>
<channel lang="hu" xmltv_id="FilmPlusHungary.hu" site_id="32">Film + Hungary</channel>
<channel lang="hu" xmltv_id="FoodNetworkEMEA.us" site_id="285">Food Network EMEA</channel>
<channel lang="hu" xmltv_id="Hatoscsatorna.hu" site_id="246">Hatoscsatorna</channel>
<channel lang="hu" xmltv_id="HBO2CentralEurope.us" site_id="59">HBO 2 Central Europe</channel>
<channel lang="hu" xmltv_id="HBO3CentralEurope.us" site_id="143">HBO 3 Central Europe</channel>
<channel lang="hu" xmltv_id="HBOHungary.us" site_id="8">HBO Hungary</channel>
<channel lang="hu" xmltv_id="HirTV.hu" site_id="10">Hír TV</channel>
<channel lang="hu" xmltv_id="HistoryEurope.us" site_id="182">History Europe</channel>
<channel lang="hu" xmltv_id="HtMusicChannelHungary.ro" site_id="253">H!t Music Channel Hungary</channel>
<channel lang="hu" xmltv_id="IzauraTV.hu" site_id="304">Izaura TV</channel>
<channel lang="hu" xmltv_id="JimJamHungary.uk" site_id="197">JimJam Hungary</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 Hungary</channel>
<channel lang="hu" xmltv_id="MoziPlus.hu" site_id="229">Mozi +</channel>
<channel lang="hu" xmltv_id="MTVGlobal.us" site_id="144">MTV Global</channel>
<channel lang="hu" xmltv_id="MusicChannelHungary.ro" 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="NationalGeographicHungaryCzechia.us" site_id="14">National Geographic Hungary &amp; Czechia</channel>
<channel lang="hu" xmltv_id="NationalGeographicWildHungary.us" site_id="141">National Geographic Wild Hungary</channel>
<channel lang="hu" xmltv_id="NickelodeonMagyarorszag.us" site_id="41">Nickelodeon Magyarország</channel>
<channel lang="hu" xmltv_id="NickJrCentralEasternEurope.us" site_id="236">Nick Jr Central &amp; Eastern Europe</channel>
<channel lang="hu" xmltv_id="OzoneTV.hu" site_id="213">Ozone TV</channel>
<channel lang="hu" xmltv_id="ParamountNetworkHungary.us" site_id="257">Paramount Network Hungary</channel>
<channel lang="hu" xmltv_id="Prime.hu" site_id="215">Prime</channel>
<channel lang="hu" xmltv_id="RTLGold.de" site_id="180">RTL Gold</channel>
<channel lang="hu" xmltv_id="RTLII.de" site_id="241">RTL II</channel>
<channel lang="hu" xmltv_id="RTLKlub.de" site_id="5">RTL Klub</channel>
<channel lang="hu" xmltv_id="RTLPlus.de" site_id="178">RTL +</channel>
<channel lang="hu" xmltv_id="SkyNewsInternational.uk" site_id="158">Sky News International</channel>
<channel lang="hu" xmltv_id="SlagerTV.hu" site_id="216">Sláger TV</channel>
<channel lang="hu" xmltv_id="SonyMaxHungary.in" site_id="132">Sony Max Hungary</channel>
<channel lang="hu" xmltv_id="SonyMovieChannelHungary.us" site_id="138">Sony Movie Channel Hungary</channel>
<channel lang="hu" xmltv_id="SorozatPlus.hu" site_id="179">Sorozat +</channel>
<channel lang="hu" xmltv_id="Spektrum.hu" site_id="9">Spektrum</channel>
<channel lang="hu" xmltv_id="SpilerTV1.hu" site_id="305">Spíler TV 1</channel>
<channel lang="hu" xmltv_id="Sport1Hungary.hu" site_id="90">Sport 1 Hungary</channel>
<channel lang="hu" xmltv_id="Sport2Hungary.hu" site_id="44">Sport 2 Hungary</channel>
<channel lang="hu" xmltv_id="Story4.hu" site_id="38">Story 4</channel>
<channel lang="hu" xmltv_id="Story5.hu" site_id="228">Story 5</channel>
<channel lang="hu" xmltv_id="SuperTV2.hu" site_id="244">Super TV 2</channel>
<channel lang="hu" xmltv_id="TeenNickHungary.us" site_id="312">TeenNick Hungary</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="TravelChannelEurope.us" site_id="84">Travel Channel Europe</channel>
<channel lang="hu" xmltv_id="TV2.hu" site_id="3">TV 2</channel>
<channel lang="hu" xmltv_id="TV2Kids.hu" site_id="310">TV 2 Kids</channel>
<channel lang="hu" xmltv_id="TV2Sef.hu" site_id="309">TV 2 Séf</channel>
<channel lang="hu" xmltv_id="TVPaprika.hu" site_id="46">TV Paprika</channel>
<channel lang="hu" xmltv_id="VH1Europe.us" site_id="99">VH1 Europe</channel>
<channel lang="hu" xmltv_id="Viasat3.hu" site_id="21">Viasat 3</channel>
<channel lang="hu" xmltv_id="Viasat6.hu" site_id="164">Viasat 6</channel>
<channel lang="hu" xmltv_id="ViasatExploreEast.se" site_id="65">Viasat Explore East</channel>
<channel lang="hu" xmltv_id="ViasatHistory.se" site_id="66">Viasat History</channel>
<channel lang="hu" xmltv_id="ViasatNatureEast.se" site_id="223">Viasat Nature East</channel>
</channels>
</site>