wip
This commit is contained in:
@@ -3,7 +3,8 @@
|
||||
const fs = require('fs')
|
||||
const path = require('path')
|
||||
const axios = require('axios')
|
||||
const axiosDelayAdapter = require('axios-delay').default
|
||||
const axiosCookieJarSupport = require('axios-cookiejar-support').default
|
||||
const tough = require('tough-cookie')
|
||||
const utils = require('./utils')
|
||||
const { Command } = require('commander')
|
||||
const program = new Command()
|
||||
@@ -14,6 +15,10 @@ dayjs.extend(utc)
|
||||
dayjs.extend(timezone)
|
||||
dayjs.tz.setDefault('UTC')
|
||||
|
||||
axiosCookieJarSupport(axios)
|
||||
|
||||
const cookieJar = new tough.CookieJar()
|
||||
|
||||
program
|
||||
.version('0.1.0', '-v, --version')
|
||||
.name('epg-grabber')
|
||||
@@ -29,8 +34,9 @@ const config = utils.parseConfig(options.config)
|
||||
const sites = utils.loadSites(options.sites)
|
||||
|
||||
const client = axios.create({
|
||||
adapter: axiosDelayAdapter(axios.defaults.adapter),
|
||||
headers: { 'User-Agent': config.userAgent }
|
||||
headers: { 'User-Agent': config.userAgent, Cookie: config.cookie },
|
||||
withCredentials: true,
|
||||
jar: cookieJar
|
||||
})
|
||||
|
||||
async function main() {
|
||||
|
||||
@@ -74,6 +74,7 @@ utils.parseConfig = function (configPath) {
|
||||
const days = this.getElementText('days', settings.elements)
|
||||
const userAgent = this.getElementText('user-agent', settings.elements)
|
||||
const timezone = this.getElementText('timezone', settings.elements)
|
||||
const cookie = this.getElementText('cookie', settings.elements)
|
||||
const channels = settings.elements
|
||||
.filter(el => el.name === 'channel')
|
||||
.map(el => {
|
||||
@@ -88,7 +89,8 @@ utils.parseConfig = function (configPath) {
|
||||
days,
|
||||
userAgent,
|
||||
timezone,
|
||||
channels
|
||||
channels,
|
||||
cookie
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user