mirror of
https://github.com/iptv-org/database.git
synced 2025-05-09 19:20:01 -04:00
Update scripts
This commit is contained in:
parent
0feb6b1e89
commit
f0cbc45e14
4 changed files with 29 additions and 34 deletions
17
scripts/core/idCreator.ts
Normal file
17
scripts/core/idCreator.ts
Normal file
|
@ -0,0 +1,17 @@
|
|||
export class IDCreator {
|
||||
create(name: string, country: string): string {
|
||||
const slug = normalize(name)
|
||||
const code = country.toLowerCase()
|
||||
|
||||
return `${slug}.${code}`
|
||||
}
|
||||
}
|
||||
|
||||
function normalize(name: string) {
|
||||
return name
|
||||
.replace(/^@/gi, 'At')
|
||||
.replace(/^&/i, 'And')
|
||||
.replace(/\+/gi, 'Plus')
|
||||
.replace(/\s-(\d)/gi, ' Minus$1')
|
||||
.replace(/[^a-z\d]+/gi, '')
|
||||
}
|
|
@ -2,3 +2,4 @@ export * from './csv'
|
|||
export * from './issueParser'
|
||||
export * from './issueLoader'
|
||||
export * from './csvParser'
|
||||
export * from './idCreator'
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue