Merge pull request #61 from iptv-org/add-replace-by-field

Add replace_by field
This commit is contained in:
Aleksandr Statciuk 2022-04-21 22:17:18 +03:00 committed by GitHub
commit bc758c0795
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 29020 additions and 29001 deletions

View file

@ -21,7 +21,7 @@ All data is stored in the [/data](data) folder as [CSV](https://en.wikipedia.org
| id | Unique channel ID. Should be derived from the name of the channel and country code separated by dot. May only contain Latin letters, numbers and dot. | Required | `AnhuiTV.cn` | | id | Unique channel ID. Should be derived from the name of the channel and country code separated by dot. May only contain Latin letters, numbers and dot. | Required | `AnhuiTV.cn` |
| name | Official channel name in English. May include: `a-z`, `à-ÿ`, `0-9`, `space`, `-`, `!`, `:`, `&`, `.`, `+`, `'`, `/`, `»`, `#`, `%`, `°`, `$`, `@`, `?`, `(`, `)`. | Required | `Anhui TV` | | name | Official channel name in English. May include: `a-z`, `à-ÿ`, `0-9`, `space`, `-`, `!`, `:`, `&`, `.`, `+`, `'`, `/`, `»`, `#`, `%`, `°`, `$`, `@`, `?`, `(`, `)`. | Required | `Anhui TV` |
| native_name | Channel name in the original language. May contain any characters except `,` and `"`. | Optional | `安徽卫视` | | native_name | Channel name in the original language. May contain any characters except `,` and `"`. | Optional | `安徽卫视` |
| network | Name of the network operating the channel. | Optional | `Anhui` | | network | Network of which this channel is a part. | Optional | `Anhui` |
| country | Country code from which the channel is transmitted. A list of all supported countries and their codes can be found in [data/countries.csv](data/countries.csv) | Required | `CN` | | country | Country code from which the channel is transmitted. A list of all supported countries and their codes can be found in [data/countries.csv](data/countries.csv) | Required | `CN` |
| subdivision | Code of the subdivision (e.g., provinces or states) from which the broadcast is transmitted. A list of all supported subdivisions and their codes can be found in [data/subdivisions.csv](data/subdivisions.csv) | Optional | `CN-AH` | | subdivision | Code of the subdivision (e.g., provinces or states) from which the broadcast is transmitted. A list of all supported subdivisions and their codes can be found in [data/subdivisions.csv](data/subdivisions.csv) | Optional | `CN-AH` |
| city | Name of the city from which the channel is transmitted. May only contain `a-z`, `à-ÿ`, `0-9`, `space`, `-`, `'`. | Optional | `Hefei` | | city | Name of the city from which the channel is transmitted. May only contain `a-z`, `à-ÿ`, `0-9`, `space`, `-`, `'`. | Optional | `Hefei` |
@ -31,6 +31,7 @@ All data is stored in the [/data](data) folder as [CSV](https://en.wikipedia.org
| is_nsfw | Indicates whether the channel broadcasts adult content (`TRUE` or `FALSE`) | Required | `FALSE` | | is_nsfw | Indicates whether the channel broadcasts adult content (`TRUE` or `FALSE`) | Required | `FALSE` |
| launched | Launch date of the channel (`YYYY-MM-DD`) | Optional | `2016-07-28` | | launched | Launch date of the channel (`YYYY-MM-DD`) | Optional | `2016-07-28` |
| closed | Date on which the channel closed (`YYYY-MM-DD`) | Optional | `2020-05-31` | | closed | Date on which the channel closed (`YYYY-MM-DD`) | Optional | `2020-05-31` |
| replaced_by | The ID of the channel that this channel was replaced by. | Optional | `CCTV1.cn` |
| website | Official website URL. | Optional | `http://www.ahtv.cn/` | | website | Official website URL. | Optional | `http://www.ahtv.cn/` |
| logo | Logo URL. Only URL with HTTPS protocol are allowed. Supported image types: `PNG`, `JPEG`. | Optional | `https://example.com/logo.png` | | logo | Logo URL. Only URL with HTTPS protocol are allowed. Supported image types: `PNG`, `JPEG`. | Optional | `https://example.com/logo.png` |

File diff suppressed because it is too large Load diff

View file

@ -26,7 +26,8 @@ const csv2jsonOptions = {
launched: nullable, launched: nullable,
closed: nullable, closed: nullable,
website: nullable, website: nullable,
native_name: nullable native_name: nullable,
replaced_by: nullable
} }
} }

View file

@ -35,6 +35,9 @@ module.exports = {
is_nsfw: Joi.boolean().strict().required(), is_nsfw: Joi.boolean().strict().required(),
launched: Joi.date().format('YYYY-MM-DD').raw().allow(null), launched: Joi.date().format('YYYY-MM-DD').raw().allow(null),
closed: Joi.date().format('YYYY-MM-DD').raw().allow(null), closed: Joi.date().format('YYYY-MM-DD').raw().allow(null),
replaced_by: Joi.string()
.regex(/^[A-Za-z0-9]+\.[a-z]{2}$/)
.allow(null),
website: Joi.string() website: Joi.string()
.uri({ .uri({
scheme: ['http', 'https'] scheme: ['http', 'https']

View file

@ -78,6 +78,7 @@ async function main() {
fileErrors = fileErrors.concat(validateChannelBroadcastArea(row, i)) fileErrors = fileErrors.concat(validateChannelBroadcastArea(row, i))
fileErrors = fileErrors.concat(validateChannelSubdivision(row, i)) fileErrors = fileErrors.concat(validateChannelSubdivision(row, i))
fileErrors = fileErrors.concat(validateChannelCategories(row, i)) fileErrors = fileErrors.concat(validateChannelCategories(row, i))
fileErrors = fileErrors.concat(validateChannelReplacedBy(row, i))
fileErrors = fileErrors.concat(validateChannelLanguages(row, i)) fileErrors = fileErrors.concat(validateChannelLanguages(row, i))
fileErrors = fileErrors.concat(validateChannelCountry(row, i)) fileErrors = fileErrors.concat(validateChannelCountry(row, i))
} }
@ -172,6 +173,18 @@ function validateChannelCountry(row, i) {
return errors return errors
} }
function validateChannelReplacedBy(row, i) {
const errors = []
if (row.replaced_by && !db.channels[row.replaced_by]) {
errors.push({
line: i + 2,
message: `"${row.id}" has the wrong replaced_by "${row.replaced_by}"`
})
}
return errors
}
function validateChannelSubdivision(row, i) { function validateChannelSubdivision(row, i) {
const errors = [] const errors = []
if (row.subdivision && !db.subdivisions[row.subdivision]) { if (row.subdivision && !db.subdivisions[row.subdivision]) {