From 533583fee4511017ef0dc9f6e26432bd1b5fe603 Mon Sep 17 00:00:00 2001 From: freearhey Date: Fri, 12 Mar 2021 17:42:01 +0300 Subject: [PATCH] wip --- .gh-pages/guides/programme-tv.net.xml | 28 --------------------------- bin/epg-grabber/index.js | 2 +- bin/epg-grabber/utils.js | 7 +++++-- sites/programme-tv.net.channels.xml | 4 ++-- sites/programme-tv.net.config.js | 11 ++++------- sites/tv.yandex.ru.config.js | 1 - sites/tvguide.co.uk.config.js | 4 ++-- update.sh | 4 ++-- 8 files changed, 16 insertions(+), 45 deletions(-) delete mode 100644 .gh-pages/guides/programme-tv.net.xml diff --git a/.gh-pages/guides/programme-tv.net.xml b/.gh-pages/guides/programme-tv.net.xml deleted file mode 100644 index 788051d2..00000000 --- a/.gh-pages/guides/programme-tv.net.xml +++ /dev/null @@ -1,28 +0,0 @@ - -13ème Rue -Meurtres à Saint-MaloTéléfilm de suspense -Commissaire MagellanSérie policière -ComplicesCourt métrage -Ice screamCourt métrage -IntusCourt métrage dramatique -CaïdsCourt métrage dramatique -Crimes parfaitsSérie policière -Crimes parfaitsSérie policière -Meurtres à RocamadourTéléfilm policier -Commissaire MagellanSérie policière -FalcoSérie de suspense -Close to Home : Juste causeSérie policière -Close to Home : Juste causeSérie policière -Chicago FireSérie dramatique -Les petits meurtres d'Agatha ChristieSérie policière -FalcoSérie de suspense -New York, section criminelleSérie policière -New York, unité spécialeSérie policière -New York, unité spécialeSérie policière -New York, section criminelleSérie policière -Chicago FireSérie dramatique -New York, section criminelleSérie policière -New York, section criminelleSérie policière -New York, section criminelleSérie policière -New York, unité spécialeSérie policière - \ No newline at end of file diff --git a/bin/epg-grabber/index.js b/bin/epg-grabber/index.js index c15d40eb..839e7b5a 100755 --- a/bin/epg-grabber/index.js +++ b/bin/epg-grabber/index.js @@ -62,7 +62,7 @@ async function main() { utils.writeToFile(config.output, xml) console.log(`File '${config.output}' successfully saved`) - console.log('Finish\r\n') + console.log('Finish') } main() diff --git a/bin/epg-grabber/utils.js b/bin/epg-grabber/utils.js index 6b7b0859..e1b99df0 100644 --- a/bin/epg-grabber/utils.js +++ b/bin/epg-grabber/utils.js @@ -18,7 +18,9 @@ utils.loadConfig = function (file) { if (!file) throw new Error('Path to [site].config.js is missing') console.log(`Loading '${file}'...`) - const config = require(path.resolve(process.cwd(), file)) + const configPath = path.resolve(process.cwd(), file) + const config = require(configPath) + const channelsPath = path.resolve(this.getDirectory(configPath), `${config.site}.channels.xml`) return Object.assign( {}, @@ -27,7 +29,8 @@ utils.loadConfig = function (file) { 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.130 Safari/537.36 Edg/79.0.309.71', days: 1, cookie: '', - lang: 'en' + lang: 'en', + channels: channelsPath }, config ) diff --git a/sites/programme-tv.net.channels.xml b/sites/programme-tv.net.channels.xml index 26d51628..30f66b0e 100755 --- a/sites/programme-tv.net.channels.xml +++ b/sites/programme-tv.net.channels.xml @@ -2,7 +2,7 @@ 13ème Rue - + ZDF \ No newline at end of file diff --git a/sites/programme-tv.net.config.js b/sites/programme-tv.net.config.js index 090ac4f9..96e8c843 100644 --- a/sites/programme-tv.net.config.js +++ b/sites/programme-tv.net.config.js @@ -1,17 +1,16 @@ const jsdom = require('jsdom') const { JSDOM } = jsdom +const parse = require('parse-duration') const dayjs = require('dayjs') -var customParseFormat = require('dayjs/plugin/customParseFormat') -var duration = require('dayjs/plugin/duration') +const customParseFormat = require('dayjs/plugin/customParseFormat') +const duration = require('dayjs/plugin/duration') dayjs.extend(duration) dayjs.extend(customParseFormat) -const { htmlToText } = require('html-to-text') -var parse = require('parse-duration') module.exports = { + site: 'programme-tv.net', lang: 'fr', output: '../../.gh-pages/guides/programme-tv.net.xml', - channels: '../../sites/programme-tv.net.channels.xml', url: function ({ date, channel }) { return `https://www.programme-tv.net/programme/chaine/${date.format('YYYY-MM-DD')}/programme-${ channel.site_id @@ -64,8 +63,6 @@ module.exports = { } }) - // console.log(programs) - return programs } } diff --git a/sites/tv.yandex.ru.config.js b/sites/tv.yandex.ru.config.js index d52d59ce..cea30179 100644 --- a/sites/tv.yandex.ru.config.js +++ b/sites/tv.yandex.ru.config.js @@ -2,7 +2,6 @@ module.exports = { site: 'tv.yandex.ru', lang: 'ru', output: '../../.gh-pages/guides/tv.yandex.ru.xml', - channels: '../../sites/tv.yandex.ru.channels.xml', cookie: 'yandexuid=8747786251615498142; Expires=Tue, 11 Mar 2031 21:29:02 GMT; Domain=yandex.ru; Path=/', url: function ({ date, channel }) { diff --git a/sites/tvguide.co.uk.config.js b/sites/tvguide.co.uk.config.js index c62d776f..e332fbee 100644 --- a/sites/tvguide.co.uk.config.js +++ b/sites/tvguide.co.uk.config.js @@ -1,14 +1,14 @@ const jsdom = require('jsdom') const { JSDOM } = jsdom +const { htmlToText } = require('html-to-text') const dayjs = require('dayjs') var customParseFormat = require('dayjs/plugin/customParseFormat') dayjs.extend(customParseFormat) -const { htmlToText } = require('html-to-text') module.exports = { + site: 'tvguide.co.uk', lang: 'en', output: '../../.gh-pages/guides/tvguide.co.uk.xml', - channels: '../../sites/tvguide.co.uk.channels.xml', url: function ({ date, channel }) { return `https://www.tvguide.co.uk/mobile/channellisting.asp?ch=${channel.site_id}` }, diff --git a/update.sh b/update.sh index 755ca0a4..48ef9b44 100755 --- a/update.sh +++ b/update.sh @@ -1,5 +1,5 @@ #!/bin/bash ./bin/epg-grabber/index.js --config=sites/tv.yandex.ru.config.js && \ -./bin/epg-grabber/index.js --config=sites/tvguide.co.uk.config.js && \ -./bin/epg-grabber/index.js --config=sites/programme-tv.net.config.js \ No newline at end of file +./bin/epg-grabber/index.js --config=sites/tvguide.co.uk.config.js +# ./bin/epg-grabber/index.js --config=sites/programme-tv.net.config.js \ No newline at end of file