diff --git a/sites/firstmedia.com/firstmedia.com.config.js b/sites/firstmedia.com/firstmedia.com.config.js index ec62c1a6..60039aca 100644 --- a/sites/firstmedia.com/firstmedia.com.config.js +++ b/sites/firstmedia.com/firstmedia.com.config.js @@ -9,9 +9,9 @@ module.exports = { site: 'firstmedia.com', days: 1, url: function ({ channel, date }) { - return `https://www.firstmedia.com/ajax/schedule?date=${date.format('DD/MM/YYYY')}&channel=${ + return `https://api.firstmedia.com/api/content/tv-guide/list?date=${date.format('DD/MM/YYYY')}&channel=${ channel.site_id - }&start_time=1&end_time=24&need_channels=0` + }&startTime=0&endTime=24` }, parser: function ({ content, channel }) { if (!content || !channel) return [] @@ -32,7 +32,7 @@ module.exports = { } function parseItems(content, channel) { - return JSON.parse(content.trim()).entries[channel] + return JSON.parse(content.trim()).data.entries[channel] || [] } function parseTitle(item) { @@ -44,9 +44,9 @@ function parseDescription(item) { } function parseStart(item) { - return dayjs.tz(item.start_time, 'YYYY-MM-DD HH:mm:ss', 'Asia/Jakarta') + return dayjs.tz(item.startTime, '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') + return dayjs.tz(item.endTime, '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 index 9e717c74..ca59291a 100644 --- a/sites/firstmedia.com/firstmedia.com.test.js +++ b/sites/firstmedia.com/firstmedia.com.test.js @@ -3,27 +3,27 @@ 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' } +const date = dayjs.utc('2023-11-04', 'DD/MM/YYYY').startOf('d') +const channel = { site_id: '243', xmltv_id: 'AlJazeeraEnglish.qa', 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' + 'https://api.firstmedia.com/api/content/tv-guide/list?date=04/11/2023&channel=243&startTime=0&endTime=24' ) }) 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"}]}}' + '{"data":{"entries":{"243":[{"createdAt":"2023-10-29T17:01:52.000Z","updatedAt":"2023-10-29T17:01:52.000Z","id":"044aebf7-7e14-4a8b-a7da-c401498d83f2","channelNo":"243","programmeId":null,"title":"People and Power: The Launderer P3","episode":null,"slug":"people-and-power-the-launderer-p3","date":"2023-11-03 17:00:00","startTime":"2023-11-04 12:30:00","endTime":"2023-11-04 13:00:00","length":1800,"description":"People and Power: The Launderer P3","long_description":"The concluding episode of a three part investigation into Mafia money laundering.","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"}]}}]}}}' 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', + start: '2023-11-04T05:30:00.000Z', + stop: '2023-11-04T06:00:00.000Z', + title: 'People and Power: The Launderer P3', 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." + "The concluding episode of a three part investigation into Mafia money laundering." } ]) })