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