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.
iptv/scripts/core/id.js

24 lines
505 B
JavaScript

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