From f48a302fa8cd209dbab0dcd4ccce8341f03c979b Mon Sep 17 00:00:00 2001 From: freearhey <7253922+freearhey@users.noreply.github.com> Date: Tue, 14 Jan 2025 19:28:34 +0300 Subject: [PATCH 1/4] Delete rev.bs.test.js --- sites/rev.bs/rev.bs.test.js | 80 ------------------------------------- 1 file changed, 80 deletions(-) delete mode 100644 sites/rev.bs/rev.bs.test.js diff --git a/sites/rev.bs/rev.bs.test.js b/sites/rev.bs/rev.bs.test.js deleted file mode 100644 index d96e6d9a..00000000 --- a/sites/rev.bs/rev.bs.test.js +++ /dev/null @@ -1,80 +0,0 @@ -const { parser, url } = require('./rev.bs.config.js') -const axios = require('axios') -const dayjs = require('dayjs') -const utc = require('dayjs/plugin/utc') -const customParseFormat = require('dayjs/plugin/customParseFormat') - -dayjs.extend(customParseFormat) -dayjs.extend(utc) - -jest.mock('axios') - -const date = dayjs.utc('2021-11-21', 'YYYY-MM-DD').startOf('d') -const channel = { - site_id: '206', - xmltv_id: 'WTVJ.us' -} - -it('can generate valid url', () => { - expect(url({ date, channel })).toBe( - 'https://www.rev.bs/wp-content/uploads/tv-guide/2021-11-21_0.json' - ) -}) - -it('can parse response', done => { - axios.get.mockImplementation(url => { - if (url === 'https://www.rev.bs/wp-content/uploads/tv-guide/2021-11-21_1.json') { - return Promise.resolve({ - data: Buffer.from( - '{"status":"OK","data":{"schedule":{"206":[{"title":"Talk Stoop","sid":43599836,"s":"330.0000","duration":30,"rating":"TVPG"}]}}}' - ) - }) - } else { - return Promise.resolve({ - data: Buffer.from('{"status":"OK","data":{"schedule":{}}}') - }) - } - }) - - const content = - '{"status":"OK","data":{"schedule":{"205":[{"title":"Rev Pulse 5 - Online Classifieds","sid":43576112,"s":"-120.0000","duration":120,"rating":""}],"206":[{"title":"Saturday Night Live","sid":43599827,"s":"-31.0000","duration":93,"rating":"TV14"}]}}}' - parser({ content, channel, date }) - .then(result => { - result = result.map(p => { - p.start = p.start.toJSON() - p.stop = p.stop.toJSON() - return p - }) - expect(result).toMatchObject([ - { - start: '2021-11-21T04:29:00.000Z', - stop: '2021-11-21T06:02:00.000Z', - title: 'Saturday Night Live' - }, - { - start: '2021-11-21T10:30:00.000Z', - stop: '2021-11-21T11:00:00.000Z', - title: 'Talk Stoop' - } - ]) - done() - }) - .catch(err => { - done(err) - }) -}) - -it('can handle empty guide', done => { - parser({ - date, - channel, - content: '
' - }) - .then(result => { - expect(result).toMatchObject([]) - done() - }) - .catch(err => { - done(err) - }) -}) From f83e7d33d71e705a6c08017820fc5031cc85d7e4 Mon Sep 17 00:00:00 2001 From: freearhey <7253922+freearhey@users.noreply.github.com> Date: Tue, 14 Jan 2025 19:28:48 +0300 Subject: [PATCH 2/4] Delete rev.bs.config.js --- sites/rev.bs/rev.bs.config.js | 68 ----------------------------------- 1 file changed, 68 deletions(-) delete mode 100644 sites/rev.bs/rev.bs.config.js diff --git a/sites/rev.bs/rev.bs.config.js b/sites/rev.bs/rev.bs.config.js deleted file mode 100644 index c956fd1c..00000000 --- a/sites/rev.bs/rev.bs.config.js +++ /dev/null @@ -1,68 +0,0 @@ -const _ = require('lodash') -const axios = require('axios') -const dayjs = require('dayjs') -const utc = require('dayjs/plugin/utc') -const timezone = require('dayjs/plugin/timezone') - -dayjs.extend(utc) -dayjs.extend(timezone) - -module.exports = { - site: 'rev.bs', - days: 2, - url: function ({ date }) { - return `https://www.rev.bs/wp-content/uploads/tv-guide/${date.format('YYYY-MM-DD')}_0.json` - }, - parser: async function ({ content, channel, date }) { - const programs = [] - const items0 = parseItems(content, channel) - if (!items0.length) return programs - const items1 = parseItems(await loadNextItems(date, 1), channel) - const items2 = parseItems(await loadNextItems(date, 2), channel) - const items3 = parseItems(await loadNextItems(date, 3), channel) - const items = _.unionBy(items0, items1, items2, items3, 'sid') - items.forEach(item => { - const start = parseStart(item, date) - const stop = start.add(item.duration, 'm') - programs.push({ - title: item.title, - start, - stop - }) - }) - - return programs - } -} - -async function loadNextItems(date, index) { - const url = `https://www.rev.bs/wp-content/uploads/tv-guide/${date.format( - 'YYYY-MM-DD' - )}_${index}.json` - - return axios - .get(url, { - responseType: 'arraybuffer' - }) - .then(res => res.data.toString()) - .catch(console.log) -} - -function parseStart(item, date) { - const shift = parseInt(item.s) - - return dayjs.tz(date.add(shift, 'm').toString(), 'America/New_York') -} - -function parseItems(content, channel) { - let data - try { - data = JSON.parse(content) - } catch { - return [] - } - - if (!data || data.status !== 'OK') return [] - - return data.data.schedule[channel.site_id] || [] -} From 9087b4d104e535279d029c9dd2f9e325963a6cc5 Mon Sep 17 00:00:00 2001 From: freearhey <7253922+freearhey@users.noreply.github.com> Date: Tue, 14 Jan 2025 19:29:43 +0300 Subject: [PATCH 3/4] Delete rev.bs.channels.xml --- sites/rev.bs/rev.bs.channels.xml | 183 ------------------------------- 1 file changed, 183 deletions(-) delete mode 100644 sites/rev.bs/rev.bs.channels.xml diff --git a/sites/rev.bs/rev.bs.channels.xml b/sites/rev.bs/rev.bs.channels.xml deleted file mode 100644 index ecf78acc..00000000 --- a/sites/rev.bs/rev.bs.channels.xml +++ /dev/null @@ -1,183 +0,0 @@ - -