Initial Commit
This commit is contained in:
98
sites/getafteritmedia.com/__data__/content.html
Normal file
98
sites/getafteritmedia.com/__data__/content.html
Normal file
File diff suppressed because one or more lines are too long
10
sites/getafteritmedia.com/getafteritmedia.com.channels.xml
Normal file
10
sites/getafteritmedia.com/getafteritmedia.com.channels.xml
Normal file
@@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<site site="getafteritmedia.com">
|
||||
<channels>
|
||||
<channel lang="en" xmltv_id="REVNEastern.us" site_id="380697915">REV'N Eastern</channel>
|
||||
<channel lang="en" xmltv_id="REVNCentral.us" site_id="1722195092">REV'N Central</channel>
|
||||
<channel lang="en" xmltv_id="REVNMountain.us" site_id="1014453176">REV'N Mountain</channel>
|
||||
<channel lang="en" xmltv_id="REVNPacific.us" site_id="589261086">REV'N Pacific</channel>
|
||||
<channel lang="en" xmltv_id="REVNWebFeed.us" site_id="494637005">REV'N Web Feed</channel>
|
||||
</channels>
|
||||
</site>
|
||||
64
sites/getafteritmedia.com/getafteritmedia.com.config.js
Normal file
64
sites/getafteritmedia.com/getafteritmedia.com.config.js
Normal file
@@ -0,0 +1,64 @@
|
||||
const table2array = require('table2array')
|
||||
const cheerio = require('cheerio')
|
||||
const dayjs = require('dayjs')
|
||||
const utc = require('dayjs/plugin/utc')
|
||||
const timezone = require('dayjs/plugin/timezone')
|
||||
const customParseFormat = require('dayjs/plugin/customParseFormat')
|
||||
const isoWeek = require('dayjs/plugin/isoWeek')
|
||||
|
||||
dayjs.extend(utc)
|
||||
dayjs.extend(timezone)
|
||||
dayjs.extend(customParseFormat)
|
||||
dayjs.extend(isoWeek)
|
||||
|
||||
module.exports = {
|
||||
site: 'getafteritmedia.com',
|
||||
days: 2,
|
||||
url: 'https://docs.google.com/spreadsheets/d/e/2PACX-1vQcDmb9OnO0HpbjINfGaepqgGTp3VSmPs7hs654n3sRKrq4Q9y6uPSEvVvq9MwTLYG_n_V7vh0rFYP9/pubhtml',
|
||||
parser({ content, channel, date }) {
|
||||
const programs = []
|
||||
const items = parseItems(content, channel, date)
|
||||
items.forEach(item => {
|
||||
const prev = programs[programs.length - 1]
|
||||
let start = parseStart(item, date)
|
||||
if (prev) {
|
||||
if (start.isBefore(prev.start)) {
|
||||
start = start.add(1, 'd')
|
||||
date = date.add(1, 'd')
|
||||
}
|
||||
prev.stop = start
|
||||
}
|
||||
const stop = start.add(30, 'm')
|
||||
programs.push({
|
||||
title: item.title,
|
||||
start,
|
||||
stop
|
||||
})
|
||||
})
|
||||
|
||||
return programs
|
||||
}
|
||||
}
|
||||
|
||||
function parseStart(item, date) {
|
||||
return dayjs.tz(
|
||||
`${date.format('YYYY-MM-DD')} ${item.time}`,
|
||||
'YYYY-MM-DD HH:mm A',
|
||||
'America/New_York'
|
||||
)
|
||||
}
|
||||
|
||||
function parseItems(content, channel, date) {
|
||||
const day = date.isoWeekday()
|
||||
const $ = cheerio.load(content)
|
||||
const table = $.html($(`#${channel.site_id} table`))
|
||||
let data = table2array(table)
|
||||
data.splice(0, 5)
|
||||
|
||||
return data.map(row => {
|
||||
return {
|
||||
time: row[1],
|
||||
title: row[day + 1]
|
||||
}
|
||||
})
|
||||
}
|
||||
47
sites/getafteritmedia.com/getafteritmedia.com.test.js
Normal file
47
sites/getafteritmedia.com/getafteritmedia.com.test.js
Normal file
@@ -0,0 +1,47 @@
|
||||
// npx epg-grabber --config=sites/getafteritmedia.com/getafteritmedia.com.config.js --channels=sites/getafteritmedia.com/getafteritmedia.com.channels.xml --output=guide.xml --days=2
|
||||
|
||||
const { parser, url } = require('./getafteritmedia.com.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-26', 'YYYY-MM-DD').startOf('d')
|
||||
const channel = {
|
||||
site_id: '494637005',
|
||||
xmltv_id: 'REVNWebFeed.us'
|
||||
}
|
||||
|
||||
it('can generate valid url', () => {
|
||||
expect(url).toBe(
|
||||
'https://docs.google.com/spreadsheets/d/e/2PACX-1vQcDmb9OnO0HpbjINfGaepqgGTp3VSmPs7hs654n3sRKrq4Q9y6uPSEvVvq9MwTLYG_n_V7vh0rFYP9/pubhtml'
|
||||
)
|
||||
})
|
||||
|
||||
it('can parse response', () => {
|
||||
const content = fs.readFileSync(path.resolve(__dirname, '__data__/content.html'), 'utf8')
|
||||
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-26T05:00:00.000Z',
|
||||
stop: '2022-11-26T05:30:00.000Z',
|
||||
title: `The Appraisers`
|
||||
})
|
||||
})
|
||||
|
||||
it('can handle empty guide', () => {
|
||||
const result = parser({
|
||||
date,
|
||||
channel,
|
||||
content: `<!DOCTYPE html><html><head></head><body></body></html>`
|
||||
})
|
||||
expect(result).toMatchObject([])
|
||||
})
|
||||
Reference in New Issue
Block a user