mirror of
https://github.com/iptv-org/epg.git
synced 2025-05-10 00:50:09 -04:00
Create streamingtvguides.com.config.js
This commit is contained in:
parent
39271813a7
commit
c82b96fe33
1 changed files with 70 additions and 0 deletions
70
sites/streamingtvguides.com/streamingtvguides.com.config.js
Normal file
70
sites/streamingtvguides.com/streamingtvguides.com.config.js
Normal file
|
@ -0,0 +1,70 @@
|
||||||
|
const cheerio = require('cheerio')
|
||||||
|
const dayjs = require('dayjs')
|
||||||
|
const customParseFormat = require('dayjs/plugin/customParseFormat')
|
||||||
|
const timezone = require('dayjs/plugin/timezone')
|
||||||
|
const _ = require('lodash')
|
||||||
|
|
||||||
|
dayjs.extend(customParseFormat)
|
||||||
|
dayjs.extend(timezone)
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
site: 'streamingtvguides.com',
|
||||||
|
days: 2,
|
||||||
|
url({ channel }) {
|
||||||
|
return `https://streamingtvguides.com/Channel/${channel.site_id}`
|
||||||
|
},
|
||||||
|
parser({ content, date }) {
|
||||||
|
let programs = []
|
||||||
|
const items = parseItems(content)
|
||||||
|
items.forEach(item => {
|
||||||
|
const $item = cheerio.load(item)
|
||||||
|
const start = parseStart($item)
|
||||||
|
if (!date.isSame(start, 'd')) return
|
||||||
|
|
||||||
|
programs.push({
|
||||||
|
title: parseTitle($item),
|
||||||
|
description: parseDescription($item),
|
||||||
|
start,
|
||||||
|
stop: parseStop($item)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
programs = _.orderBy(_.uniqBy(programs, 'start'), 'start')
|
||||||
|
|
||||||
|
return programs
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function parseTitle($item) {
|
||||||
|
return $item('.card-body > .prog-contains > .card-title')
|
||||||
|
.clone()
|
||||||
|
.children()
|
||||||
|
.remove()
|
||||||
|
.end()
|
||||||
|
.text()
|
||||||
|
.trim()
|
||||||
|
}
|
||||||
|
|
||||||
|
function parseDescription($item) {
|
||||||
|
return $item('.card-body > .card-text').clone().children().remove().end().text().trim()
|
||||||
|
}
|
||||||
|
|
||||||
|
function parseStart($item) {
|
||||||
|
const date = $item('.card-body').clone().children().remove().end().text().trim()
|
||||||
|
const [time] = date.split(' - ')
|
||||||
|
|
||||||
|
return dayjs.tz(time, 'YYYY-MM-DD HH:mm:ss [PST]', 'PST').utc()
|
||||||
|
}
|
||||||
|
|
||||||
|
function parseStop($item) {
|
||||||
|
const date = $item('.card-body').clone().children().remove().end().text().trim()
|
||||||
|
const [_, time] = date.split(' - ')
|
||||||
|
|
||||||
|
return dayjs.tz(time, 'YYYY-MM-DD HH:mm:ss [PST]', 'PST').utc()
|
||||||
|
}
|
||||||
|
|
||||||
|
function parseItems(content) {
|
||||||
|
const $ = cheerio.load(content)
|
||||||
|
|
||||||
|
return $(`.container`).toArray()
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue