additional updates.

This commit is contained in:
theofficialomega 2025-06-29 00:17:31 +02:00
parent b5f36296e9
commit 59c3e0b191
8 changed files with 8464 additions and 5986 deletions

7
.gitignore vendored
View File

@ -5,4 +5,9 @@
/guide.xml.gz
# macOS
.DS_Store
.DS_Store
# If Yarn is used (yarn.lock)
/.yarn/*
.yarnrc
.yarnrc.yml

36
package-lock.json generated
View File

@ -25,6 +25,7 @@
"@types/jest": "^30.0.0",
"@types/langs": "^2.0.5",
"@types/lodash": "^4.17.18",
"@types/node": "^24.0.7",
"@types/node-cleanup": "^2.1.5",
"@types/numeral": "^2.0.5",
"@typescript-eslint/eslint-plugin": "^8.34.1",
@ -78,6 +79,7 @@
"tough-cookie": "^5.1.2",
"transliteration": "^2.3.5",
"tsx": "^4.20.3",
"typescript": "^5.8.3",
"unzipit": "^1.4.3",
"wildcard-match": "^5.1.4"
}
@ -3472,9 +3474,13 @@
"license": "MIT"
},
"node_modules/@types/node": {
"version": "20.7.1",
"resolved": "https://registry.npmjs.org/@types/node/-/node-20.7.1.tgz",
"integrity": "sha512-LT+OIXpp2kj4E2S/p91BMe+VgGX2+lfO+XTpfXhh+bCk2LkQtHZSub8ewFBMGP5ClysPjTDFa4sMI8Q3n4T0wg=="
"version": "24.0.7",
"resolved": "https://registry.npmjs.org/@types/node/-/node-24.0.7.tgz",
"integrity": "sha512-YIEUUr4yf8q8oQoXPpSlnvKNVKDQlPMWrmOcgzoduo7kvA2UF0/BwJ/eMKFTiTtkNL17I0M6Xe2tvwFU7be6iw==",
"license": "MIT",
"dependencies": {
"undici-types": "~7.8.0"
}
},
"node_modules/@types/node-cleanup": {
"version": "2.1.5",
@ -11277,7 +11283,6 @@
"resolved": "https://registry.npmjs.org/typescript/-/typescript-5.8.3.tgz",
"integrity": "sha512-p1diW6TqL9L07nNxvRMM7hMMw4c5XOo/1ibL4aAIGmSAt9slTE1Xgw5KWuof2uTOvCg9BY7ZRi+GaF+7sfgPeQ==",
"license": "Apache-2.0",
"peer": true,
"bin": {
"tsc": "bin/tsc",
"tsserver": "bin/tsserver"
@ -11295,6 +11300,12 @@
"node": ">=20.18.1"
}
},
"node_modules/undici-types": {
"version": "7.8.0",
"resolved": "https://registry.npmjs.org/undici-types/-/undici-types-7.8.0.tgz",
"integrity": "sha512-9UJ2xGDvQ43tYyVMpuHlsgApydB8ZKfVYTsLDhXkFL/6gfkp+U8xTGdh8pMJv1SpZna0zxG1DwsKZsreLbXBxw==",
"license": "MIT"
},
"node_modules/universal-user-agent": {
"version": "7.0.3",
"resolved": "https://registry.npmjs.org/universal-user-agent/-/universal-user-agent-7.0.3.tgz",
@ -13963,9 +13974,12 @@
"integrity": "sha512-KJ65INaxqxmU6EoCiJmRPZC9H9RVWCRd349tXM2M3O5NA7cY6YL7c0bHAHQ93NOfTObEQ004kd2QVHs/r0+m4g=="
},
"@types/node": {
"version": "20.7.1",
"resolved": "https://registry.npmjs.org/@types/node/-/node-20.7.1.tgz",
"integrity": "sha512-LT+OIXpp2kj4E2S/p91BMe+VgGX2+lfO+XTpfXhh+bCk2LkQtHZSub8ewFBMGP5ClysPjTDFa4sMI8Q3n4T0wg=="
"version": "24.0.7",
"resolved": "https://registry.npmjs.org/@types/node/-/node-24.0.7.tgz",
"integrity": "sha512-YIEUUr4yf8q8oQoXPpSlnvKNVKDQlPMWrmOcgzoduo7kvA2UF0/BwJ/eMKFTiTtkNL17I0M6Xe2tvwFU7be6iw==",
"requires": {
"undici-types": "~7.8.0"
}
},
"@types/node-cleanup": {
"version": "2.1.5",
@ -19223,14 +19237,18 @@
"typescript": {
"version": "5.8.3",
"resolved": "https://registry.npmjs.org/typescript/-/typescript-5.8.3.tgz",
"integrity": "sha512-p1diW6TqL9L07nNxvRMM7hMMw4c5XOo/1ibL4aAIGmSAt9slTE1Xgw5KWuof2uTOvCg9BY7ZRi+GaF+7sfgPeQ==",
"peer": true
"integrity": "sha512-p1diW6TqL9L07nNxvRMM7hMMw4c5XOo/1ibL4aAIGmSAt9slTE1Xgw5KWuof2uTOvCg9BY7ZRi+GaF+7sfgPeQ=="
},
"undici": {
"version": "7.10.0",
"resolved": "https://registry.npmjs.org/undici/-/undici-7.10.0.tgz",
"integrity": "sha512-u5otvFBOBZvmdjWLVW+5DAc9Nkq8f24g0O9oY7qw2JVIF1VocIFoyz9JFkuVOS2j41AufeO0xnlweJ2RLT8nGw=="
},
"undici-types": {
"version": "7.8.0",
"resolved": "https://registry.npmjs.org/undici-types/-/undici-types-7.8.0.tgz",
"integrity": "sha512-9UJ2xGDvQ43tYyVMpuHlsgApydB8ZKfVYTsLDhXkFL/6gfkp+U8xTGdh8pMJv1SpZna0zxG1DwsKZsreLbXBxw=="
},
"universal-user-agent": {
"version": "7.0.3",
"resolved": "https://registry.npmjs.org/universal-user-agent/-/universal-user-agent-7.0.3.tgz",

View File

@ -3,15 +3,15 @@
"scripts": {
"act:check": "act pull_request -W .github/workflows/check.yml",
"act:update": "act workflow_dispatch -W .github/workflows/update.yml",
"api:load": "npx tsx scripts/commands/api/load.ts",
"api:generate": "npx tsx scripts/commands/api/generate.ts",
"channels:lint": "npx tsx scripts/commands/channels/lint.mts",
"channels:parse": "npx tsx scripts/commands/channels/parse.ts",
"channels:edit": "npx tsx scripts/commands/channels/edit.ts",
"channels:validate": "npx tsx scripts/commands/channels/validate.ts",
"sites:init": "npx tsx scripts/commands/sites/init.ts",
"sites:update": "npx tsx scripts/commands/sites/update.ts",
"grab": "npx tsx scripts/commands/epg/grab.ts",
"api:load": "tsx scripts/commands/api/load.ts",
"api:generate": "tsx scripts/commands/api/generate.ts",
"channels:lint": "tsx scripts/commands/channels/lint.mts",
"channels:parse": "tsx scripts/commands/channels/parse.ts",
"channels:edit": "tsx scripts/commands/channels/edit.ts",
"channels:validate": "tsx scripts/commands/channels/validate.ts",
"sites:init": "tsx scripts/commands/sites/init.ts",
"sites:update": "tsx scripts/commands/sites/update.ts",
"grab": "tsx scripts/commands/epg/grab.ts",
"lint": "npx eslint \"{scripts,tests,sites}/**/*.{ts,mts,js}\"",
"test": "cross-env TZ=Pacific/Nauru npx jest --runInBand",
"test:site": "cross-env TZ=Pacific/Nauru npx jest --runInBand --testPathPatterns",
@ -55,6 +55,7 @@
"@types/jest": "^30.0.0",
"@types/langs": "^2.0.5",
"@types/lodash": "^4.17.18",
"@types/node": "^24.0.7",
"@types/node-cleanup": "^2.1.5",
"@types/numeral": "^2.0.5",
"@typescript-eslint/eslint-plugin": "^8.34.1",
@ -108,7 +109,9 @@
"tough-cookie": "^5.1.2",
"transliteration": "^2.3.5",
"tsx": "^4.20.3",
"typescript": "^5.8.3",
"unzipit": "^1.4.3",
"wildcard-match": "^5.1.4"
}
},
"packageManager": "yarn@4.9.2"
}

View File

@ -44,7 +44,7 @@ program
.default(false)
.env('GZIP')
)
.parse(process.argv)
.parse()
export type GrabOptions = {
site?: string
@ -102,7 +102,10 @@ async function main() {
runJob({ logger, parsedChannels })
}
main()
main().catch(error => {
console.error('ERR:', error.message)
process.exit(1)
})
async function runJob({ logger, parsedChannels }: { logger: Logger; parsedChannels: Collection }) {
const timer = new Timer()

View File

@ -35,7 +35,7 @@ export class Guide {
const programs = this.programs
const currDate = new DateTime(process.env.CURR_DATE || new Date().toISOString(), {
zone: 'UTC'
timezone: 'UTC'
})
const xmltv = new XMLTV({
channels,
@ -50,7 +50,7 @@ export class Guide {
if (this.gzip) {
const zip = new Zip()
const compressed = await zip.compress(xmltv.toString())
const compressed = zip.compress(xmltv.toString())
const gzFilepath = `${this.filepath}.gz`
const gzFilename = path.basename(gzFilepath)
this.logger.info(` saving to "${gzFilepath}"...`)

View File

@ -45,15 +45,15 @@ describe('epg:grab', () => {
)
const zip = new Zip()
const expected = await zip.decompress(fs.readFileSync('tests/__data__/output/guide.xml.gz'))
const result = await zip.decompress(
const expected = zip.decompress(fs.readFileSync('tests/__data__/output/guide.xml.gz'))
const result = zip.decompress(
fs.readFileSync('tests/__data__/expected/epg_grab/guide.xml.gz')
)
expect(expected).toEqual(result)
}, 30000)
it('can grab epg with wildcard as output', () => {
const cmd = `${ENV_VAR} npm run grab --- --channels=tests/__data__/input/epg_grab/sites/example.com/example.com.channels.xml --output=tests/__data__/output/guides/{lang}/{site}.xml`
const cmd = `${ENV_VAR} npm run grab --- --channels="tests/__data__/input/epg_grab/sites/example.com/example.com.channels.xml" --output="tests/__data__/output/guides/{lang}/{site}.xml"`
const stdout = execSync(cmd, { encoding: 'utf8' })
if (process.env.DEBUG === 'true') console.log(cmd, stdout)
@ -97,11 +97,19 @@ describe('epg:grab', () => {
})
it('it will raise an error if the timeout is exceeded', () => {
const cmd = `${ENV_VAR} npm run grab --- --channels=tests/__data__/input/epg_grab/custom.channels.xml --output=tests/__data__/output/guide.xml --timeout=100`
const stdout = execSync(cmd, { encoding: 'utf8' })
if (process.env.DEBUG === 'true') console.log(cmd, stdout)
expect(stdout).toContain('ERR: Connection timeout')
const cmd = `${ENV_VAR} npm run grab --- --channels=tests/__data__/input/epg_grab/custom.channels.xml --output=tests/__data__/output/guide.xml --timeout=0`
try {
const stdout = execSync(cmd, { encoding: 'utf8' })
expect(stdout).toContain('ERR: Connection timeout')
} catch (error) {
// in the eventuality of an error that doesn't pipe in properly, check stdout and stderr.
const stderr = error.stderr?.toString() || ''
const stdout = error.stdout?.toString() || ''
const combined = stderr + stdout
if (process.env.DEBUG === 'true') console.log('Error output:', combined)
expect(combined).toContain('ERR: Connection timeout')
}
})
it('can grab epg via https proxy', () => {

View File

@ -11,8 +11,8 @@
"./scripts/types"
],
"allowJs": true,
"outDir": "./"
"outDir": "./dist"
},
"include": ["src/**/*", "scripts/types/**/*"],
"include": ["scripts/**/*", "src/**/*"],
"exclude": ["node_modules", "dist"]
}

14345
yarn.lock

File diff suppressed because it is too large Load Diff