Add country subdivisions codes to the country lists

This commit is contained in:
Gabriel Bergeron 2022-03-13 23:58:19 -04:00
parent e1adac57b7
commit 332600501b
2 changed files with 8 additions and 1 deletions

View File

@ -35,5 +35,6 @@ api.categories = new API(`${DATA_DIR}/categories.json`)
api.languages = new API(`${DATA_DIR}/languages.json`)
api.regions = new API(`${DATA_DIR}/regions.json`)
api.blocklist = new API(`${DATA_DIR}/blocklist.json`)
api.subdivisions = new API(`${DATA_DIR}/subdivisions.json`)
module.exports = api

View File

@ -8,12 +8,18 @@ module.exports = async function (streams = []) {
const countries = await api.countries.all()
await api.regions.load()
const regions = await api.regions.all()
await api.subdivisions.load()
const subdivisions = await api.subdivisions.all()
const output = []
for (const country of countries) {
const countryAreaCodes = _.filter(regions, { countries: [country.code] }).map(
let countryRegionCodes = _.filter(regions, { countries: [country.code] }).map(
r => `r/${r.code}`
)
const countrySubdivisionCodes = _.filter(subdivisions, { country: country.code}).map(
r => `s/${r.code}`
)
const countryAreaCodes = countryRegionCodes.concat(countrySubdivisionCodes)
countryAreaCodes.push(`c/${country.code}`)
let items = _.filter(streams, stream => {