mirror of
https://github.com/iptv-org/database.git
synced 2024-11-14 07:42:30 -05:00
22 lines
606 B
TypeScript
22 lines
606 B
TypeScript
|
import { Storage, File } from '@freearhey/core'
|
||
|
import { DATA_DIR, API_DIR } from '../constants'
|
||
|
import { CSVParser } from '../core'
|
||
|
|
||
|
async function main() {
|
||
|
const dataStorage = new Storage(DATA_DIR)
|
||
|
const apiStorage = new Storage(API_DIR)
|
||
|
const parser = new CSVParser()
|
||
|
|
||
|
const files = await dataStorage.list('*.csv')
|
||
|
for (const filepath of files) {
|
||
|
const file = new File(filepath)
|
||
|
const filename = file.name()
|
||
|
const data = await dataStorage.load(file.basename())
|
||
|
const items = await parser.parse(data)
|
||
|
|
||
|
await apiStorage.save(`${filename}.json`, items.toJSON())
|
||
|
}
|
||
|
}
|
||
|
|
||
|
main()
|