mirror of
https://github.com/iptv-org/epg.git
synced 2025-05-10 09:00:07 -04:00
commit
eeb27cc9db
3 changed files with 1021 additions and 24 deletions
1008
sites/kvf.fo/__data__/example.html
Normal file
1008
sites/kvf.fo/__data__/example.html
Normal file
File diff suppressed because one or more lines are too long
|
@ -11,7 +11,7 @@ dayjs.extend(customParseFormat)
|
||||||
module.exports = {
|
module.exports = {
|
||||||
site: 'kvf.fo',
|
site: 'kvf.fo',
|
||||||
url({ date }) {
|
url({ date }) {
|
||||||
return `https://kvf.fo/nskra/uv?date=${date.format('YYYY-MM-DD')}`
|
return `https://kvf.fo/nskra/sv?date=${date.format('YYYY-MM-DD')}`
|
||||||
},
|
},
|
||||||
parser({ content, date }) {
|
parser({ content, date }) {
|
||||||
let programs = []
|
let programs = []
|
||||||
|
@ -20,6 +20,7 @@ module.exports = {
|
||||||
const prev = programs[programs.length - 1]
|
const prev = programs[programs.length - 1]
|
||||||
const $item = cheerio.load(item)
|
const $item = cheerio.load(item)
|
||||||
let start = parseStart($item, date)
|
let start = parseStart($item, date)
|
||||||
|
if (!start) return
|
||||||
if (prev && start.isBefore(prev.stop)) {
|
if (prev && start.isBefore(prev.stop)) {
|
||||||
start = start.add(1, 'd')
|
start = start.add(1, 'd')
|
||||||
date = date.add(1, 'd')
|
date = date.add(1, 'd')
|
||||||
|
@ -65,7 +66,5 @@ function parseTitle($item) {
|
||||||
function parseItems(content) {
|
function parseItems(content) {
|
||||||
const $ = cheerio.load(content)
|
const $ = cheerio.load(content)
|
||||||
|
|
||||||
return $(
|
return $('.view > .view-content > div.views-row').toArray()
|
||||||
'#block-system-main > div > div > div.panels-flexible-row.panels-flexible-row-339-main-row.panels-flexible-row-last.clearfix > div > div.panels-flexible-region.panels-flexible-region-339-center.panels-flexible-region-first > div > div > div > div > div.view-content > div.views-row'
|
|
||||||
).toArray()
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
// npx epg-grabber --config=sites/kvf.fo/kvf.fo.config.js --channels=sites/kvf.fo/kvf.fo_fo.channels.xml --output=.gh-pages/guides/fo/kvf.fo.epg.xml --days=2
|
// npx epg-grabber --config=sites/kvf.fo/kvf.fo.config.js --channels=sites/kvf.fo/kvf.fo_fo.channels.xml --output=guide.xml --days=2
|
||||||
|
|
||||||
const { parser, url } = require('./kvf.fo.config.js')
|
const { parser, url } = require('./kvf.fo.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')
|
||||||
|
@ -14,34 +16,22 @@ const channel = {
|
||||||
}
|
}
|
||||||
|
|
||||||
it('can generate valid url', () => {
|
it('can generate valid url', () => {
|
||||||
expect(url({ date })).toBe('https://kvf.fo/nskra/uv?date=2021-11-21')
|
expect(url({ date })).toBe('https://kvf.fo/nskra/sv?date=2021-11-21')
|
||||||
})
|
})
|
||||||
|
|
||||||
it('can parse response', () => {
|
it('can parse response', () => {
|
||||||
const content = `<!DOCTYPE html><html> <head></head> <body class="html not-front not-logged-in no-sidebars page-nskra page-nskra-uv"> <body> <div class="main-container container"> <div class="row"> <section class="col-sm-12"> <a id="main-content"></a> <div class="region region-content"> <section id="block-system-main" class="block block-system clearfix"> <div class="panel-flexible panels-flexible-339 clearfix"> <div class="panel-flexible-inside panels-flexible-339-inside"> <div class=" panels-flexible-row panels-flexible-row-339-main-row panels-flexible-row-last clearfix " > <div class=" inside panels-flexible-row-inside panels-flexible-row-339-main-row-inside panels-flexible-row-inside-last clearfix " > <div class=" panels-flexible-region panels-flexible-region-339-center panels-flexible-region-first " > <div class=" inside panels-flexible-region-inside panels-flexible-region-339-center-inside panels-flexible-region-inside-first " > <div class="panel-pane pane-views pane-ws-skr-ir"> <div class="pane-content"> <div class=" view view-ws-skr-ir view-id-ws_skr_ir view-display-id-page_uv s-pane view-dom-id-3dc4c119f4c633d65e7ed8b3c167d7a2 " > <div class="view-content"> <div class="views-row views-row-1"> <div class="s-normal"> <div class="s-time1"> <div class="s-time">00:00 - 02:00</div></div><div class="s-player"></div><div class="s-heiti">Plátubarrin</div><div class="s-option"> <div class="s-expand"> <img src="/sites/all/themes/bootstrap_subtheme/images/skra/plus.png"/> </div></div><div class="s-timer-notimer"></div></div><div class="s-sub" style="display: none"> <table class="s-insider"> <tr> <td class="c1"> <div class="s-imgsending"> <img typeof="foaf:Image" class="img-responsive" src="https://kvf.fo/sites/default/files/styles/nvf-very-small/public/platubarrin_1.jpg?itok=5kwClG66" width="116" height="65" alt=""/> </div></td><td class="c2"> <div class="s-subtitle"> Beinleiðis leygarkvøldssending við temaplátu og lurtaraynskjum. </div><div class="s-text"></div><div class="s-producer"> Jákup Magnussen er vertur. </div><div> <div class="s-sending"> <a href="/node/18941">Far til sendingasíðu</a> </div></div></td></tr></table> </div></div><div class="views-row views-row-26"> <div class="s-normal"> <div class="s-time1"> <div class="s-time">23:00 - 00:00</div></div><div class="s-player"></div><div class="s-heiti">Tónleikur</div><div class="s-option"> <div class="s-expand"> <img src="/sites/all/themes/bootstrap_subtheme/images/skra/plus.png"/> </div></div><div class="s-timer-notimer"></div></div><div class="s-sub" style="display: none"> <table class="s-insider"> <tbody> <tr> <td class="c1"></td><td class="c2"> <div class="s-subtitle"></div><div class="s-text"></div><div class="s-producer"></div><div></div></td></tr></tbody> </table> </div></div><div class="views-row views-row-26"> <div class="s-normal"> <div class="s-time1"> <div class="s-time">00:00 - 01:00</div></div><div class="s-player"></div><div class="s-heiti">Náttarrásin</div><div class="s-option"> <div class="s-expand"> <img src="/sites/all/themes/bootstrap_subtheme/images/skra/plus.png"/> </div></div><div class="s-timer-notimer"></div></div><div class="s-sub" style="display: none"> <table class="s-insider"> <tbody> <tr> <td class="c1"></td><td class="c2"> <div class="s-subtitle"></div><div class="s-text"></div><div class="s-producer"></div><div></div></td></tr></tbody> </table> </div></div></div></div></div></div></div></div></div></div></div></div></section> </div></section> </div></div></body> </body></html>`
|
const content = fs.readFileSync(path.resolve(__dirname, './__data__/example.html'))
|
||||||
const result = parser({ content, date }).map(p => {
|
const result = parser({ content, date }).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(result[2]).toMatchObject({
|
||||||
{
|
start: '2021-11-21T18:05:00.000Z',
|
||||||
start: '2021-11-21T00:00:00.000Z',
|
stop: '2021-11-21T18:30:00.000Z',
|
||||||
stop: '2021-11-21T02:00:00.000Z',
|
title: `Letibygd 13`
|
||||||
title: `Plátubarrin`
|
})
|
||||||
},
|
|
||||||
{
|
|
||||||
start: '2021-11-21T23:00:00.000Z',
|
|
||||||
stop: '2021-11-22T00:00:00.000Z',
|
|
||||||
title: `Tónleikur`
|
|
||||||
},
|
|
||||||
{
|
|
||||||
start: '2021-11-22T00:00:00.000Z',
|
|
||||||
stop: '2021-11-22T01:00:00.000Z',
|
|
||||||
title: `Náttarrásin`
|
|
||||||
}
|
|
||||||
])
|
|
||||||
})
|
})
|
||||||
|
|
||||||
it('can handle empty guide', () => {
|
it('can handle empty guide', () => {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue