Add support for ignore option
This commit is contained in:
parent
24cf5edc15
commit
9a4b18143d
|
@ -94,6 +94,7 @@ module.exports = {
|
|||
lang: 'fr', // default language for all programs (default: 'en')
|
||||
days: 3, // number of days for which to grab the program (default: 1)
|
||||
delay: 5000, // delay between requests (default: 3000)
|
||||
ignore: true, // skip all channels during request (default: false)
|
||||
|
||||
request: { // request options (details: https://github.com/axios/axios#request-config)
|
||||
|
||||
|
|
|
@ -14,6 +14,12 @@ module.exports = {
|
|||
|
||||
let programs = []
|
||||
for (let item of queue) {
|
||||
if (config.ignore) {
|
||||
item.programs = []
|
||||
cb(item, new Error('Skipped'))
|
||||
continue
|
||||
}
|
||||
|
||||
await utils
|
||||
.buildRequest(item, config)
|
||||
.then(request => utils.fetchData(request))
|
||||
|
|
|
@ -71,3 +71,23 @@ it('can grab single channel programs', done => {
|
|||
done()
|
||||
})
|
||||
})
|
||||
|
||||
it('return "Skipped" error if ignore option in config is true', done => {
|
||||
const config = {
|
||||
site: 'example.com',
|
||||
ignore: true,
|
||||
url: `http://example.com/20210319/1tv.json`,
|
||||
parser: () => []
|
||||
}
|
||||
const channel = {
|
||||
site: 'example.com',
|
||||
site_id: 'cnn',
|
||||
xmltv_id: 'CNN.us',
|
||||
lang: 'en',
|
||||
name: 'CNN'
|
||||
}
|
||||
grabber.grab(channel, config, (data, err) => {
|
||||
expect(err.message).toBe('Skipped')
|
||||
done()
|
||||
})
|
||||
})
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
module.exports = {
|
||||
site: 'example.com',
|
||||
ignore: true,
|
||||
channels: 'example.com.channels.xml',
|
||||
output: 'tests/output/guide.xml',
|
||||
url: () => 'http://example.com/20210319/1tv.json',
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
module.exports = {
|
||||
site: 'example.com',
|
||||
ignore: true,
|
||||
url: 'http://example.com/20210319/1tv.json',
|
||||
parser: () => []
|
||||
}
|
||||
|
|
|
@ -7,6 +7,7 @@ it('can load valid config.js', () => {
|
|||
const config = utils.loadConfig(require(path.resolve('./tests/input/example.com.config.js')))
|
||||
expect(config).toMatchObject({
|
||||
days: 1,
|
||||
ignore: true,
|
||||
delay: 3000,
|
||||
lang: 'en',
|
||||
site: 'example.com'
|
||||
|
|
Loading…
Reference in New Issue