iptv-checker 0.29.1 → 0.30.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.
@@ -62,8 +62,7 @@ let bar
62
62
  const stats = {
63
63
  total: 0,
64
64
  online: 0,
65
- offline: 0,
66
- duplicates: 0
65
+ failed: 0
67
66
  }
68
67
 
69
68
  const outputDir = options.output
@@ -74,8 +73,7 @@ try {
74
73
  }
75
74
 
76
75
  const onlinePlaylist = new Playlist(`${outputDir}/online.m3u`)
77
- const offlinePlaylist = new Playlist(`${outputDir}/offline.m3u`)
78
- const duplicatesPlaylist = new Playlist(`${outputDir}/duplicates.m3u`)
76
+ const failedPlaylist = new Playlist(`${outputDir}/failed.m3u`)
79
77
 
80
78
  init()
81
79
 
@@ -89,18 +87,12 @@ async function init() {
89
87
  const checked = await checker.checkPlaylist(stdin)
90
88
 
91
89
  stats.online = checked.items.filter(item => item.status.ok).length
92
- stats.offline = checked.items.filter(
93
- item => !item.status.ok && item.status.code !== `DUPLICATE`
94
- ).length
95
- stats.duplicates = checked.items.filter(
96
- item => !item.status.ok && item.status.code === `DUPLICATE`
97
- ).length
90
+ stats.failed = checked.items.filter(item => !item.status.ok).length
98
91
 
99
92
  const result = [
100
93
  `Total: ${stats.total}`,
101
94
  `Online: ${stats.online}`.green,
102
- `Offline: ${stats.offline}`.red,
103
- `Duplicates: ${stats.duplicates}`.yellow
95
+ `Failed: ${stats.failed}`.red
104
96
  ].join('\n')
105
97
 
106
98
  logger.info(`\n${result}`)
@@ -114,10 +106,8 @@ async function init() {
114
106
  function afterEach(item) {
115
107
  if (item.status.ok) {
116
108
  onlinePlaylist.append(item)
117
- } else if (item.status.code === `DUPLICATE`) {
118
- duplicatesPlaylist.append(item)
119
109
  } else {
120
- offlinePlaylist.append(item)
110
+ failedPlaylist.append(item)
121
111
  }
122
112
 
123
113
  if (!config.debug) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "iptv-checker",
3
- "version": "0.29.1",
3
+ "version": "0.30.0",
4
4
  "description": "Node.js CLI tool for checking links in IPTV playlists",
5
5
  "main": "src/index.js",
6
6
  "type": "module",
@@ -41,7 +41,7 @@
41
41
  "dateformat": "^5.0.3",
42
42
  "eslint": "^9.22.0",
43
43
  "get-stdin": "^9.0.0",
44
- "iptv-playlist-parser": "^0.14.0",
44
+ "iptv-playlist-parser": "^0.15.2",
45
45
  "msw": "^2.7.3",
46
46
  "normalize-url": "^8.0.1",
47
47
  "progress": "^2.0.3",
@@ -9,11 +9,11 @@ export class Playlist {
9
9
 
10
10
  append(item) {
11
11
  const message = item?.status?.message || null
12
- const lines = item.raw.split('\r\n')
12
+ const lines = item.raw.split(/\r?\n/)
13
13
  const extinf = lines[0]
14
14
 
15
15
  if (message) {
16
- lines[0] = `${extinf.trim()} (${message})`
16
+ lines[0] = `${extinf.trim()} [${message}]`
17
17
  }
18
18
 
19
19
  const output = `${lines.join('\r\n')}\r\n`
@@ -14,11 +14,6 @@ export class PlaylistLoader {
14
14
 
15
15
  client.interceptors.response.use(
16
16
  response => {
17
- const contentType = response.headers?.['content-type'] || ''
18
- if (!/mpegurl/.test(contentType)) {
19
- throw new Error('URL is not an M3U playlist file')
20
- }
21
-
22
17
  return response.data
23
18
  },
24
19
  () => {
package/tests/bin.test.js CHANGED
@@ -11,8 +11,7 @@ it(`should process a local playlist file`, () => {
11
11
  encoding: 'utf8'
12
12
  })
13
13
 
14
- expect(load('output/duplicates.m3u')).toBe(load('expected/output/simple/duplicates.m3u'))
15
- expect(load('output/offline.m3u')).toBe(load('expected/output/simple/offline.m3u'))
14
+ expect(load('output/failed.m3u')).toBe(load('expected/output/simple/failed.m3u'))
16
15
  expect(load('output/online.m3u')).toBe(load('expected/output/simple/online.m3u'))
17
16
  })
18
17
 
@@ -22,8 +21,7 @@ it(`should process playlist piped from stdin`, () => {
22
21
  { encoding: 'utf8' }
23
22
  )
24
23
 
25
- expect(load('output/duplicates.m3u')).toBe(load('expected/output/simple/duplicates.m3u'))
26
- expect(load('output/offline.m3u')).toBe(load('expected/output/simple/offline.m3u'))
24
+ expect(load('output/failed.m3u')).toBe(load('expected/output/simple/failed.m3u'))
27
25
  expect(load('output/online.m3u')).toBe(load('expected/output/simple/online.m3u'))
28
26
  })
29
27
 
@@ -32,8 +30,7 @@ it(`should process a playlist URL`, () => {
32
30
  encoding: 'utf8'
33
31
  })
34
32
 
35
- expect(load('output/duplicates.m3u')).toBe(load('expected/output/simple/duplicates.m3u'))
36
- expect(load('output/offline.m3u')).toBe(load('expected/output/simple/offline.m3u'))
33
+ expect(load('output/failed.m3u')).toBe(load('expected/output/simple/failed.m3u'))
37
34
  expect(load('output/online.m3u')).toBe(load('expected/output/simple/online.m3u'))
38
35
  })
39
36
 
@@ -43,8 +40,7 @@ it(`should respect proxy argument`, () => {
43
40
  { encoding: 'utf8' }
44
41
  )
45
42
 
46
- expect(load('output/duplicates.m3u')).toBe(load('expected/output/simple/duplicates.m3u'))
47
- expect(load('output/offline.m3u')).toBe(load('expected/output/simple/offline.m3u'))
43
+ expect(load('output/failed.m3u')).toBe(load('expected/output/simple/failed.m3u'))
48
44
  expect(load('output/online.m3u')).toBe(load('expected/output/simple/online.m3u'))
49
45
  })
50
46
 
@@ -62,12 +62,6 @@ describe('checkPlaylist', () => {
62
62
  )
63
63
  })
64
64
 
65
- it(`should throw on invalid fetched input data`, async () => {
66
- await expect(checker.checkPlaylist(`https://github.com`)).rejects.toThrow(
67
- 'URL is not an M3U playlist file'
68
- )
69
- })
70
-
71
65
  it(`should process a playlist with rtp link`, async () => {
72
66
  const path = 'tests/__data__/input/rtp.m3u'
73
67
  const results = await checker.checkPlaylist(path)