mirror of
https://github.com/iptv-org/epg.git
synced 2025-05-09 16:40:07 -04:00
Update update-readme.js
This commit is contained in:
parent
da23d7e267
commit
3793895948
3 changed files with 14 additions and 10 deletions
|
@ -27,7 +27,7 @@ async function generateGuides() {
|
|||
const items = grouped[key]
|
||||
const channels = items
|
||||
.map(i => {
|
||||
const channel = api.channels.get(i.xmltv_id)
|
||||
const channel = api.channels.find({ id: i.xmltv_id })
|
||||
i.name = channel.name
|
||||
i.logo = channel.logo
|
||||
return i
|
||||
|
|
|
@ -1,7 +1,4 @@
|
|||
const { file, markdown, parser, logger } = require('../core')
|
||||
const provinces = require('../data/ca-provinces.json')
|
||||
const countries = require('../data/countries.json')
|
||||
const states = require('../data/us-states.json')
|
||||
const { file, markdown, parser, logger, api } = require('../core')
|
||||
const { program } = require('commander')
|
||||
const _ = require('lodash')
|
||||
|
||||
|
@ -14,6 +11,7 @@ const options = program
|
|||
|
||||
async function main() {
|
||||
const records = await getLogRecords()
|
||||
console.log(records)
|
||||
await generateCountriesTable(records)
|
||||
await generateUSStatesTable(records)
|
||||
await generateCanadaProvincesTable(records)
|
||||
|
@ -27,7 +25,7 @@ async function generateCountriesTable(items = []) {
|
|||
|
||||
let rows = []
|
||||
for (const item of items) {
|
||||
const country = countries[item.code]
|
||||
const country = api.countries.find({ code: item.code })
|
||||
if (!country) continue
|
||||
|
||||
rows.push({
|
||||
|
@ -51,7 +49,8 @@ async function generateUSStatesTable(items = []) {
|
|||
|
||||
let rows = []
|
||||
for (const item of items) {
|
||||
const state = states[item.code]
|
||||
if (!item.code.startsWith('US-')) continue
|
||||
const state = api.subdivisions.find({ code: item.code })
|
||||
if (!state) continue
|
||||
|
||||
rows.push({
|
||||
|
@ -74,7 +73,8 @@ async function generateCanadaProvincesTable(items = []) {
|
|||
|
||||
let rows = []
|
||||
for (const item of items) {
|
||||
const province = provinces[item.code]
|
||||
if (!item.code.startsWith('CA-')) continue
|
||||
const province = api.subdivisions.find({ code: item.code })
|
||||
if (!province) continue
|
||||
|
||||
rows.push({
|
||||
|
|
|
@ -1,15 +1,19 @@
|
|||
const _ = require('lodash')
|
||||
|
||||
class API {
|
||||
constructor(filepath) {
|
||||
this.collection = require(filepath)
|
||||
}
|
||||
|
||||
get(id) {
|
||||
return this.collection.find(c => c.id === id)
|
||||
find(query) {
|
||||
return _.find(this.collection, query)
|
||||
}
|
||||
}
|
||||
|
||||
const api = {}
|
||||
|
||||
api.channels = new API('../data/channels.json')
|
||||
api.countries = new API('../data/countries.json')
|
||||
api.subdivisions = new API('../data/subdivisions.json')
|
||||
|
||||
module.exports = api
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue