mirror of
https://github.com/iptv-org/epg.git
synced 2025-05-10 00:50:09 -04:00
Update rev.bs.config.js
This commit is contained in:
parent
ca32f8a280
commit
e6735dba2b
1 changed files with 16 additions and 13 deletions
|
@ -1,19 +1,16 @@
|
||||||
|
const _ = require('lodash')
|
||||||
|
const axios = require('axios')
|
||||||
const dayjs = require('dayjs')
|
const dayjs = require('dayjs')
|
||||||
const utc = require('dayjs/plugin/utc')
|
const utc = require('dayjs/plugin/utc')
|
||||||
const timezone = require('dayjs/plugin/timezone')
|
const timezone = require('dayjs/plugin/timezone')
|
||||||
const axios = require('axios')
|
|
||||||
const _ = require('lodash')
|
|
||||||
const cheerio = require('cheerio')
|
|
||||||
|
|
||||||
dayjs.extend(utc)
|
dayjs.extend(utc)
|
||||||
dayjs.extend(timezone)
|
dayjs.extend(timezone)
|
||||||
|
|
||||||
const endpoint = `https://www.rev.bs/wp-content/uploads/tv-guide/$date_$index.json`
|
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
site: 'rev.bs',
|
site: 'rev.bs',
|
||||||
url: function ({ date }) {
|
url: function ({ date }) {
|
||||||
return endpoint.replace('$date', date.format('YYYY-MM-DD')).replace('$index', 0)
|
return `https://www.rev.bs/wp-content/uploads/tv-guide/${date.format('YYYY-MM-DD')}_0.json`
|
||||||
},
|
},
|
||||||
logo({ channel }) {
|
logo({ channel }) {
|
||||||
return channel.logo
|
return channel.logo
|
||||||
|
@ -21,6 +18,7 @@ module.exports = {
|
||||||
parser: async function ({ content, channel, date }) {
|
parser: async function ({ content, channel, date }) {
|
||||||
const programs = []
|
const programs = []
|
||||||
const items0 = parseItems(content, channel)
|
const items0 = parseItems(content, channel)
|
||||||
|
if (!items0.length) return programs
|
||||||
const items1 = parseItems(await loadNextItems(date, 1), channel)
|
const items1 = parseItems(await loadNextItems(date, 1), channel)
|
||||||
const items2 = parseItems(await loadNextItems(date, 2), channel)
|
const items2 = parseItems(await loadNextItems(date, 2), channel)
|
||||||
const items3 = parseItems(await loadNextItems(date, 3), channel)
|
const items3 = parseItems(await loadNextItems(date, 3), channel)
|
||||||
|
@ -40,25 +38,30 @@ module.exports = {
|
||||||
}
|
}
|
||||||
|
|
||||||
async function loadNextItems(date, index) {
|
async function loadNextItems(date, index) {
|
||||||
const url = endpoint.replace('$date', date.format('YYYY-MM-DD')).replace('$index', index)
|
const url = `https://www.rev.bs/wp-content/uploads/tv-guide/${date.format(
|
||||||
|
'YYYY-MM-DD'
|
||||||
|
)}_${index}.json`
|
||||||
|
|
||||||
return axios
|
return axios
|
||||||
.get(url, {
|
.get(url, {
|
||||||
responseType: 'arraybuffer'
|
responseType: 'arraybuffer'
|
||||||
})
|
})
|
||||||
.then(res => res.data.toString())
|
.then(res => res.data.toString())
|
||||||
.catch(e => ({}))
|
.catch(console.log)
|
||||||
}
|
}
|
||||||
|
|
||||||
function parseStart(item, d) {
|
function parseStart(item, date) {
|
||||||
const shift = parseInt(item.s)
|
const shift = parseInt(item.s)
|
||||||
|
|
||||||
return dayjs.tz(d.add(shift, 'm').toString(), 'America/New_York')
|
return dayjs.tz(date.add(shift, 'm').toString(), 'America/New_York')
|
||||||
}
|
}
|
||||||
|
|
||||||
function parseItems(content, channel) {
|
function parseItems(content, channel) {
|
||||||
const data = JSON.parse(content)
|
let data
|
||||||
if (data.status !== 'OK') return []
|
try {
|
||||||
|
data = JSON.parse(content)
|
||||||
|
} catch (err) {}
|
||||||
|
if (!data || data.status !== 'OK') return []
|
||||||
|
|
||||||
return data.data.schedule[channel.site_id]
|
return data.data.schedule[channel.site_id] || []
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue