Merge pull request #5149 from iptv-org/update-format-js
Update format.js
This commit is contained in:
commit
9ca381c848
|
@ -7,7 +7,6 @@
|
|||
"name": "iptv",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@freearhey/iso-639-3": "^1.0.0",
|
||||
"axios": "^0.21.4",
|
||||
"commander": "^7.0.0",
|
||||
"iptv-checker": "^0.21.0",
|
||||
|
@ -560,11 +559,6 @@
|
|||
"resolved": "https://registry.npmjs.org/@bcoe/v8-coverage/-/v8-coverage-0.2.3.tgz",
|
||||
"integrity": "sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw=="
|
||||
},
|
||||
"node_modules/@freearhey/iso-639-3": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/@freearhey/iso-639-3/-/iso-639-3-1.0.0.tgz",
|
||||
"integrity": "sha512-K4xgPkCktQakQcYv8WuV8gFWAWrAaTrQEVgr/KVdE8k10KL9QmYVw+8Qb9WbtpMr2VXDz5pDwIAEINU5KlnlAg=="
|
||||
},
|
||||
"node_modules/@istanbuljs/load-nyc-config": {
|
||||
"version": "1.1.0",
|
||||
"resolved": "https://registry.npmjs.org/@istanbuljs/load-nyc-config/-/load-nyc-config-1.1.0.tgz",
|
||||
|
@ -4242,11 +4236,6 @@
|
|||
"resolved": "https://registry.npmjs.org/@bcoe/v8-coverage/-/v8-coverage-0.2.3.tgz",
|
||||
"integrity": "sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw=="
|
||||
},
|
||||
"@freearhey/iso-639-3": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/@freearhey/iso-639-3/-/iso-639-3-1.0.0.tgz",
|
||||
"integrity": "sha512-K4xgPkCktQakQcYv8WuV8gFWAWrAaTrQEVgr/KVdE8k10KL9QmYVw+8Qb9WbtpMr2VXDz5pDwIAEINU5KlnlAg=="
|
||||
},
|
||||
"@istanbuljs/load-nyc-config": {
|
||||
"version": "1.1.0",
|
||||
"resolved": "https://registry.npmjs.org/@istanbuljs/load-nyc-config/-/load-nyc-config-1.1.0.tgz",
|
||||
|
|
|
@ -10,7 +10,6 @@
|
|||
"private": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@freearhey/iso-639-3": "^1.0.0",
|
||||
"axios": "^0.21.4",
|
||||
"commander": "^7.0.0",
|
||||
"iptv-checker": "^0.21.0",
|
||||
|
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -66,7 +66,7 @@ async function updatePlaylist(playlist) {
|
|||
const curr = i + 1
|
||||
updateTvgName(channel)
|
||||
updateTvgId(channel, playlist)
|
||||
updateTvgCountry(channel, playlist)
|
||||
updateTvgCountry(channel)
|
||||
normalizeUrl(channel)
|
||||
|
||||
const data = channels[channel.tvg.id]
|
||||
|
@ -217,9 +217,9 @@ function updateTvgId(channel, playlist) {
|
|||
}
|
||||
}
|
||||
|
||||
function updateTvgCountry(channel, playlist) {
|
||||
const code = playlist.country.code
|
||||
if (!channel.countries.length) {
|
||||
function updateTvgCountry(channel) {
|
||||
if (!channel.countries.length && channel.tvg.id) {
|
||||
const code = channel.tvg.id.split('.')[1] || null
|
||||
const name = utils.code2name(code)
|
||||
channel.countries = name ? [{ code, name }] : []
|
||||
channel.tvg.country = channel.countries.map(c => c.code.toUpperCase()).join(';')
|
||||
|
@ -237,8 +237,13 @@ function updateLogo(channel, data, epgData) {
|
|||
}
|
||||
|
||||
function updateTvgLanguage(channel, data) {
|
||||
if (!channel.tvg.language && data) {
|
||||
if (!channel.tvg.language) {
|
||||
if (data) {
|
||||
channel.tvg.language = data.languages.map(l => l.name).join(';')
|
||||
} else if (channel.countries.length) {
|
||||
const countryCode = channel.countries[0].code
|
||||
channel.tvg.language = utils.country2language(countryCode)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
const { orderBy } = require('natural-orderby')
|
||||
const iso6393 = require('@freearhey/iso-639-3')
|
||||
const transliteration = require('transliteration')
|
||||
const countries = require('../data/countries')
|
||||
const categories = require('../data/categories')
|
||||
const languages = require('../data/languages')
|
||||
const regions = require('../data/regions')
|
||||
|
||||
const utils = {}
|
||||
|
@ -50,11 +51,19 @@ utils.code2name = function (code) {
|
|||
}
|
||||
|
||||
utils.language2code = function (name) {
|
||||
const lang = iso6393.find(l => l.name === name)
|
||||
const lang = languages.find(l => l.name === name)
|
||||
|
||||
return lang && lang.code ? lang.code : null
|
||||
}
|
||||
|
||||
utils.country2language = function (code) {
|
||||
const country = countries[code.toUpperCase()]
|
||||
if (!country.languages.length) return ''
|
||||
const language = languages.find(l => l.code === country.languages[0])
|
||||
|
||||
return language ? language.name : ''
|
||||
}
|
||||
|
||||
utils.sortBy = function (arr, fields, order = null) {
|
||||
fields = fields.map(field => {
|
||||
if (field === 'resolution.height') return channel => channel.resolution.height || 0
|
||||
|
|
Loading…
Reference in New Issue