mirror of
https://github.com/iptv-org/epg
synced 2026-05-08 18:36:59 -04:00
Update /sites
This commit is contained in:
@@ -1,6 +1,4 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<site site="pbsguam.org">
|
||||
<channels>
|
||||
<channel lang="en" xmltv_id="KGTFDT1.us" site_id="#">PBS Guam (KGTF) Hagåtña, Guam</channel>
|
||||
</channels>
|
||||
</site>
|
||||
<channels>
|
||||
<channel site="pbsguam.org" lang="en" xmltv_id="KGTFDT1.us" site_id="#">PBS Guam (KGTF) Hagåtña, Guam</channel>
|
||||
</channels>
|
||||
@@ -23,9 +23,14 @@ module.exports = {
|
||||
}
|
||||
|
||||
function parseItems(content, date) {
|
||||
const [_, json] = content.match(/EventsSchedule_1 = (.*);/i) || [null, null]
|
||||
if (!json) return []
|
||||
const data = JSON.parse(json)
|
||||
const [, json] = content.match(/EventsSchedule_1 = (.*);/i) || [null, '']
|
||||
let data
|
||||
try {
|
||||
data = JSON.parse(json)
|
||||
} catch (error) {
|
||||
return []
|
||||
}
|
||||
|
||||
if (!data || !Array.isArray(data.feed)) return []
|
||||
|
||||
return data.feed.filter(
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// npx epg-grabber --config=sites/pbsguam.org/pbsguam.org.config.js --channels=sites/pbsguam.org/pbsguam.org.channels.xml --output=guide.xml --days=2
|
||||
// npm run grab -- --site=pbsguam.org
|
||||
|
||||
const { parser, url } = require('./pbsguam.org.config.js')
|
||||
const dayjs = require('dayjs')
|
||||
@@ -20,7 +20,7 @@ it('can generate valid url', () => {
|
||||
it('can parse response', () => {
|
||||
const content = `<!DOCTYPE html><html lang="en-US"> <head></head> <body> <script type='text/javascript' id='wcs-main-js-extra'>
|
||||
/* <![CDATA[ */
|
||||
var EventsSchedule_1 = {\"feed\":[{\"title\":\"Xavier Riddle and the Secret Museum\",\"id\":5097,\"thumbnail\":false,\"thumbnail_size\":false,\"multiday\":false,\"ending\":\"\",\"duration\":\"30'\",\"terms\":[],\"period\":30,\"excerpt\":\"\",\"hash\":\"5d7710f569fec3fb1839bd7e5ad87038\",\"visible\":true,\"timestamp\":1637829000,\"last\":false,\"start\":\"2021-11-25T08:30:00+00:00\",\"end\":\"2021-11-25T09:00:00+00:00\",\"future\":true,\"finished\":false,\"permalink\":\"https:\\/\\/pbsguam.org\\/class\\/xavier-riddle-and-the-secret-museum\\/?wcs_timestamp=1637829000\",\"buttons\":[],\"meta\":[]},{\"title\":\"Austin City Limits\",\"id\":3916,\"thumbnail\":false,\"thumbnail_size\":false,\"multiday\":false,\"ending\":\"\",\"duration\":\"1h\",\"terms\":[],\"period\":60,\"excerpt\":\"\",\"hash\":\"1255a0a23db3b726b38a5384147ec677\",\"visible\":true,\"timestamp\":1638140400,\"last\":false,\"start\":\"2021-11-28T23:00:00+00:00\",\"end\":\"2021-11-29T00:00:00+00:00\",\"future\":true,\"finished\":false,\"permalink\":\"https:\\/\\/pbsguam.org\\/class\\/austin-city-limits\\/?wcs_timestamp=1638140400\",\"buttons\":[],\"meta\":[]}]};
|
||||
var EventsSchedule_1 = {"feed":[{"title":"Xavier Riddle and the Secret Museum","id":5097,"thumbnail":false,"thumbnail_size":false,"multiday":false,"ending":"","duration":"30'","terms":[],"period":30,"excerpt":"","hash":"5d7710f569fec3fb1839bd7e5ad87038","visible":true,"timestamp":1637829000,"last":false,"start":"2021-11-25T08:30:00+00:00","end":"2021-11-25T09:00:00+00:00","future":true,"finished":false,"permalink":"https://pbsguam.org/class/xavier-riddle-and-the-secret-museum/?wcs_timestamp=1637829000","buttons":[],"meta":[]},{"title":"Austin City Limits","id":3916,"thumbnail":false,"thumbnail_size":false,"multiday":false,"ending":"","duration":"1h","terms":[],"period":60,"excerpt":"","hash":"1255a0a23db3b726b38a5384147ec677","visible":true,"timestamp":1638140400,"last":false,"start":"2021-11-28T23:00:00+00:00","end":"2021-11-29T00:00:00+00:00","future":true,"finished":false,"permalink":"https://pbsguam.org/class/austin-city-limits/?wcs_timestamp=1638140400","buttons":[],"meta":[]}]};
|
||||
/* ]]> */
|
||||
</script> </body></html>`
|
||||
const result = parser({ date, content }).map(p => {
|
||||
@@ -42,7 +42,7 @@ it('can handle empty guide', () => {
|
||||
const result = parser({
|
||||
date,
|
||||
channel,
|
||||
content: `<html> <head></head> <body></body></html>`
|
||||
content: '<html> <head></head> <body></body></html>'
|
||||
})
|
||||
expect(result).toMatchObject([])
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user