Update scripts

This commit is contained in:
freearhey 2025-03-18 08:32:46 +03:00
parent 77680e2dc9
commit 075c53143e
14 changed files with 520 additions and 132 deletions

24
scripts/utils.ts Normal file
View 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, '')
}