iptv/scripts/core/cid.js
2022-02-05 07:25:56 +03:00

24 lines
508 B
JavaScript

const file = require('./file')
const parser = require('./parser')
const transliteration = require('transliteration')
const cid = {}
cid.generate = function (title, filepath) {
const name = parser.parseChannelName(title)
const code = parser.parseCountryCode(filepath)
if (name && code) {
const slug = transliteration
.transliterate(name)
.replace(/\+/gi, 'Plus')
.replace(/[^a-z\d]+/gi, '')
return `${slug}.${code.toLowerCase()}`
}
return null
}
module.exports = cid