mirror of
https://github.com/iptv-org/epg.git
synced 2025-05-10 00:50:09 -04:00
Update load-cluster.js
This commit is contained in:
parent
5ab469205c
commit
c034f001e8
2 changed files with 17 additions and 28 deletions
|
@ -46,30 +46,29 @@ async function main() {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
const programs = await grabber.grab(channel, config, async (data, err) => {
|
await grabber.grab(channel, config, async (data, err) => {
|
||||||
await db.channels.update({ _id: channel._id }, { $set: { logo: data.channel.logo } })
|
|
||||||
|
|
||||||
logger.info(
|
|
||||||
`[${i}/${total}] ${channel.site} - ${data.id} - ${data.date.format('MMM D, YYYY')} (${
|
|
||||||
data.programs.length
|
|
||||||
} programs)`
|
|
||||||
)
|
|
||||||
|
|
||||||
if (err) logger.error(err.message)
|
|
||||||
|
|
||||||
if (i < total) i++
|
|
||||||
})
|
|
||||||
|
|
||||||
await file.append(
|
await file.append(
|
||||||
clusterLog,
|
clusterLog,
|
||||||
JSON.stringify({
|
JSON.stringify({
|
||||||
_id: channel._id,
|
_id: channel._id,
|
||||||
site: channel.site,
|
site: channel.site,
|
||||||
country: channel.country,
|
country: channel.country,
|
||||||
|
logo: data.channel.logo,
|
||||||
gid: channel.gid,
|
gid: channel.gid,
|
||||||
programs
|
programs: data.programs
|
||||||
}) + '\n'
|
}) + '\n'
|
||||||
)
|
)
|
||||||
|
|
||||||
|
logger.info(
|
||||||
|
`[${i}/${total}] ${channel.site} - ${channel.xmltv_id} - ${data.date.format(
|
||||||
|
'MMM D, YYYY'
|
||||||
|
)} (${data.programs.length} programs)`
|
||||||
|
)
|
||||||
|
|
||||||
|
if (err) logger.error(err.message)
|
||||||
|
|
||||||
|
if (i < total) i++
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
db.channels.compact()
|
db.channels.compact()
|
||||||
|
|
|
@ -24,6 +24,7 @@ it('can load cluster', () => {
|
||||||
expect(output[0]).toMatchObject({
|
expect(output[0]).toMatchObject({
|
||||||
_id: '0Wefq0oMR3feCcuY',
|
_id: '0Wefq0oMR3feCcuY',
|
||||||
site: 'chaines-tv.orange.fr',
|
site: 'chaines-tv.orange.fr',
|
||||||
|
logo: 'https://example.com/logo.png',
|
||||||
country: 'US',
|
country: 'US',
|
||||||
gid: 'fr'
|
gid: 'fr'
|
||||||
})
|
})
|
||||||
|
@ -31,21 +32,10 @@ it('can load cluster', () => {
|
||||||
expect(output[1]).toMatchObject({
|
expect(output[1]).toMatchObject({
|
||||||
_id: '1XzrxNkSF2AQNBrT',
|
_id: '1XzrxNkSF2AQNBrT',
|
||||||
site: 'magticom.ge',
|
site: 'magticom.ge',
|
||||||
|
logo: 'https://www.magticom.ge/images/channels/MjAxOC8wOS8xMC9lZmJhNWU5Yy0yMmNiLTRkMTAtOWY5Ny01ODM0MzY0ZTg0MmEuanBn.jpg',
|
||||||
country: 'US',
|
country: 'US',
|
||||||
gid: 'ge'
|
gid: 'ge'
|
||||||
})
|
})
|
||||||
|
|
||||||
const database = content('tests/__data__/temp/database/channels.db')
|
|
||||||
|
|
||||||
expect(database[1]).toMatchObject({
|
|
||||||
_id: '0Wefq0oMR3feCcuY',
|
|
||||||
logo: 'https://example.com/logo.png'
|
|
||||||
})
|
|
||||||
|
|
||||||
expect(database[2]).toMatchObject({
|
|
||||||
_id: '1XzrxNkSF2AQNBrT',
|
|
||||||
logo: 'https://www.magticom.ge/images/channels/MjAxOC8wOS8xMC9lZmJhNWU5Yy0yMmNiLTRkMTAtOWY5Ny01ODM0MzY0ZTg0MmEuanBn.jpg'
|
|
||||||
})
|
|
||||||
})
|
})
|
||||||
|
|
||||||
function content(filepath) {
|
function content(filepath) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue