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')
|
|
|
|
|
2022-02-11 08:52:38 +01:00
|
|
|
const id = {}
|
2022-02-05 00:47:16 +01:00
|
|
|
|
2022-02-11 08:52:38 +01:00
|
|
|
id.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
|
|
|
|
}
|
|
|
|
|
2022-02-11 08:52:38 +01:00
|
|
|
module.exports = id
|