epg-grabber 0.34.0 → 0.35.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "epg-grabber",
3
- "version": "0.34.0",
3
+ "version": "0.35.0",
4
4
  "description": "Node.js CLI tool for grabbing EPG from different sites",
5
5
  "main": "src/index.js",
6
6
  "preferGlobal": true,
@@ -28,9 +28,8 @@
28
28
  "node": ">=10.0.0"
29
29
  },
30
30
  "dependencies": {
31
- "axios": "^0.21.1",
31
+ "axios": "^1.6.1",
32
32
  "axios-cache-interceptor": "^0.10.3",
33
- "axios-cookiejar-support": "^1.0.1",
34
33
  "axios-mock-adapter": "^1.20.0",
35
34
  "commander": "^7.1.0",
36
35
  "curl-generator": "^0.2.0",
@@ -39,9 +38,10 @@
39
38
  "epg-parser": "^0.1.6",
40
39
  "fs-extra": "^11.1.1",
41
40
  "glob": "^7.1.6",
41
+ "http-cookie-agent": "^5.0.4",
42
42
  "lodash": "^4.17.21",
43
43
  "node-gzip": "^1.1.2",
44
- "tough-cookie": "^4.0.0",
44
+ "tough-cookie": "^4.1.3",
45
45
  "winston": "^3.3.3",
46
46
  "xml-js": "^1.6.11"
47
47
  },
@@ -50,7 +50,7 @@
50
50
  "@babel/preset-env": "^7.13.12",
51
51
  "babel-jest": "^26.6.3",
52
52
  "eslint": "^7.22.0",
53
- "jest": "^26.6.3",
53
+ "jest": "^29.7.0",
54
54
  "jest-mock-axios": "^4.4.1"
55
55
  },
56
56
  "jest": {
package/src/client.js CHANGED
@@ -1,10 +1,11 @@
1
1
  const { CurlGenerator } = require('curl-generator')
2
- const axios = require('axios').default
3
- const axiosCookieJarSupport = require('axios-cookiejar-support').default
2
+ const { default: axios } = require('axios')
3
+ const { CookieJar } = require('tough-cookie')
4
4
  const { setupCache } = require('axios-cache-interceptor')
5
5
  const { isObject, isPromise } = require('./utils')
6
+ const { HttpCookieAgent, HttpsCookieAgent } = require('http-cookie-agent/http')
6
7
 
7
- axiosCookieJarSupport(axios)
8
+ const jar = new CookieJar()
8
9
 
9
10
  module.exports.create = create
10
11
  module.exports.buildRequest = buildRequest
@@ -13,14 +14,17 @@ module.exports.parseResponse = parseResponse
13
14
  let timeout
14
15
 
15
16
  function create(config) {
16
- const client = setupCache(
17
- axios.create({
18
- ignoreCookieErrors: true,
19
- headers: {
20
- 'User-Agent':
21
- 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.130 Safari/537.36 Edg/79.0.309.71'
22
- }
23
- })
17
+ const client = setupCookie(
18
+ setupCache(
19
+ axios.create({
20
+ jar,
21
+ ignoreCookieErrors: true,
22
+ headers: {
23
+ 'User-Agent':
24
+ 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.130 Safari/537.36 Edg/79.0.309.71'
25
+ }
26
+ })
27
+ )
24
28
  )
25
29
 
26
30
  client.interceptors.request.use(
@@ -136,3 +140,44 @@ async function getRequestUrl({ channel, date, config }) {
136
140
  }
137
141
  return config.url
138
142
  }
143
+
144
+ const AGENT_CREATED_BY_AXIOS_COOKIEJAR_SUPPORT = Symbol('AGENT_CREATED_BY_AXIOS_COOKIEJAR_SUPPORT')
145
+
146
+ function requestInterceptor(config) {
147
+ if (!config.jar) {
148
+ return config
149
+ }
150
+
151
+ config.httpAgent = new HttpCookieAgent({ cookies: { jar: config.jar } })
152
+ Object.defineProperty(config.httpAgent, AGENT_CREATED_BY_AXIOS_COOKIEJAR_SUPPORT, {
153
+ configurable: false,
154
+ enumerable: false,
155
+ value: true,
156
+ writable: false
157
+ })
158
+
159
+ config.httpsAgent = new HttpsCookieAgent({ cookies: { jar: config.jar } })
160
+ Object.defineProperty(config.httpsAgent, AGENT_CREATED_BY_AXIOS_COOKIEJAR_SUPPORT, {
161
+ configurable: false,
162
+ enumerable: false,
163
+ value: true,
164
+ writable: false
165
+ })
166
+
167
+ return config
168
+ }
169
+
170
+ function setupCookie(axios) {
171
+ axios.interceptors.request.use(requestInterceptor)
172
+
173
+ if ('create' in axios) {
174
+ const create = axios.create
175
+ axios.create = (...args) => {
176
+ const instance = create.apply(axios, args)
177
+ instance.interceptors.request.use(requestInterceptor)
178
+ return instance
179
+ }
180
+ }
181
+
182
+ return axios
183
+ }
@@ -1,4 +1,4 @@
1
- <?xml version="1.0" encoding="UTF-8" ?><tv date="20230930">
1
+ <?xml version="1.0" encoding="UTF-8" ?><tv date="20231116">
2
2
  <channel id="1TV.com"><display-name>1 TV</display-name><icon src="https://example.com/logos/1TV.png"/><url>https://example.com</url></channel>
3
3
  <channel id="2TV.com"><display-name>2 TV</display-name><icon src="http://example.com/logos/1TV.png?x=шеллы&amp;sid=777"/><url>https://example.com</url></channel>
4
4
  <channel id="3TV.com"><display-name>3 TV</display-name><icon src="http://example.com/logos/1TV.png?x=шеллы&amp;sid=777"/><url>https://example2.com</url></channel>