Update index_country_m3u.js

This commit is contained in:
Aleksandr Statciuk 2023-01-22 17:00:15 +03:00
parent 1a6df4ef83
commit 9746f31eaa

View file

@ -25,6 +25,12 @@ module.exports = async function (streams = []) {
return
}
if (stream.broadcast_area.includes('r/INT')) {
const item = _.cloneDeep(stream)
item.group_title = 'International'
items.push(item)
}
const broadcastCountries = getBroadcastCountries(stream, { countries, regions, subdivisions })
broadcastCountries.forEach(country => {
const item = _.cloneDeep(stream)
@ -33,11 +39,7 @@ module.exports = async function (streams = []) {
})
})
items = _.sortBy(items, item => {
if (item.group_title === 'Undefined') return ''
return item.group_title
})
items = sortByGroupTitle(items)
return { filepath: 'index.country.m3u', items }
}
@ -50,7 +52,7 @@ function getBroadcastCountries(stream, { countries, regions, subdivisions }) {
acc.push(code)
break
case 'r':
if (regions[code]) {
if (code !== 'INT' && regions[code]) {
acc = acc.concat(regions[code].countries)
}
break
@ -67,3 +69,12 @@ function getBroadcastCountries(stream, { countries, regions, subdivisions }) {
return codes.map(code => countries[code]).filter(c => c)
}
function sortByGroupTitle(items) {
return _.sortBy(items, item => {
if (item.group_title === 'International') return '[' // ASCII character 91
if (item.group_title === 'Undefined') return ']' // ASCII character 93
return item.group_title
})
}