mirror of
https://github.com/iptv-org/iptv.git
synced 2025-05-13 02:20:03 -04:00
Update index_country_m3u.js
This commit is contained in:
parent
1a6df4ef83
commit
9746f31eaa
1 changed files with 62 additions and 51 deletions
|
@ -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
|
||||
})
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue