Merge branch 'iptv-org:master' into master

This commit is contained in:
smrtprjcts
2022-11-19 17:22:07 +01:00
committed by GitHub
9 changed files with 5724 additions and 258 deletions

File diff suppressed because one or more lines are too long

View File

@@ -2,47 +2,47 @@
// npx epg-grabber --config=sites/musor.tv/musor.tv.config.js --channels=sites/musor.tv/musor.tv_hu.channels.xml --output=guide.xml --days=2
const { parser, url } = require('./musor.tv.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-03-07', 'YYYY-MM-DD').startOf('d')
const date = dayjs.utc('2022-11-20', 'YYYY-MM-DD').startOf('d')
const channel = {
site_id: 'DUNA',
xmltv_id: 'DunaTV.hu'
site_id: 'HATOS_CSATORNA',
xmltv_id: 'Hatoscsatorna.hu'
}
it('can generate valid url', () => {
expect(url({ channel, date })).toBe('https://musor.tv/napi/tvmusor/DUNA/2022.03.07')
expect(url({ channel, date })).toBe('https://musor.tv/napi/tvmusor/HATOS_CSATORNA/2022.11.20')
})
it('can parse response', () => {
const content = `<!DOCTYPE html><html><head></head><body> <div class="big_content"> <div class="content"> <div class="content_container"> <section> <div class="striped_table striped_table_min_height"> <div class="striped_table_row"> <div class="striped_table_cell_right striped_table_cell_right_padding"> <div class="multicolumn multicolumndayprogarea"> <div class="smartpe_progentry" itemscope itemtype="https://schema.org/BroadcastEvent" title="Tovább a részletes műsorinformációhoz" onclick="clickOn(event,'a_36861422');"> <div class="smartpe_progentryrow"> <div class="smartpe_progentrycell"> <div class="smartpe_progentry_intable top5"> <div class="smartpe_progentryrow"> <div class="smartpe_progentrycell"> <time class="smartpe_time" itemprop="startDate" content="2022-03-06GMT23:35:00">00:35</time> </div></div></div></div></div><div class="smartpe_progentryrow"> <div class="smartpe_progentrycell"> <h3 class="smartpe_progtitle_common smartpe_progtitle" itemprop="name"><a id="a_36861422" href="/tvmusor/Havannai_ejszaka/36861422" target="_blank">Havannai éjszaka</a></h3> </div></div><div class="smartpe_progentryrow"> <div class="smartpe_progentrycell"> <div class="smartpe_progshortdesc" itemprop="description"> kubai-francia filmdráma,2014 </div></div></div><div class="smartpe_progentryrow"> <div class="smartpe_progentrycell smartpe_screenshot"> <img src="//musor.tv/img/small/143/14373/Labadrugas.jpg" width="174" height="116" class="" alt="tv-műsor kép: Labadrúgás" title="tv-műsor: Labadrúgás"> </div></div><div class="smartpe_progentryrow"> <div class="smartpe_progentrycell"> <div class="smartpe_progentrylong"> A Havannai éjszaka az első film, amely teljes egészében Kubában forgott és kendőzetlen őszinteséggel beszél egy elveszett generáció minden illúziójáról és csalódottságáról. Amadeo 16 évig nem találkozott legjobb barátaival, fe </div></div></div></div><div class="smartpe_progentry" itemscope itemtype="https://schema.org/BroadcastEvent" title="Tovább a részletes műsorinformációhoz" onclick="clickOn(event,'a_36861419');"> <div class="smartpe_progentryrow"> <div class="smartpe_progentrycell"> <div class="smartpe_progentry_intable top5"> <div class="smartpe_progentryrow"> <div class="smartpe_progentrycell"> <time class="smartpe_time" itemprop="startDate" content="2022-03-07GMT01:15:00">02:15</time> </div></div></div></div></div><div class="smartpe_progentryrow"> <div class="smartpe_progentrycell"> <h3 class="smartpe_progtitle_common smartpe_progtitle" itemprop="name"><a id="a_36861419" href="/tvmusor/A_tengeralattjaro_2018_I_1_/36861419" target="_blank">A tengeralattjáró 2018 I./1.</a></h3> </div></div><div class="smartpe_progentryrow"> <div class="smartpe_progentrycell"> <div class="smartpe_progshortdesc" itemprop="description"> német tévéfilmsorozat,2018 </div></div></div><div class="smartpe_progentryrow"> <div class="smartpe_progentrycell"> <img src="/images/etc/pg_16.svg" class="smartpe_rating" width="22" height="22" alt="TV műsor 16 év felettieknek!" title="A TV műsor megtekintése 16 év felettieknek ajánlott!"> <span class="smartpe_hd"><img src="/images/etc/hd_30.png" alt="HD adás" title="A műsor HD minőségben is elérhető!" width="30" height="22"></span> </div></div><div class="smartpe_progentryrow"> <div class="smartpe_progentrycell"> <div class="smartpe_progentrylong"> 8/1.: Új utakonUlrich Wrangel tengeralattjáró-kapitány és emberei összecsapásba keverednek egy amerikai fregatt-tal. Eközben a megszállt Franciaországban az ifjú Klaus Hoffmann kapitány azon igyekszik, hogy méltó legyen apja hírnevé </div></div></div></div></div></div></div></div></section> </div></div></div></body></html>`
const result = parser({ content, date }).map(p => {
const content = fs.readFileSync(path.resolve(__dirname, '__data__/content.html'))
let results = parser({ content, date })
results = results.map(p => {
p.start = p.start.toJSON()
p.stop = p.stop.toJSON()
return p
})
expect(result).toMatchObject([
{
start: '2022-03-06T23:35:00.000Z',
stop: '2022-03-07T01:15:00.000Z',
title: `Havannai éjszaka`,
icon: 'https://musor.tv/img/small/143/14373/Labadrugas.jpg',
description:
'A Havannai éjszaka az első film, amely teljes egészében Kubában forgott és kendőzetlen őszinteséggel beszél egy elveszett generáció minden illúziójáról és csalódottságáról. Amadeo 16 évig nem találkozott legjobb barátaival, fe'
},
{
start: '2022-03-07T01:15:00.000Z',
stop: '2022-03-07T01:45:00.000Z',
title: `A tengeralattjáró 2018 I./1.`,
description:
'8/1.: Új utakonUlrich Wrangel tengeralattjáró-kapitány és emberei összecsapásba keverednek egy amerikai fregatt-tal. Eközben a megszállt Franciaországban az ifjú Klaus Hoffmann kapitány azon igyekszik, hogy méltó legyen apja hírnevé'
}
])
expect(results[0]).toMatchObject({
start: '2022-11-19T23:00:00.000Z',
stop: '2022-11-19T23:30:00.000Z',
title: `Egészségtér`,
description:
'Egészségtér címmel új természetgyógyászattal foglalkozó magazinműsor indult hetente fél órás időtartamban a hatoscsatornán. A műsor derűs, objektív hangvételével és szakmailag magas színvonalú ismeretterjesztő jellegével az e'
})
expect(results[1]).toMatchObject({
start: '2022-11-19T23:30:00.000Z',
stop: '2022-11-20T00:00:00.000Z',
title: `Tradíció Klipek`,
description: 'Tradíció Klipek Birinyi József néprajzi, vallási, népzenei, népszokás filmjeiből.'
})
})
it('can handle empty guide', () => {

File diff suppressed because one or more lines are too long

View File

@@ -1,6 +1,6 @@
const FormData = require('form-data')
const axios = require('axios')
const dayjs = require('dayjs')
const _ = require('lodash')
module.exports = {
site: 'tvmusor.hu',
@@ -26,13 +26,20 @@ module.exports = {
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: dayjs(item.e),
stop: dayjs(item.f)
start,
stop
})
})
@@ -67,6 +74,7 @@ function parseItems(content, channel, date) {
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 Array.isArray(blocks[blockId]) ? blocks[blockId] : []
return _.uniqBy(_.uniqBy(blocks[blockId], 'e'), 'b')
}

View File

@@ -1,17 +1,19 @@
// node ./scripts/channels.js --config=./sites/tvmusor.hu/tvmusor.hu.config.js --output=./sites/tvmusor.hu/tvmusor.hu_hu.channels.xml
// npm run channels:parse -- --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=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('2021-11-24', 'YYYY-MM-DD').startOf('d')
const date = dayjs.utc('2022-11-19', 'YYYY-MM-DD').startOf('d')
const channel = {
site_id: '139',
xmltv_id: 'AMCHungary.hu'
site_id: '290',
xmltv_id: 'M4Sport.hu'
}
it('can generate valid url', () => {
@@ -30,27 +32,33 @@ it('can generate valid request headers', () => {
it('can generate valid request data', () => {
const result = request.data({ channel, date })
expect(result.get('data')).toBe('{"blocks":["139|2021-11-24"]}')
expect(result.get('data')).toBe('{"blocks":["290|2022-11-19"]}')
})
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 => {
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(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'
}
])
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', () => {

View File

@@ -30,7 +30,6 @@
<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</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>
@@ -92,5 +91,6 @@
<channel lang="hu" xmltv_id="ViasatExplore.se" site_id="65">Viasat Explore</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>