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
| Field | Description | Required | Example |
| ----- | ------------------------------------------------------------------------------------------ | -------- | ------------ |
| name | Official name of the country | Required | `Martinique` |
| code | [ISO 3166-1 alpha-2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) code of the country | Required | `MQ` |
| lang | Official language in the country | Required | `fra` |
| flag | Country flag emoji | Required | `🇲🇶` |
| Field | Description | Required | Example |
| --------- | ------------------------------------------------------------------------------------------------------------------------------------------------------- | -------- | --------- |
| 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 | `CA` |
| 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 | `🇨🇦` |
### subdivisions

View file

@ -1,4 +1,4 @@
name,code,lang,flag
name,code,languages,flag
Afghanistan,AF,pus,🇦🇫
Albania,AL,sqi,🇦🇱
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()
.regex(/^[A-Z]{2}$/)
.required(),
lang: Joi.string()
.regex(/^[a-z]{3}$/)
.required(),
languages: Joi.array().items(
Joi.string()
.regex(/^[a-z]{3}$/)
.required()
),
flag: Joi.string()
.regex(/^[\uD83C][\uDDE6-\uDDFF][\uD83C][\uDDE6-\uDDFF]$/)
.required()

View file

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