mirror of
https://github.com/iptv-org/iptv
synced 2026-09-06 03:50:47 -04:00
Merge remote-tracking branch 'origin/master' into pr/49871
# Conflicts: # tests/commands/playlist/format.test.ts
This commit is contained in:
@@ -1,15 +1,25 @@
|
||||
[
|
||||
{
|
||||
"channel": null,
|
||||
"feed": null,
|
||||
"title": "Daawah TV",
|
||||
{
|
||||
"channel": null,
|
||||
"feed": null,
|
||||
"title": "Daawah TV",
|
||||
"url": "http://51.15.246.58:8081/daawahtv/daawahtv2/playlist.m3u8",
|
||||
"referrer": null,
|
||||
"user_agent": null,
|
||||
"quality": null,
|
||||
"label": null
|
||||
},
|
||||
{
|
||||
"quality": null,
|
||||
"label": null
|
||||
},
|
||||
{
|
||||
"channel": null,
|
||||
"feed": null,
|
||||
"title": "Example (720|)",
|
||||
"url": "https://example.com/live.m3u8",
|
||||
"referrer": null,
|
||||
"user_agent": null,
|
||||
"quality": null,
|
||||
"label": null
|
||||
},
|
||||
{
|
||||
"channel": null,
|
||||
"feed": null,
|
||||
"title": "Andorra TV",
|
||||
@@ -79,4 +89,4 @@
|
||||
"quality": "720p",
|
||||
"label": null
|
||||
}
|
||||
]
|
||||
]
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
const dns = require('node:dns')
|
||||
|
||||
dns.lookup = (_hostname, callback) => callback(new Error('offline'))
|
||||
@@ -1,9 +1,11 @@
|
||||
#EXTM3U
|
||||
#EXTINF:-1 tvg-id="LDPRTV.ru",ЛДПР ТВ (1080p)
|
||||
http://46.46.143.222:1935/live/mp4:ldpr.stream/blocked.m3u8
|
||||
#EXTINF:-1 tvg-id="VisitXTV.nl",Visit-X TV
|
||||
https://stream.visit-x.tv/vxtv/ngrp:live_all/30fps.m3u8
|
||||
#EXTINF:-1 tvg-id="" user-agent="Mozilla/5.0 (iPhone; CPU iPhone OS 12_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148",Andorra TV (720p) [Not 24/7]
|
||||
#EXTINF:-1 tvg-id="VisitXTV.nl",Visit-X TV
|
||||
https://stream.visit-x.tv/vxtv/ngrp:live_all/30fps.m3u8
|
||||
#EXTINF:-1 tvg-id="",Example (720|)
|
||||
https://example.com/live.m3u8
|
||||
#EXTINF:-1 tvg-id="" user-agent="Mozilla/5.0 (iPhone; CPU iPhone OS 12_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148",Andorra TV (720p) [Not 24/7]
|
||||
#EXTVLCOPT:http-referrer=http://imn.iq
|
||||
#EXTVLCOPT:http-user-agent=Mozilla/5.0 (iPhone; CPU iPhone OS 12_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148
|
||||
http://1111296894.rsc.cdn77.org/LS-ATL-54548-6/index2.m3u8
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
#EXTM3U
|
||||
#EXTINF:-1 tvg-id="",Example (720p)
|
||||
http://example.com/a%ZZ
|
||||
@@ -0,0 +1,3 @@
|
||||
#EXTM3U
|
||||
#EXTINF:-1,Example
|
||||
https://example.com/live.m3u8
|
||||
@@ -1,10 +1,14 @@
|
||||
import issues from '../../__data__/input/issues'
|
||||
import { pathToFileURL } from 'node:url'
|
||||
import { execSync } from 'child_process'
|
||||
import { execFileSync } from 'child_process'
|
||||
import * as fs from 'fs-extra'
|
||||
|
||||
const ENV_VAR =
|
||||
'cross-env DATA_DIR=tests/__data__/input/data STREAMS_DIR=tests/__data__/output/streams LOGS_DIR=tests/__data__/output/logs'
|
||||
const ENV = {
|
||||
...process.env,
|
||||
DATA_DIR: 'tests/__data__/input/data',
|
||||
STREAMS_DIR: 'tests/__data__/output/streams',
|
||||
LOGS_DIR: 'tests/__data__/output/logs'
|
||||
}
|
||||
|
||||
beforeEach(() => {
|
||||
fs.emptyDirSync('tests/__data__/output')
|
||||
@@ -14,11 +18,10 @@ beforeEach(() => {
|
||||
describe('issue:validate', () => {
|
||||
it('can handle streams:add request', () => {
|
||||
const body = issues.find(issue => issue.number === 14179)?.body
|
||||
const cmd = `${ENV_VAR} npm run issue:validate --- --body="${body}" --labels="approved,streams:add"`
|
||||
|
||||
try {
|
||||
const stdout = execSync(cmd, { encoding: 'utf8' })
|
||||
if (process.env.DEBUG === 'true') console.log(cmd, stdout)
|
||||
const stdout = runIssueValidate(body, 'approved,streams:add')
|
||||
if (process.env.DEBUG === 'true') console.log(stdout)
|
||||
throw new Error('Failed')
|
||||
} catch {
|
||||
expect(content('tests/__data__/output/logs/errors.txt')).toBe(
|
||||
@@ -29,11 +32,10 @@ describe('issue:validate', () => {
|
||||
|
||||
it('can handle streams:remove request', () => {
|
||||
const body = issues.find(issue => issue.number === 14150)?.body
|
||||
const cmd = `${ENV_VAR} npm run issue:validate --- --body="${body}" --labels="approved,streams:remove"`
|
||||
|
||||
try {
|
||||
const stdout = execSync(cmd, { encoding: 'utf8' })
|
||||
if (process.env.DEBUG === 'true') console.log(cmd, stdout)
|
||||
const stdout = runIssueValidate(body, 'approved,streams:remove')
|
||||
if (process.env.DEBUG === 'true') console.log(stdout)
|
||||
throw new Error('Failed')
|
||||
} catch {
|
||||
expect(content('tests/__data__/output/logs/errors.txt')).toBe(
|
||||
@@ -44,11 +46,10 @@ describe('issue:validate', () => {
|
||||
|
||||
it('can handle streams:edit request', () => {
|
||||
const body = issues.find(issue => issue.number === 39097)?.body
|
||||
const cmd = `${ENV_VAR} npm run issue:validate --- --body="${body}" --labels="approved,streams:edit"`
|
||||
|
||||
try {
|
||||
const stdout = execSync(cmd, { encoding: 'utf8' })
|
||||
if (process.env.DEBUG === 'true') console.log(cmd, stdout)
|
||||
const stdout = runIssueValidate(body, 'approved,streams:edit')
|
||||
if (process.env.DEBUG === 'true') console.log(stdout)
|
||||
throw new Error('Failed')
|
||||
} catch {
|
||||
expect(content('tests/__data__/output/logs/errors.txt')).toBe(
|
||||
@@ -58,6 +59,22 @@ describe('issue:validate', () => {
|
||||
})
|
||||
})
|
||||
|
||||
function runIssueValidate(body: string | undefined, labels: string) {
|
||||
return execFileSync(
|
||||
process.execPath,
|
||||
[
|
||||
'--import',
|
||||
'tsx',
|
||||
'scripts/commands/issue/validate.ts',
|
||||
'--body',
|
||||
`${body}`,
|
||||
'--labels',
|
||||
labels
|
||||
],
|
||||
{ encoding: 'utf8', env: ENV }
|
||||
)
|
||||
}
|
||||
|
||||
function content(filepath: string) {
|
||||
return fs.readFileSync(pathToFileURL(filepath), { encoding: 'utf8' })
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@ describe('playlist:export', () => {
|
||||
content('tests/__data__/expected/playlist_export/.api/streams.json')
|
||||
)
|
||||
})
|
||||
|
||||
})
|
||||
|
||||
function content(filepath: string) {
|
||||
|
||||
@@ -30,6 +30,7 @@ describe('playlist:format', () => {
|
||||
)
|
||||
})
|
||||
})
|
||||
|
||||
it('formats playlists in nested directories', () => {
|
||||
const cmd = `${ENV_VAR} npm run playlist:format`
|
||||
execSync(cmd, { encoding: 'utf8' })
|
||||
@@ -39,6 +40,19 @@ describe('playlist:format', () => {
|
||||
expect(output).toContain(',Zulu (720p)')
|
||||
expect(output.indexOf(',Alpha (720p)')).toBeLessThan(output.indexOf(',Zulu (720p)'))
|
||||
})
|
||||
|
||||
it('keeps links with malformed percent escapes', () => {
|
||||
fs.emptyDirSync('tests/__data__/output')
|
||||
fs.copySync('tests/__data__/input/playlist_normalize', 'tests/__data__/output/streams')
|
||||
|
||||
const cmd =
|
||||
'cross-env STREAMS_DIR=tests/__data__/output/streams DATA_DIR=tests/__data__/input/data npm run playlist:format'
|
||||
execSync(cmd, { encoding: 'utf8' })
|
||||
|
||||
expect(content('tests/__data__/output/streams/bad_encoding.m3u')).toContain(
|
||||
'http://example.com/a%ZZ'
|
||||
)
|
||||
})
|
||||
})
|
||||
|
||||
function content(filepath: string) {
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import child_process from 'node:child_process'
|
||||
import child_process, { execSync } from 'node:child_process'
|
||||
import path from 'node:path'
|
||||
import { pathToFileURL } from 'node:url'
|
||||
import { promisify } from 'node:util'
|
||||
import * as fs from 'fs-extra'
|
||||
@@ -9,6 +10,7 @@ const exec = promisify(child_process.exec)
|
||||
type ExecError = {
|
||||
status: number
|
||||
stdout: string
|
||||
stderr: string
|
||||
}
|
||||
|
||||
const ENV_VAR = 'cross-env DATA_DIR=tests/__data__/input/data ROOT_DIR=tests/__data__/output'
|
||||
@@ -55,6 +57,20 @@ describe('playlist:test', () => {
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
it('fails when the network is unavailable', () => {
|
||||
const preload = path.resolve('tests/__data__/input/offline_dns.cjs').replaceAll('\\', '/')
|
||||
const cmd =
|
||||
`cross-env NODE_OPTIONS="--require=${preload}" npm run playlist:test -- streams/af.m3u`
|
||||
|
||||
try {
|
||||
execSync(cmd, { encoding: 'utf8' })
|
||||
throw new Error('Expected playlist:test to fail offline')
|
||||
} catch (error) {
|
||||
const output = `${(error as ExecError).stdout || ''}${(error as ExecError).stderr || ''}`
|
||||
expect(output).toContain('Internet connection is required for the script to work')
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
function content(filepath: string) {
|
||||
|
||||
@@ -101,4 +101,12 @@ describe('playlist:validate', () => {
|
||||
const stdout = execSync(cmd, { encoding: 'utf8' })
|
||||
if (process.env.DEBUG === 'true') console.log(cmd, stdout)
|
||||
})
|
||||
|
||||
it('accepts a playlist without optional metadata attributes', () => {
|
||||
const cmd = `${ENV_VAR} npm run playlist:validate -- missing_metadata.m3u`
|
||||
const stdout = execSync(cmd, { encoding: 'utf8' })
|
||||
if (process.env.DEBUG === 'true') console.log(cmd, stdout)
|
||||
expect(stdout).toContain('missing_metadata.m3u')
|
||||
expect(stdout).toContain('is missing a channel ID')
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user