From 332600501b71af0a6b1bbc1924ca5c72b71a7b47 Mon Sep 17 00:00:00 2001 From: Gabriel Bergeron Date: Sun, 13 Mar 2022 23:58:19 -0400 Subject: [PATCH] Add country subdivisions codes to the country lists --- scripts/core/api.js | 1 + scripts/generators/countries.js | 8 +++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/scripts/core/api.js b/scripts/core/api.js index efd84c5471..770f3a7eac 100644 --- a/scripts/core/api.js +++ b/scripts/core/api.js @@ -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 diff --git a/scripts/generators/countries.js b/scripts/generators/countries.js index 58d08b6f97..9554c4b739 100644 --- a/scripts/generators/countries.js +++ b/scripts/generators/countries.js @@ -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 => {