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
77680e2dc9
commit
075c53143e
14 changed files with 520 additions and 132 deletions
24
scripts/utils.ts
Normal file
24
scripts/utils.ts
Normal file
|
@ -0,0 +1,24 @@
|
|||
export function createChannelId(
|
||||
name: string | undefined,
|
||||
country: string | undefined
|
||||
): string | undefined {
|
||||
if (!name || !country) return undefined
|
||||
|
||||
const slug = normalize(name)
|
||||
const code = country.toLowerCase()
|
||||
|
||||
return `${slug}.${code}`
|
||||
}
|
||||
|
||||
export function createFeedId(name: string) {
|
||||
return normalize(name)
|
||||
}
|
||||
|
||||
function normalize(string: string) {
|
||||
return string
|
||||
.replace(/^@/gi, 'At')
|
||||
.replace(/^&/i, 'And')
|
||||
.replace(/\+/gi, 'Plus')
|
||||
.replace(/\s-(\d)/gi, ' Minus$1')
|
||||
.replace(/[^a-z\d]+/gi, '')
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue