Merge pull request #910 from iptv-org/patch-2022.10.3

Patch 2022.10.3
This commit is contained in:
Aleksandr Statciuk 2022-10-24 03:54:11 +03:00 committed by GitHub
commit 2fd38a3a1b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 21 additions and 17 deletions

View file

@ -55,12 +55,12 @@
### countries ### countries
| Field | Description | Required | Example | | Field | Description | Required | Example |
| ----- | ------------------------------------------------------------------------------------------ | -------- | ------------ | | --------- | ------------------------------------------------------------------------------------------------------------------------------------------------------- | -------- | --------- |
| name | Official name of the country | Required | `Martinique` | | name | Official name of the country | Required | `Canada` |
| code | [ISO 3166-1 alpha-2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) code of the country | Required | `MQ` | | code | [ISO 3166-1 alpha-2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) code of the country | Required | `CA` |
| lang | Official language in the country | Required | `fra` | | languages | List of official languages of the country separated by `;`. A list of all supported languages can be found in [data/languages.csv](data/languages.csv). | Required | `eng;fra` |
| flag | Country flag emoji | Required | `🇲🇶` | | flag | Country flag emoji | Required | `🇨🇦` |
### subdivisions ### subdivisions

View file

@ -1,4 +1,4 @@
name,code,lang,flag name,code,languages,flag
Afghanistan,AF,pus,🇦🇫 Afghanistan,AF,pus,🇦🇫
Albania,AL,sqi,🇦🇱 Albania,AL,sqi,🇦🇱
Algeria,DZ,ara,🇩🇿 Algeria,DZ,ara,🇩🇿

1 name code lang languages flag
2 Afghanistan AF pus 🇦🇫
3 Albania AL sqi 🇦🇱
4 Algeria DZ ara 🇩🇿

View file

@ -7,9 +7,11 @@ module.exports = {
code: Joi.string() code: Joi.string()
.regex(/^[A-Z]{2}$/) .regex(/^[A-Z]{2}$/)
.required(), .required(),
lang: Joi.string() languages: Joi.array().items(
.regex(/^[a-z]{3}$/) Joi.string()
.required(), .regex(/^[a-z]{3}$/)
.required()
),
flag: Joi.string() flag: Joi.string()
.regex(/^[\uD83C][\uDDE6-\uDDFF][\uD83C][\uDDE6-\uDDFF]$/) .regex(/^[\uD83C][\uDDE6-\uDDFF][\uD83C][\uDDE6-\uDDFF]$/)
.required() .required()

View file

@ -91,7 +91,7 @@ async function main() {
} }
} else if (filename === 'countries') { } else if (filename === 'countries') {
for (const [i, row] of rowsCopy.entries()) { for (const [i, row] of rowsCopy.entries()) {
fileErrors = fileErrors.concat(validateCountryLanguage(row, i)) fileErrors = fileErrors.concat(validateCountryLanguages(row, i))
} }
} else if (filename === 'subdivisions') { } else if (filename === 'subdivisions') {
for (const [i, row] of rowsCopy.entries()) { for (const [i, row] of rowsCopy.entries()) {
@ -295,13 +295,15 @@ function validateChannel(row, i) {
return errors return errors
} }
function validateCountryLanguage(row, i) { function validateCountryLanguages(row, i) {
const errors = [] const errors = []
if (!db.languages[row.lang]) { for (let lang of row.languages) {
errors.push({ if (!db.languages[lang]) {
line: i + 2, errors.push({
message: `"${row.code}" has the wrong language "${row.lang}"` line: i + 2,
}) message: `"${row.code}" has the wrong language "${lang}"`
})
}
} }
return errors return errors