From abd4d2a1d5e4198f6d41f0339a66177d685de871 Mon Sep 17 00:00:00 2001 From: Aleksandr Statciuk Date: Thu, 14 Oct 2021 05:17:30 +0300 Subject: [PATCH] Update rev.bs.config.js --- sites/rev.bs.config.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/sites/rev.bs.config.js b/sites/rev.bs.config.js index 9217fd7c..30978a79 100644 --- a/sites/rev.bs.config.js +++ b/sites/rev.bs.config.js @@ -3,6 +3,7 @@ const utc = require('dayjs/plugin/utc') const timezone = require('dayjs/plugin/timezone') const axios = require('axios') const _ = require('lodash') +const cheerio = require('cheerio') dayjs.extend(utc) dayjs.extend(timezone) @@ -14,6 +15,19 @@ module.exports = { url: function ({ date }) { return endpoint.replace('$date', date.format('YYYY-MM-DD')).replace('$index', 0) }, + logo: async function ({ channel }) { + const html = await axios + .get('https://www.rev.bs/tv-guide') + .then(r => r.data) + .catch(console.log) + const $ = cheerio.load(html) + const script = $('body > script:nth-child(2)').html() + let channels = script.match(/Rev.TVGuide.channels = (.*);/i)[1] || '' + channels = JSON.parse(channels) + if (!channels[channel.site_id]) return null + + return `https:${channels[channel.site_id].channel_image}` + }, parser: async function ({ content, channel, date }) { const programs = [] const items0 = parseItems(content, channel)