Update load-cluster.js

This commit is contained in:
Aleksandr Statciuk 2022-01-21 18:00:33 +03:00
parent af69100bc5
commit 4ec3e35845
3 changed files with 17 additions and 23 deletions

View File

@ -47,18 +47,6 @@ async function main() {
})
await grabber.grab(channel, config, async (data, err) => {
await file.append(
clusterLog,
JSON.stringify({
_id: channel._id,
site: channel.site,
country: channel.country,
logo: data.channel.logo,
gid: channel.gid,
programs: data.programs
}) + '\n'
)
logger.info(
`[${i}/${total}] ${channel.site} - ${channel.xmltv_id} - ${data.date.format(
'MMM D, YYYY'
@ -67,6 +55,15 @@ async function main() {
if (err) logger.error(err.message)
const result = {
_id: channel._id,
logo: data.channel.logo,
programs: data.programs,
error: err ? err.message : null
}
await file.append(clusterLog, JSON.stringify(result) + '\n')
if (i < total) i++
})
}

View File

@ -1,4 +1,4 @@
{"lang":"en","xmltv_id":"BravoEast.us","site_id":"237","logo":"https://www.directv.com/images/logos/channels/dark/large/579.png","name":"Bravo East","site":"directv.com","channelsPath":"sites/directv.com/directv.com_us.channels.xml","configPath":"sites/directv.com/directv.com.config.js","gid":"us","cluster_id":84,"country":"US","_id":"00AluKCrCnfgrl8W"}
{"lang":"fr","country":"US","xmltv_id":"CNNInternationalEurope.us","site_id":"53","logo":null,"name":"CNN International Europe","site":"chaines-tv.orange.fr","channelsPath":"sites/chaines-tv.orange.fr/chaines-tv.orange.fr_fr.channels.xml","configPath":"tests/__data__/input/sites/example.com.config.js","gid":"fr","cluster_id":1,"_id":"0Wefq0oMR3feCcuY"}
{"lang":"ru","country":"US","xmltv_id":"CNNInternationalEurope.us","site_id":"140","logo":"https://www.magticom.ge/images/channels/MjAxOC8wOS8xMC9lZmJhNWU5Yy0yMmNiLTRkMTAtOWY5Ny01ODM0MzY0ZTg0MmEuanBn.jpg","name":"CNN Int","site":"magticom.ge","channelsPath":"sites/magticom.ge/magticom.ge_ge.channels.xml","configPath":"tests/__data__/input/sites/example.com.config.js","gid":"ge","cluster_id":1,"_id":"1XzrxNkSF2AQNBrT"}
{"lang":"en","country":"ZA","xmltv_id":"MNetMovies2.za","site_id":"404a052b-3dea-4cac-a19c-de9a7d6f191d#MAP","logo":"https://rndcdn.dstv.com/dstvcms/2020/08/31/M-Net_Movies_2_Logo_4-3_lightbackground_xlrg.png","name":"M-Net Movies 2","site":"dstv.com","channelsPath":"sites/dstv.com/dstv.com_zw.channels.xml","configPath":"sites/dstv.com/dstv.com.config.js","gid":"zw","cluster_id":120,"_id":"1lnhXpN7g0ER5XwN"}
{"lang":"en","xmltv_id":"BravoEast.us","site_id":"237","logo":"https://www.directv.com/images/logos/channels/dark/large/579.png","name":"Bravo East","site":"directv.com","channelsPath":"sites/directv.com/directv.com_us.channels.xml","configPath":"sites/directv.com/directv.com.config.js","groups":["us"],"cluster_id":84,"country":"US","_id":"00AluKCrCnfgrl8W"}
{"lang":"fr","country":"US","xmltv_id":"CNNInternationalEurope.us","site_id":"53","logo":null,"name":"CNN International Europe","site":"chaines-tv.orange.fr","channelsPath":"sites/chaines-tv.orange.fr/chaines-tv.orange.fr_fr.channels.xml","configPath":"tests/__data__/input/sites/example.com.config.js","groups":["fr"],"cluster_id":1,"_id":"0Wefq0oMR3feCcuY"}
{"lang":"ru","country":"US","xmltv_id":"CNNInternationalEurope.us","site_id":"140","logo":"https://www.magticom.ge/images/channels/MjAxOC8wOS8xMC9lZmJhNWU5Yy0yMmNiLTRkMTAtOWY5Ny01ODM0MzY0ZTg0MmEuanBn.jpg","name":"CNN Int","site":"magticom.ge","channelsPath":"sites/magticom.ge/magticom.ge_ge.channels.xml","configPath":"tests/__data__/input/sites/example.com.config.js","groups":["ge"],"cluster_id":1,"_id":"1XzrxNkSF2AQNBrT"}
{"lang":"en","country":"ZA","xmltv_id":"MNetMovies2.za","site_id":"404a052b-3dea-4cac-a19c-de9a7d6f191d#MAP","logo":"https://rndcdn.dstv.com/dstvcms/2020/08/31/M-Net_Movies_2_Logo_4-3_lightbackground_xlrg.png","name":"M-Net Movies 2","site":"dstv.com","channelsPath":"sites/dstv.com/dstv.com_zw.channels.xml","configPath":"sites/dstv.com/dstv.com.config.js","groups":["zw"],"cluster_id":120,"_id":"1lnhXpN7g0ER5XwN"}

View File

@ -23,18 +23,15 @@ it('can load cluster', () => {
expect(output[0]).toMatchObject({
_id: '0Wefq0oMR3feCcuY',
site: 'chaines-tv.orange.fr',
logo: 'https://example.com/logo.png',
country: 'US',
gid: 'fr'
error: null
})
expect(Object.keys(output[0]).sort()).toEqual(['_id', 'error', 'logo', 'programs'])
expect(output[1]).toMatchObject({
_id: '1XzrxNkSF2AQNBrT',
site: 'magticom.ge',
logo: 'https://www.magticom.ge/images/channels/MjAxOC8wOS8xMC9lZmJhNWU5Yy0yMmNiLTRkMTAtOWY5Ny01ODM0MzY0ZTg0MmEuanBn.jpg',
country: 'US',
gid: 'ge'
logo: 'https://www.magticom.ge/images/channels/MjAxOC8wOS8xMC9lZmJhNWU5Yy0yMmNiLTRkMTAtOWY5Ny01ODM0MzY0ZTg0MmEuanBn.jpg'
})
})