From 6280e93bbe8f91b93dde8dab2e0fc4f358b73e31 Mon Sep 17 00:00:00 2001 From: Aleksandr Statciuk Date: Thu, 6 Oct 2022 14:12:48 +0300 Subject: [PATCH 1/3] Update tests/__data__ --- tests/__data__/expected/guides/bh/chaines-tv.orange.fr.epg.json | 1 + tests/__data__/expected/guides/fr/chaines-tv.orange.fr.epg.json | 1 + tests/__data__/expected/guides/ge/magticom.ge.epg.json | 1 + tests/__data__/expected/guides/ru/yandex.ru.epg.json | 1 + tests/__data__/expected/guides/us/directv.com.epg.json | 1 + tests/__data__/expected/guides/zw/dstv.com.epg.json | 1 + 6 files changed, 6 insertions(+) create mode 100644 tests/__data__/expected/guides/bh/chaines-tv.orange.fr.epg.json create mode 100644 tests/__data__/expected/guides/fr/chaines-tv.orange.fr.epg.json create mode 100644 tests/__data__/expected/guides/ge/magticom.ge.epg.json create mode 100644 tests/__data__/expected/guides/ru/yandex.ru.epg.json create mode 100644 tests/__data__/expected/guides/us/directv.com.epg.json create mode 100644 tests/__data__/expected/guides/zw/dstv.com.epg.json diff --git a/tests/__data__/expected/guides/bh/chaines-tv.orange.fr.epg.json b/tests/__data__/expected/guides/bh/chaines-tv.orange.fr.epg.json new file mode 100644 index 00000000..fb005c3c --- /dev/null +++ b/tests/__data__/expected/guides/bh/chaines-tv.orange.fr.epg.json @@ -0,0 +1 @@ +{"channels":[{"id":"CNNInternationalEurope.us","name":"CNN International","site":"chaines-tv.orange.fr","site_id":"53","lang":"fr","logo":"https://i.imgur.com/2BXCg0x.jpg","url":"https://chaines-tv.orange.fr"}],"programs":[{"site":"chaines-tv.orange.fr","channel":"CNNInternationalEurope.us","titles":[{"value":"World Sport","lang":"fr"}],"sub_titles":[],"descriptions":[{"value":"Все о главных спортивных событиях мира. Обзоры самых важных спортивных событий, аналитика, мнения экспертов.","lang":"fr"}],"icon":{"src":""},"episodeNumbers":[],"date":null,"start":1641825900000,"stop":1641826800000,"urls":[],"ratings":[],"categories":[],"directors":[],"actors":[],"writers":[],"adapters":[],"producers":[],"composers":[],"editors":[],"presenters":[],"commentators":[],"guests":[]},{"site":"chaines-tv.orange.fr","channel":"CNNInternationalEurope.us","titles":[{"value":"Connecting Africa. 114-я серия","lang":"fr"}],"sub_titles":[],"descriptions":[{"value":"114-я серия. Проект, рассказывающий о людях и компаниях, которые совершают революцию в африканском бизнесе, и о тех, кто объединяет континент, выступая за свободную торговлю в Африке.","lang":"fr"}],"icon":{"src":""},"episodeNumbers":[],"date":null,"start":1641843900000,"stop":1641844800000,"urls":[],"ratings":[],"categories":[],"directors":[],"actors":[],"writers":[],"adapters":[],"producers":[],"composers":[],"editors":[],"presenters":[],"commentators":[],"guests":[]}]} \ No newline at end of file diff --git a/tests/__data__/expected/guides/fr/chaines-tv.orange.fr.epg.json b/tests/__data__/expected/guides/fr/chaines-tv.orange.fr.epg.json new file mode 100644 index 00000000..fb005c3c --- /dev/null +++ b/tests/__data__/expected/guides/fr/chaines-tv.orange.fr.epg.json @@ -0,0 +1 @@ +{"channels":[{"id":"CNNInternationalEurope.us","name":"CNN International","site":"chaines-tv.orange.fr","site_id":"53","lang":"fr","logo":"https://i.imgur.com/2BXCg0x.jpg","url":"https://chaines-tv.orange.fr"}],"programs":[{"site":"chaines-tv.orange.fr","channel":"CNNInternationalEurope.us","titles":[{"value":"World Sport","lang":"fr"}],"sub_titles":[],"descriptions":[{"value":"Все о главных спортивных событиях мира. Обзоры самых важных спортивных событий, аналитика, мнения экспертов.","lang":"fr"}],"icon":{"src":""},"episodeNumbers":[],"date":null,"start":1641825900000,"stop":1641826800000,"urls":[],"ratings":[],"categories":[],"directors":[],"actors":[],"writers":[],"adapters":[],"producers":[],"composers":[],"editors":[],"presenters":[],"commentators":[],"guests":[]},{"site":"chaines-tv.orange.fr","channel":"CNNInternationalEurope.us","titles":[{"value":"Connecting Africa. 114-я серия","lang":"fr"}],"sub_titles":[],"descriptions":[{"value":"114-я серия. Проект, рассказывающий о людях и компаниях, которые совершают революцию в африканском бизнесе, и о тех, кто объединяет континент, выступая за свободную торговлю в Африке.","lang":"fr"}],"icon":{"src":""},"episodeNumbers":[],"date":null,"start":1641843900000,"stop":1641844800000,"urls":[],"ratings":[],"categories":[],"directors":[],"actors":[],"writers":[],"adapters":[],"producers":[],"composers":[],"editors":[],"presenters":[],"commentators":[],"guests":[]}]} \ No newline at end of file diff --git a/tests/__data__/expected/guides/ge/magticom.ge.epg.json b/tests/__data__/expected/guides/ge/magticom.ge.epg.json new file mode 100644 index 00000000..a418f6d7 --- /dev/null +++ b/tests/__data__/expected/guides/ge/magticom.ge.epg.json @@ -0,0 +1 @@ +{"channels":[{"id":"CNNInternationalEurope.us","name":"CNN International","site":"magticom.ge","site_id":"140","lang":"ru","logo":"https://i.imgur.com/2BXCg0x.jpg","url":"https://magticom.ge"}],"programs":[]} \ No newline at end of file diff --git a/tests/__data__/expected/guides/ru/yandex.ru.epg.json b/tests/__data__/expected/guides/ru/yandex.ru.epg.json new file mode 100644 index 00000000..e74c7fac --- /dev/null +++ b/tests/__data__/expected/guides/ru/yandex.ru.epg.json @@ -0,0 +1 @@ +{"channels":[],"programs":[]} \ No newline at end of file diff --git a/tests/__data__/expected/guides/us/directv.com.epg.json b/tests/__data__/expected/guides/us/directv.com.epg.json new file mode 100644 index 00000000..e74c7fac --- /dev/null +++ b/tests/__data__/expected/guides/us/directv.com.epg.json @@ -0,0 +1 @@ +{"channels":[],"programs":[]} \ No newline at end of file diff --git a/tests/__data__/expected/guides/zw/dstv.com.epg.json b/tests/__data__/expected/guides/zw/dstv.com.epg.json new file mode 100644 index 00000000..e52810b4 --- /dev/null +++ b/tests/__data__/expected/guides/zw/dstv.com.epg.json @@ -0,0 +1 @@ +{"channels":[{"id":"MNetMovies2.za","name":"M-Net Movies 2","site":"dstv.com","site_id":"404a052b-3dea-4cac-a19c-de9a7d6f191d#MAP","lang":"en","logo":"https://rndcdn.dstv.com/dstvcms/2020/08/31/M-Net_Movies_2_Logo_4-3_lightbackground_xlrg.png","url":"https://dstv.com"}],"programs":[{"site":"dstv.com","channel":"MNetMovies2.za","titles":[{"value":"Robin Hood","lang":"en"}],"sub_titles":[],"descriptions":[],"icon":{"src":""},"episodeNumbers":[{"system":"xmltv_ns","value":"8.256.0/1"},{"system":"onscreen","value":"S09E257"}],"date":null,"start":1641822300000,"stop":1641829200000,"urls":[],"ratings":[],"categories":[],"directors":[],"actors":[],"writers":[],"adapters":[],"producers":[],"composers":[],"editors":[],"presenters":[],"commentators":[],"guests":[]}]} \ No newline at end of file From 0afc0a864adeff5f1699660cee9ab58aeee06fa9 Mon Sep 17 00:00:00 2001 From: Aleksandr Statciuk Date: Thu, 6 Oct 2022 14:12:53 +0300 Subject: [PATCH 2/3] Update update.test.js --- tests/commands/guides/update.test.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tests/commands/guides/update.test.js b/tests/commands/guides/update.test.js index f85848f9..7b1049aa 100644 --- a/tests/commands/guides/update.test.js +++ b/tests/commands/guides/update.test.js @@ -28,6 +28,14 @@ it('can generate /guides', () => { compressed.forEach(filepath => { expect(content(`output/${filepath}`), filepath).toBe(content(`expected/${filepath}`)) }) + + const json = glob + .sync('tests/__data__/expected/guides/**/*.json') + .map(f => f.replace('tests/__data__/expected/', '')) + + json.forEach(filepath => { + expect(content(`output/${filepath}`), filepath).toBe(content(`expected/${filepath}`)) + }) }) it('will terminate process if programs not found', () => { From 0b25372b13bc0638e0407b1372fe1d8cbfac2c69 Mon Sep 17 00:00:00 2001 From: Aleksandr Statciuk Date: Thu, 6 Oct 2022 14:13:50 +0300 Subject: [PATCH 3/3] Update update.js --- scripts/commands/guides/update.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/scripts/commands/guides/update.js b/scripts/commands/guides/update.js index fa9425e8..300e00d7 100644 --- a/scripts/commands/guides/update.js +++ b/scripts/commands/guides/update.js @@ -32,11 +32,13 @@ async function main() { channels = Object.values(channels) channels = _.sortBy(channels, 'id') - const filepath = `${PUBLIC_DIR}/guides/${key}.epg.xml.gz` - logger.info(`Creating "${filepath}"...`) + const gzFilepath = `${PUBLIC_DIR}/guides/${key}.epg.xml.gz` + const jsonFilepath = `${PUBLIC_DIR}/guides/${key}.epg.json` + logger.info(`Creating "${gzFilepath}"...`) const xmltv = generateXMLTV({ channels, programs, date: CURR_DATE }) const compressed = await zip.compress(xmltv) - await file.create(filepath, compressed) + await file.create(gzFilepath, compressed) + await file.create(jsonFilepath, JSON.stringify({ channels, programs })) } if (!total) {