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",
|
"name": "iptv",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@freearhey/iso-639-3": "^1.0.0",
|
|
||||||
"axios": "^0.21.4",
|
"axios": "^0.21.4",
|
||||||
"commander": "^7.0.0",
|
"commander": "^7.0.0",
|
||||||
"iptv-checker": "^0.21.0",
|
"iptv-checker": "^0.21.0",
|
||||||
|
@ -560,11 +559,6 @@
|
||||||
"resolved": "https://registry.npmjs.org/@bcoe/v8-coverage/-/v8-coverage-0.2.3.tgz",
|
"resolved": "https://registry.npmjs.org/@bcoe/v8-coverage/-/v8-coverage-0.2.3.tgz",
|
||||||
"integrity": "sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw=="
|
"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": {
|
"node_modules/@istanbuljs/load-nyc-config": {
|
||||||
"version": "1.1.0",
|
"version": "1.1.0",
|
||||||
"resolved": "https://registry.npmjs.org/@istanbuljs/load-nyc-config/-/load-nyc-config-1.1.0.tgz",
|
"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",
|
"resolved": "https://registry.npmjs.org/@bcoe/v8-coverage/-/v8-coverage-0.2.3.tgz",
|
||||||
"integrity": "sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw=="
|
"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": {
|
"@istanbuljs/load-nyc-config": {
|
||||||
"version": "1.1.0",
|
"version": "1.1.0",
|
||||||
"resolved": "https://registry.npmjs.org/@istanbuljs/load-nyc-config/-/load-nyc-config-1.1.0.tgz",
|
"resolved": "https://registry.npmjs.org/@istanbuljs/load-nyc-config/-/load-nyc-config-1.1.0.tgz",
|
||||||
|
|
|
@ -10,7 +10,6 @@
|
||||||
"private": true,
|
"private": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@freearhey/iso-639-3": "^1.0.0",
|
|
||||||
"axios": "^0.21.4",
|
"axios": "^0.21.4",
|
||||||
"commander": "^7.0.0",
|
"commander": "^7.0.0",
|
||||||
"iptv-checker": "^0.21.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
|
const curr = i + 1
|
||||||
updateTvgName(channel)
|
updateTvgName(channel)
|
||||||
updateTvgId(channel, playlist)
|
updateTvgId(channel, playlist)
|
||||||
updateTvgCountry(channel, playlist)
|
updateTvgCountry(channel)
|
||||||
normalizeUrl(channel)
|
normalizeUrl(channel)
|
||||||
|
|
||||||
const data = channels[channel.tvg.id]
|
const data = channels[channel.tvg.id]
|
||||||
|
@ -217,9 +217,9 @@ function updateTvgId(channel, playlist) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function updateTvgCountry(channel, playlist) {
|
function updateTvgCountry(channel) {
|
||||||
const code = playlist.country.code
|
if (!channel.countries.length && channel.tvg.id) {
|
||||||
if (!channel.countries.length) {
|
const code = channel.tvg.id.split('.')[1] || null
|
||||||
const name = utils.code2name(code)
|
const name = utils.code2name(code)
|
||||||
channel.countries = name ? [{ code, name }] : []
|
channel.countries = name ? [{ code, name }] : []
|
||||||
channel.tvg.country = channel.countries.map(c => c.code.toUpperCase()).join(';')
|
channel.tvg.country = channel.countries.map(c => c.code.toUpperCase()).join(';')
|
||||||
|
@ -237,8 +237,13 @@ function updateLogo(channel, data, epgData) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function updateTvgLanguage(channel, data) {
|
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(';')
|
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 { orderBy } = require('natural-orderby')
|
||||||
const iso6393 = require('@freearhey/iso-639-3')
|
|
||||||
const transliteration = require('transliteration')
|
const transliteration = require('transliteration')
|
||||||
|
const countries = require('../data/countries')
|
||||||
const categories = require('../data/categories')
|
const categories = require('../data/categories')
|
||||||
|
const languages = require('../data/languages')
|
||||||
const regions = require('../data/regions')
|
const regions = require('../data/regions')
|
||||||
|
|
||||||
const utils = {}
|
const utils = {}
|
||||||
|
@ -50,11 +51,19 @@ utils.code2name = function (code) {
|
||||||
}
|
}
|
||||||
|
|
||||||
utils.language2code = function (name) {
|
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
|
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) {
|
utils.sortBy = function (arr, fields, order = null) {
|
||||||
fields = fields.map(field => {
|
fields = fields.map(field => {
|
||||||
if (field === 'resolution.height') return channel => channel.resolution.height || 0
|
if (field === 'resolution.height') return channel => channel.resolution.height || 0
|
||||||
|
|
Loading…
Reference in New Issue