diff --git a/sites/firstmedia.com/firstmedia.com.channels.xml b/sites/firstmedia.com/firstmedia.com.channels.xml new file mode 100644 index 00000000..3b561626 --- /dev/null +++ b/sites/firstmedia.com/firstmedia.com.channels.xml @@ -0,0 +1,193 @@ + + + + ABC Australia + Al Jazeera Arabic + Al Jazeera International + Al Quran Al Kareem + ANHUI TV + Animal Planet + Animax + ANTV + Arirang + Asian Food Network + AXN + BabyFirst + + + Berita Satu + Berita Satu World + + BLOOMBERG TELEVISION + Boomerang HD + Cartoon Network + CCTV 4 + Celestial Movie + CGTN + CGTN Documentary HD + Champions TV 1 + Champions TV 2 + Champions TV 3 + Champions TV 4 SD + Channel News Asia + Cinema World HD + Cinemax + Citra Biskop HD + Citra Dangdut HD + CItra Drama HD + Citra Entertainment HD + Citra Muslim HD + + Crime + Investigation HD + Da Vinci HD + DAAI TV + Discovery Asia HD + Discovery Channel + + DMAX HD + Dragon TV + Dream Works HD + DW Deutsch + DW English + eGG Channel + Eternal Word Television + Network (EWTN)) + Euronews + + Fashion TV + + Food Network HD + Fox News + France 24 + Galaxy HD + Galaxy Premium HD + Garuda TV + GEM + GMS Channel + GTV + HBO + HBO Family + HBO Hits + HBO Signature + HGTV HD + History HD + HITS HD + HITS MOVIES HD + + + Horee! HD + Hunan TV + IDX Channel HD + IMC + Indosiar + iNews + + Jakarta TV - Jak TV + Jawa Pos Media Televisi - JTV + Jiangsu TV + + KBS World + KIX HD + Kompas TV + Lifetime HD + + + Love Nature 4K + Love Nature HD + + Metro Globe Network - MGN + Metro TV + MNC News + MTV Asia + MTV Live HD + MyZen TV HD + National + Geographic Channel + National + Geographic Wild + NET. + NHK World Japan HD + NHK World Premium + Nick jr. + Nickelodeon + O Channel + ONE + Paramount Network + HD + Phoenix Chinese Channel + Phoenix Info News + + Premier Sports + Rai Italia + Rajawali TV + Reformed 21 + Rock Entertainment HD + Rock Extreme + Russia Today + SCTV + SEA Today HD + + + Shine + Smithsonian HD + SPOTV + SPOTV 2 + Star Chinese Channel + Star Gold + Star Plus + Stingray Djazz HD + Stingray Festival 4K + + Stingray Naturescape HD + Stingray Now 4K + + Sunnah TV + TBN Asia + Tech Storm HD + The Learning Channel - TLC + TRANS 7 + TRANS TV + TRT World + + TV 5 Monde Style HD + TV One + TV PARLEMEN + TV5 Monde + TV9 + TVB Xing He + TVBS Asia + TVBS News + TVN HD + TVN Movies HD + TVRI Nasional + USA Today HD + + Wion + Xing Kong China + Zee Action + Zee Bioskop + Zee Bollywood + Zee Cinema + ZEE TV + Zhejiang TV + + \ No newline at end of file diff --git a/sites/firstmedia.com/firstmedia.com.config.js b/sites/firstmedia.com/firstmedia.com.config.js new file mode 100644 index 00000000..ef23c35f --- /dev/null +++ b/sites/firstmedia.com/firstmedia.com.config.js @@ -0,0 +1,49 @@ +const dayjs = require("dayjs"); +const timezone = require("dayjs/plugin/timezone"); +dayjs.extend(timezone); + +module.exports = { + site: "firstmedia.com", + days: 2, + url: function ({ channel, date }) { + return `https://www.firstmedia.com/ajax/schedule?date=${ + date.format("DD/MM/YYYY") + }&channel=${channel.site_id}&start_time=1&end_time=24&need_channels=0`; + }, + parser: function ({ content, channel }) { + if (!content || !channel) return []; + + let programs = []; + const items = parseItems(content, channel.site_id); + items.forEach((item) => { + programs.push({ + title: parseTitle(item), + description: parseDescription(item), + start: parseStart(item).toISOString(), + stop: parseStop(item).toISOString(), + }); + }); + + return programs; + }, +}; + +function parseItems(content, channel) { + return JSON.parse(content).entries[channel]; +} + +function parseTitle(item) { + return item.title; +} + +function parseDescription(item) { + return item.long_description; +} + +function parseStart(item) { + return dayjs.tz(item.start_time, "YYYY-MM-DD HH:mm:ss", "Asia/Jakarta"); +} + +function parseStop(item) { + return dayjs.tz(item.end_time, "YYYY-MM-DD HH:mm:ss", "Asia/Jakarta"); +} diff --git a/sites/firstmedia.com/firstmedia.com.test.js b/sites/firstmedia.com/firstmedia.com.test.js new file mode 100644 index 00000000..a705106b --- /dev/null +++ b/sites/firstmedia.com/firstmedia.com.test.js @@ -0,0 +1,31 @@ +const { url, parser } = require('./firstmedia.com.config.js') +const dayjs = require('dayjs') +const utc = require('dayjs/plugin/utc') +dayjs.extend(utc) + +const date = dayjs.utc('2023-06-18', 'DD/MM/YYYY').startOf('d') +const channel = { site_id: '251', xmltv_id: 'ABCAustralia.au', lang: 'id' } + +it('can generate valid url', () => { + expect(url({ channel, date })).toBe('https://www.firstmedia.com/ajax/schedule?date=18/06/2023&channel=251&start_time=1&end_time=24&need_channels=0') +}) + +it('can parse response', () => { + const content = `{"entries":{"251":[{"logo":"files/images/d/new-logo/channels/11-NEWS/ABC Australia SD-FirstMedia-Chl-251.jpg","name":"ABC Australia","id":"2a800e8a-fdcc-47b3-a4a6-58d1d122b326","channel_id":"a1840c59-6c92-8233-3a02-230246aae0c4","channel_no":251,"programme_id":null,"episode":null,"title":"China Tonight","slug":null,"date":"2023-06-13 00:00:00","start_time":"2023-06-13 10:55:00","end_time":"2023-06-13 11:30:00","length":2100,"description":"China Tonight","long_description":"China is a superpower that dominates global news but it's also home to 1.4 billion stories. Sam Yang is back for a new season, hearing from the people who make this extraordinary nation what it is today.","status":"0","created_by":null,"updated_by":null,"created_at":"2023-06-13 00:20:24","updated_at":"2023-06-13 00:20:24"}]}}` + const results = parser({ content, channel }) + + expect(results).toMatchObject([ + { + start: '2023-06-13T03:55:00.000Z', + stop: '2023-06-13T04:30:00.000Z', + title: 'China Tonight', + description: 'China is a superpower that dominates global news but it\'s also home to 1.4 billion stories. Sam Yang is back for a new season, hearing from the people who make this extraordinary nation what it is today.' + } + ]) +}) + +it('can handle empty guide', () => { + const results = parser({ content: '' }) + + expect(results).toMatchObject([]) +}) \ No newline at end of file