Add country subdivisions codes to the country lists
This commit is contained in:
parent
e1adac57b7
commit
332600501b
@ -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
|
||||
|
@ -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 => {
|
||||
|
Loading…
Reference in New Issue
Block a user