iptv/scripts/core/id.js
Aleksandr Statciuk 442916d130 Rename to id.js
2022-02-11 10:52:38 +03:00

24 lines
505 B
JavaScript

const file = require('./file')
const parser = require('./parser')
const transliteration = require('transliteration')
const id = {}
id.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 = id