UNPKG

@phunky/scrape-channel-listings

Version:

A TypeScript library for scraping TV channel listings from various providers

51 lines (50 loc) 1.64 kB
"use strict"; /** * Freesat Channel Listing Scraper * Extracts channel numbers and names from Freesat HD channel lineup */ Object.defineProperty(exports, "__esModule", { value: true }); const scraper_1 = require("../utils/scraper"); /** * Extracts channel information from the Sky channel listing page * @param page - Playwright page instance * @returns Array of partial channel objects containing number and name */ const scrapeFunction = async (page) => { return await page.$$eval('table tbody tr', (rows) => { return rows.map((row) => { const number = row.querySelector('.column-1')?.textContent?.trim() || ''; const name = row.querySelector('.column-2')?.textContent?.trim() || ''; // Skip those with dashes in numbers as these are category definitions if (!name || !number || number.includes('-')) { return {}; } return { number, name }; }); }); }; /** * Channel name overrides to standardize naming across providers */ const overrides = { 'DISC. SCIENCE': 'Discovery Science', 'DISC. TURBO': 'Discovery Turbo', 'SKY CINEMA SCI-FI/HORROR': 'SKY CINEMA SCFI/HORROR', 'RTÉjr': 'RTE Junior', '5': 'Channel5', '5+1': 'Channel5+1', }; /** * Sky UK scraper configuration */ const config = { url: 'https://rxtvinfo.com/freesat-channel-list-uk/', scrapeFunction, overrides, outputFile: 'freesat.json' }; // Run scraper if this file is executed directly if (require.main === module) { (0, scraper_1.runScraperCLI)(config).catch(() => process.exit(1)); } exports.default = config;