iptv/scripts/core/cid.js

24 lines
508 B
JavaScript
Raw Normal View History

2022-02-05 00:47:16 +01:00
const file = require('./file')
2022-02-05 05:25:56 +01:00
const parser = require('./parser')
2022-02-05 00:47:16 +01:00
const transliteration = require('transliteration')
const cid = {}
cid.generate = function (title, filepath) {
2022-02-05 05:25:56 +01:00
const name = parser.parseChannelName(title)
const code = parser.parseCountryCode(filepath)
2022-02-05 00:47:16 +01:00
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