mirror of
https://github.com/iptv-org/database.git
synced 2024-11-24 19:51:25 -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:
|
||||
repository-name: iptv-org/api
|
||||
branch: gh-pages
|
||||
folder: .gh-pages
|
||||
folder: .api
|
||||
token: ${{ steps.create-app-token.outputs.token }}
|
||||
git-config-name: iptv-bot[bot]
|
||||
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 OUTPUT_DIR = process.env.OUTPUT_DIR || './.gh-pages'
|
||||
const OUTPUT_DIR = process.env.OUTPUT_DIR || './.api'
|
||||
|
||||
async function main() {
|
||||
const files = await file.list(`${DATA_DIR}/*.csv`)
|
||||
for (const inputFile of files) {
|
||||
const inputFilename = file.getFilename(inputFile)
|
||||
const json = await csv.load(inputFile)
|
||||
await file.create(`${OUTPUT_DIR}/${inputFilename}.json`, JSON.stringify(json))
|
||||
for (const filepath of files) {
|
||||
const filename = file.getFilename(filepath)
|
||||
const json = await csv.load(filepath).catch(err => {
|
||||
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