mirror of https://github.com/iptv-org/iptv
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
20 lines
438 B
JavaScript
20 lines
438 B
JavaScript
const { transliterate } = require('transliteration')
|
|
|
|
const id = {}
|
|
|
|
id.generate = function (name, code) {
|
|
if (!name || !code) return null
|
|
|
|
name = name.replace(/ *\([^)]*\) */g, '')
|
|
name = name.replace(/ *\[[^)]*\] */g, '')
|
|
name = name.replace(/\+/gi, 'Plus')
|
|
name = name.replace(/[^a-z\d]+/gi, '')
|
|
name = name.trim()
|
|
name = transliterate(name)
|
|
code = code.toLowerCase()
|
|
|
|
return `${name}.${code}`
|
|
}
|
|
|
|
module.exports = id
|