From 74bff45c3403875d60fce82100eb8b020c7e97b4 Mon Sep 17 00:00:00 2001 From: Toha Date: Wed, 29 Apr 2026 21:37:46 +0700 Subject: [PATCH] Site `firstmedia.com` is retired. Signed-off-by: Toha --- sites/firstmedia.com/__data__/content.json | 1 - .../firstmedia.com.channels.xml | 119 ------------------ sites/firstmedia.com/firstmedia.com.config.js | 102 --------------- sites/firstmedia.com/firstmedia.com.test.js | 38 ------ sites/firstmedia.com/readme.md | 21 ---- 5 files changed, 281 deletions(-) delete mode 100644 sites/firstmedia.com/__data__/content.json delete mode 100644 sites/firstmedia.com/firstmedia.com.channels.xml delete mode 100644 sites/firstmedia.com/firstmedia.com.config.js delete mode 100644 sites/firstmedia.com/firstmedia.com.test.js delete mode 100644 sites/firstmedia.com/readme.md diff --git a/sites/firstmedia.com/__data__/content.json b/sites/firstmedia.com/__data__/content.json deleted file mode 100644 index c6ec2901d..000000000 --- a/sites/firstmedia.com/__data__/content.json +++ /dev/null @@ -1 +0,0 @@ -{"data":{"entries":{"243":[{"createdAt":"2023-11-05T17:09:34.000Z","updatedAt":"2023-11-05T17:09:34.000Z","id":"009f3a34-8164-4ff9-b981-9dcab1a518fc","channelNo":"243","programmeId":null,"title":"News Live","episode":null,"slug":"news-live","date":"2023-11-08 17:00:00","startTime":"2023-11-08 20:00:00","endTime":"2023-11-08 20:30:00","length":1800,"description":"News Live","long_description":"Up to date news and analysis from around the world.","status":true,"channel":{"id":"7fd7a9a6-af32-c861-d2b0-4ddc7846fad2","key":"AljaInt","no":243,"name":"Al Jazeera International","slug":"al-jazeera-international","website":null,"description":"

An international 24-hour English-language It is the first English-language news channel brings you the latest global news stories, analysis from the Middle East & worldwide.

","shortDescription":null,"logo":"files/logos/channels/11-NEWS/AlJazeera Int SD-FirstMedia-Chl-243.jpg","externalId":"132","type":"radio","status":true,"chanel":"SD","locale":"id","relationId":"5a6ea4ae-a008-4889-9c68-7a6f1838e81d","onlyfm":null,"genress":[{"id":"1db3bb43-b00d-49af-b272-6c058a8c0b49","name":"International Free View"},{"id":"2e81a4bd-9719-4186-820a-7e035e07be13","name":"News"}]}}]}}} \ No newline at end of file diff --git a/sites/firstmedia.com/firstmedia.com.channels.xml b/sites/firstmedia.com/firstmedia.com.channels.xml deleted file mode 100644 index 39c5921ba..000000000 --- a/sites/firstmedia.com/firstmedia.com.channels.xml +++ /dev/null @@ -1,119 +0,0 @@ - - - BTV - Investor Daily - First Llifestyle - NET. - Metro TV - SCTV - Indosiar - ANTV - TV One - Kompas TV - TVRI Nasional - Jawa Pos Media Televisi - JTV - Reformed 21 - Kairos - Sekolah Pelita Harapan Channel - SPH - Liga Mahasiswa - MOJI - DAAI TV - Eternal Word Television Network (EWTN) - KaraOKE Channel - Balai Kota Channel - Balai Kota Bandung - Rajawali TV - MNC News - TV9 - Garuda TV - Al Quran Al Kareem - Sunnah TV - West Java Network - AXN - Animax - GTV - Rock Action - Euronews - TBN Asia - Jakarta TV - Jak TV - iNews - The Learning Channel - TLC - Asian Food Network - IMC - Fashion TV - GMS Channel - Discovery Channel - Animal Planet - Nick jr. - Nickelodeon - Cartoon Network - SPOTV - SPOTV 2 - Champions TV 1 - Champions TV 2 - First Football - Eurosport - Star Gold - Zee Bioskop - Star Plus - ZEE TV - Zee Cinema - Wion - Zee Action - TVB Xing He - Phoenix Info News - Phoenix Chinese Channel - Celestial Movies - ONE - Xing Kong China - Zhejiang TV - CCTV 4 - CGTN - TVBS Asia - TVBS News - Hunan TV - Dragon TV - Jiangsu TV - ANHUI TV - Shenzen TV - MTV 90s - DW English - Arirang - BBC World News - CNN International - Fox News - Russia Today - Bloomberg - TRT World - Channel News Asia - Al Jazeera International - KBS World - Al Jazeera Arabic - France 24 - NHK World Premium - ABC Australia - Rai Italia - TV5 Monde - HBO - HBO Signature - HBO Hits - HBO Family - Cinemax - First Atmos HD - First Highlights HD - Jakarta Globe News Channel HD - First Lifestyle HD - HBO HD - HBO Hits HD - HBO Family HD - HBO Signature HD - Cinemax HD - Celestial Movies HD - Warner TV HD - Eurosport HD - Champions TV 1 HD - Champions TV 2 HD - HITS Now HD - Hits Movies HD - HITS HD - diff --git a/sites/firstmedia.com/firstmedia.com.config.js b/sites/firstmedia.com/firstmedia.com.config.js deleted file mode 100644 index 7c6865fc8..000000000 --- a/sites/firstmedia.com/firstmedia.com.config.js +++ /dev/null @@ -1,102 +0,0 @@ -const dayjs = require('dayjs') -const timezone = require('dayjs/plugin/timezone') -const utc = require('dayjs/plugin/utc') - -dayjs.extend(timezone) -dayjs.extend(utc) - -module.exports = { - site: 'firstmedia.com', - days: 2, - url({ channel, date }) { - return `https://api.firstmedia.com/api/content/tv-guide/list?date=${date.format( - 'DD/MM/YYYY' - )}&channel=${channel.site_id}&startTime=1&endTime=24` - }, - parser({ content, channel, date }) { - if (!content || !channel || !date) return [] - - const programs = [] - const items = parseItems(content, channel.site_id) - .map(item => { - item.start = toDelta(item.date, item.startTime) - item.stop = toDelta(item.date, item.endTime) - return item - }) - .sort((a, b) => a.start - b.start) - - const dt = date.tz('Asia/Jakarta').startOf('d') - let lastStop - items.forEach(item => { - if (lastStop === undefined || item.start >= lastStop) { - lastStop = item.stop - programs.push({ - title: parseTitle(item), - description: parseDescription(item), - start: asDate(parseStart({ item, date: dt })), - stop: asDate(parseStop({ item, date: dt })) - }) - } - }) - - return programs - }, - async channels() { - const axios = require('axios') - const result = await axios - .get( - `https://api.firstmedia.com/api/content/tv-guide/list?date=${dayjs().format( - 'DD/MM/YYYY' - )}&channel=&startTime=0&endTime=24` - ) - .then(response => response.data) - .catch(console.error) - - const channels = [] - if (result.data && result.data.entries) { - Object.values(result.data.entries).forEach(schedules => { - if (schedules.length) { - channels.push({ - lang: 'en', - site_id: schedules[0].channel.no, - name: schedules[0].channel.name - }) - } - }) - } - - return channels - } -} - -function parseItems(content, channel) { - return JSON.parse(content.trim()).data.entries[channel] || [] -} - -function parseTitle(item) { - return item.title -} - -function parseDescription(item) { - return item.long_description -} - -function parseStart({ item, date }) { - return date.add(item.start, 'ms') -} - -function parseStop({ item, date }) { - return date.add(item.stop, 'ms') -} - -function toDelta(from, to) { - return toDate(to).diff(toDate(from), 'milliseconds') -} - -function toDate(date) { - return dayjs(date, 'YYYY-MM-DD HH:mm:ss') -} - -function asDate(date) { - return date.toISOString() -} diff --git a/sites/firstmedia.com/firstmedia.com.test.js b/sites/firstmedia.com/firstmedia.com.test.js deleted file mode 100644 index 21bdd7b87..000000000 --- a/sites/firstmedia.com/firstmedia.com.test.js +++ /dev/null @@ -1,38 +0,0 @@ -const { url, parser } = require('./firstmedia.com.config.js') -const fs = require('fs') -const path = require('path') -const dayjs = require('dayjs') -const utc = require('dayjs/plugin/utc') -dayjs.extend(utc) - -const date = dayjs.utc('2023-11-08').startOf('d') -const channel = { site_id: '243', xmltv_id: 'AlJazeeraEnglish.qa', lang: 'id' } - -it('can generate valid url', () => { - expect(url({ channel, date })).toBe( - 'https://api.firstmedia.com/api/content/tv-guide/list?date=08/11/2023&channel=243&startTime=1&endTime=24' - ) -}) - -it('can parse response', () => { - const content = fs.readFileSync(path.resolve(__dirname, '__data__/content.json'), 'utf8') - const results = parser({ content, channel, date }) - - // All time in Asia/Jakarta - // 2023-11-08 17:00:00 -> 2023-11-08 20:00:00 = 2023-11-08 03:00:00 - // 2023-11-08 17:00:00 -> 2023-11-08 20:30:00 = 2023-11-08 03:30:00 - expect(results).toMatchObject([ - { - start: '2023-11-07T20:00:00.000Z', - stop: '2023-11-07T20:30:00.000Z', - title: 'News Live', - description: 'Up to date news and analysis from around the world.' - } - ]) -}) - -it('can handle empty guide', () => { - const results = parser({ content: '' }) - - expect(results).toMatchObject([]) -}) diff --git a/sites/firstmedia.com/readme.md b/sites/firstmedia.com/readme.md deleted file mode 100644 index 66e2bc2d1..000000000 --- a/sites/firstmedia.com/readme.md +++ /dev/null @@ -1,21 +0,0 @@ -# firstmedia.com - -https://www.firstmedia.com/product/tv-guide - -### Download the guide - -```sh -npm run grab --- --sites=firstmedia.com -``` - -### Update channel list - -```sh -npm run channels:parse --- --config=./sites/firstmedia.com/firstmedia.com.config.js --output=./sites/firstmedia.com/firstmedia.com.channels.xml -``` - -### Test - -```sh -npm test --- firstmedia.com -```