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/generators/languages.js

26 lines
730 B
JavaScript

3 years ago
const _ = require('lodash')
module.exports = async function (streams = []) {
streams = _.filter(streams, stream => stream.is_nsfw === false)
3 years ago
let languages = []
streams.forEach(stream => {
languages = languages.concat(stream.languages)
})
3 years ago
languages = _.uniqBy(languages, 'code')
languages = _.sortBy(languages, 'name')
3 years ago
const output = []
3 years ago
for (const language of languages) {
let items = _.filter(streams, { languages: [{ code: language.code }] })
3 years ago
if (items.length) {
3 years ago
output.push({ filepath: `languages/${language.code}.m3u`, items })
3 years ago
}
}
let items = _.filter(streams, stream => !stream.languages.length)
3 years ago
output.push({ filepath: 'languages/undefined.m3u', items })
3 years ago
return output
}