mirror of
https://github.com/iptv-org/database.git
synced 2024-11-09 22:16:38 -05:00
Update db/export.js
This commit is contained in:
parent
46c9fcf345
commit
57f2dd2cb8
2 changed files with 11 additions and 7 deletions
2
.github/workflows/deploy.yml
vendored
2
.github/workflows/deploy.yml
vendored
|
@ -22,7 +22,7 @@ jobs:
|
||||||
with:
|
with:
|
||||||
repository-name: iptv-org/api
|
repository-name: iptv-org/api
|
||||||
branch: gh-pages
|
branch: gh-pages
|
||||||
folder: .gh-pages
|
folder: .api
|
||||||
token: ${{ steps.create-app-token.outputs.token }}
|
token: ${{ steps.create-app-token.outputs.token }}
|
||||||
git-config-name: iptv-bot[bot]
|
git-config-name: iptv-bot[bot]
|
||||||
git-config-email: 84861620+iptv-bot[bot]@users.noreply.github.com
|
git-config-email: 84861620+iptv-bot[bot]@users.noreply.github.com
|
||||||
|
|
|
@ -1,14 +1,18 @@
|
||||||
const { csv, file } = require('../core')
|
const { csv, file, logger } = require('../core')
|
||||||
|
const chalk = require('chalk')
|
||||||
|
|
||||||
const DATA_DIR = process.env.DATA_DIR || './data'
|
const DATA_DIR = process.env.DATA_DIR || './data'
|
||||||
const OUTPUT_DIR = process.env.OUTPUT_DIR || './.gh-pages'
|
const OUTPUT_DIR = process.env.OUTPUT_DIR || './.api'
|
||||||
|
|
||||||
async function main() {
|
async function main() {
|
||||||
const files = await file.list(`${DATA_DIR}/*.csv`)
|
const files = await file.list(`${DATA_DIR}/*.csv`)
|
||||||
for (const inputFile of files) {
|
for (const filepath of files) {
|
||||||
const inputFilename = file.getFilename(inputFile)
|
const filename = file.getFilename(filepath)
|
||||||
const json = await csv.load(inputFile)
|
const json = await csv.load(filepath).catch(err => {
|
||||||
await file.create(`${OUTPUT_DIR}/${inputFilename}.json`, JSON.stringify(json))
|
logger.error(chalk.red(`\n${err.message} (${filepath})`))
|
||||||
|
process.exit(1)
|
||||||
|
})
|
||||||
|
await file.create(`${OUTPUT_DIR}/${filename}.json`, JSON.stringify(json))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue