mirror of
https://github.com/iptv-org/epg.git
synced 2025-05-11 01:20:08 -04:00
Merge pull request #397 from iptv-org/add-missing-logo
Add missing logos
This commit is contained in:
commit
c85aaaa631
4 changed files with 36 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 } })
|
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(
|
logger.info(
|
||||||
`[${i}/${total}] ${channel.site} - ${data.id} - ${data.date.format('MMM D, YYYY')} (${
|
`[${i}/${total}] ${channel.site} - ${channel.xmltv_id} - ${data.date.format(
|
||||||
data.programs.length
|
'MMM D, YYYY'
|
||||||
} programs)`
|
)} (${data.programs.length} programs)`
|
||||||
)
|
)
|
||||||
|
|
||||||
if (err) logger.error(err.message)
|
if (err) logger.error(err.message)
|
||||||
|
|
||||||
if (i < total) i++
|
if (i < total) i++
|
||||||
})
|
})
|
||||||
|
|
||||||
await file.append(
|
|
||||||
clusterLog,
|
|
||||||
JSON.stringify({
|
|
||||||
_id: channel._id,
|
|
||||||
site: channel.site,
|
|
||||||
country: channel.country,
|
|
||||||
gid: channel.gid,
|
|
||||||
programs
|
|
||||||
}) + '\n'
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
db.channels.compact()
|
db.channels.compact()
|
||||||
|
|
|
@ -4,6 +4,8 @@ const _ = require('lodash')
|
||||||
const LOGS_DIR = process.env.LOGS_DIR || 'scripts/logs'
|
const LOGS_DIR = process.env.LOGS_DIR || 'scripts/logs'
|
||||||
|
|
||||||
async function main() {
|
async function main() {
|
||||||
|
await db.channels.load()
|
||||||
|
|
||||||
await db.programs.load()
|
await db.programs.load()
|
||||||
await db.programs.reset()
|
await db.programs.reset()
|
||||||
const files = await file.list(`${LOGS_DIR}/load-cluster/cluster_*.log`)
|
const files = await file.list(`${LOGS_DIR}/load-cluster/cluster_*.log`)
|
||||||
|
@ -11,6 +13,8 @@ async function main() {
|
||||||
logger.info(`Parsing "${filepath}"...`)
|
logger.info(`Parsing "${filepath}"...`)
|
||||||
const results = await parser.parseLogs(filepath)
|
const results = await parser.parseLogs(filepath)
|
||||||
for (const result of results) {
|
for (const result of results) {
|
||||||
|
await db.channels.update({ _id: result._id }, { $set: { logo: result.logo } })
|
||||||
|
|
||||||
const programs = result.programs.map(program => {
|
const programs = result.programs.map(program => {
|
||||||
program.site = result.site
|
program.site = result.site
|
||||||
program.country = result.country
|
program.country = result.country
|
||||||
|
@ -22,6 +26,8 @@ async function main() {
|
||||||
await db.programs.insert(programs)
|
await db.programs.insert(programs)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
await db.channels.compact()
|
||||||
}
|
}
|
||||||
|
|
||||||
main()
|
main()
|
||||||
|
|
|
@ -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) {
|
||||||
|
|
|
@ -5,6 +5,12 @@ const { execSync } = require('child_process')
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
fs.rmdirSync('tests/__data__/output', { recursive: true })
|
fs.rmdirSync('tests/__data__/output', { recursive: true })
|
||||||
fs.mkdirSync('tests/__data__/output')
|
fs.mkdirSync('tests/__data__/output')
|
||||||
|
fs.mkdirSync('tests/__data__/output/database', { recursive: true })
|
||||||
|
|
||||||
|
fs.copyFileSync(
|
||||||
|
'tests/__data__/input/database/channels.db',
|
||||||
|
'tests/__data__/output/database/channels.db'
|
||||||
|
)
|
||||||
|
|
||||||
execSync(
|
execSync(
|
||||||
'DB_DIR=tests/__data__/output/database LOGS_DIR=tests/__data__/input/logs node scripts/commands/save-results.js',
|
'DB_DIR=tests/__data__/output/database LOGS_DIR=tests/__data__/input/logs node scripts/commands/save-results.js',
|
||||||
|
@ -29,6 +35,13 @@ it('can save results to database', () => {
|
||||||
'stop',
|
'stop',
|
||||||
'title'
|
'title'
|
||||||
])
|
])
|
||||||
|
|
||||||
|
const database = content('tests/__data__/output/database/channels.db')
|
||||||
|
|
||||||
|
expect(database[1]).toMatchObject({
|
||||||
|
_id: '0Wefq0oMR3feCcuY',
|
||||||
|
logo: 'https://example.com/logo.png'
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
function content(filepath) {
|
function content(filepath) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue