UNPKG

@phunky/scrape-channel-listings

Version:

A TypeScript library for scraping TV channel listings from various providers

24 lines (23 loc) 951 B
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.writeResultsToFiles = writeResultsToFiles; const fs_1 = __importDefault(require("fs")); const path_1 = __importDefault(require("path")); const OUTPUT_DIR = '../data'; /** * Writes scraper results to JSON files * @param results Array of scraper results to write */ function writeResultsToFiles(results) { const outputPath = path_1.default.join(__dirname, OUTPUT_DIR); fs_1.default.mkdirSync(outputPath, { recursive: true }); results.forEach(result => { if (result.success && result.channels) { const filePath = path_1.default.join(outputPath, `${result.name.toLowerCase()}.json`); fs_1.default.writeFileSync(filePath, JSON.stringify(result.channels, null, 2)); } }); }