Replaced langs package with iso-639-3

This commit is contained in:
freearhey 2020-04-18 17:16:56 +03:00
parent e9efc5b5f9
commit 4e4b9ea77a
3 changed files with 12 additions and 8 deletions

6
package-lock.json generated
View File

@ -80,10 +80,10 @@
"integrity": "sha1-6PvzdNxVb/iUehDcsFctYz8s+hA=",
"dev": true
},
"langs": {
"iso-639-3": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/langs/-/langs-2.0.0.tgz",
"integrity": "sha1-AMMs5IFSpJphRFC5uiYyq1igo2Q=",
"resolved": "https://registry.npmjs.org/iso-639-3/-/iso-639-3-2.0.0.tgz",
"integrity": "sha512-Pp+ctEs/pna6/rj05a5VR3qYxJHBZi95wp20C6Snf/WeghrkR/4G44LPJFqlbyo67XntkcUaxwrGmMeyY+F4mA==",
"dev": true
},
"markdown-include": {

View File

@ -16,7 +16,7 @@
"escape-string-regexp": "^2.0.0",
"fluent-ffmpeg": "^2.1.2",
"iptv-playlist-parser": "^0.4.0",
"langs": "^2.0.0",
"markdown-include": "^0.4.3"
"markdown-include": "^0.4.3",
"iso-639-3": "^2.0.0"
}
}

View File

@ -5,9 +5,9 @@ const axios = require('axios')
const zlib = require('zlib')
const epgParser = require('epg-parser')
const urlParser = require('url')
const langs = require('langs')
const escapeStringRegexp = require('escape-string-regexp')
const markdownInclude = require('markdown-include')
const iso6393 = require('iso-639-3')
let cache = {}
let helper = {}
@ -41,11 +41,15 @@ helper.escapeStringRegexp = function (scring) {
}
helper.getISO6391Name = function (code) {
return langs.has('3', code) ? langs.where('3', code).name : null
const lang = iso6393.find((l) => l.iso6393 === code.toLowerCase())
return lang && lang.name ? lang.name : null
}
helper.getISO6391Code = function (name) {
return langs.has('name', name) ? langs.where('name', name)['3'] : null
const lang = iso6393.find((l) => l.name === name)
return lang && lang.iso6393 ? lang.iso6393 : null
}
helper.parsePlaylist = function (filename) {