diff --git a/sites/osn.com/osn.com.config.js b/sites/osn.com/osn.com.config.js index e1520c8b..7e44efe4 100644 --- a/sites/osn.com/osn.com.config.js +++ b/sites/osn.com/osn.com.config.js @@ -8,26 +8,20 @@ dayjs.extend(timezone) module.exports = { site: 'osn.com', days: 2, - url: 'https://www.osn.com/CMSPages/TVScheduleWebService.asmx/GetTVChannelsProgramTimeTable', + url({ channel, date }) { + return `https://www.osn.com/api/TVScheduleWebService.asmx/GetTVChannelsProgramTimeTable?newDate=${ + encodeURIComponent(date.format('MM/DD/YYYY')) + }&selectedCountry=AE&channelCode=${channel.site_id}&isMobile=false&hoursForMobile=0` + }, request: { - method: 'POST', - headers: { - 'Content-Type': 'application/json; charset=UTF-8', - Referer: 'https://www.osn.com' - }, - data({ channel, date }) { + headers({ channel }) { return { - newDate: date.format('MM/DD/YYYY'), - selectedCountry: 'AE', - channelCode: channel.site_id, - isMobile: false, - hoursForMobile: 0 + Referer: `https://www.osn.com/${channel.lang}-ae/watch/tv-schedule`, } }, - jar: null }, - parser: function ({ content, channel }) { - let programs = [] + parser({ content, channel }) { + const programs = [] const items = parseItems(content) items.forEach(item => { const start = parseStart(item, channel) @@ -42,6 +36,23 @@ module.exports = { }) return programs + }, + async channels({lang = 'ar'}) { + const axios = require('axios') + const result = await axios + .get('https://www.osn.com/api/tvchannels.ashx?culture=en-US&packageId=3519&country=AE') + .then(response => response.data) + .catch(console.error) + + const channels = result.map(channel => { + return { + lang: lang, + site_id: channel.channelCode, + name: channel.channeltitle + } + }) + + return channels } } @@ -64,8 +75,5 @@ function parseStart(item) { } function parseItems(content) { - if (!content) return [] - const json = JSON.parse(content) - - return json.d ? JSON.parse(json.d) : [] + return content ? JSON.parse(content) : [] } diff --git a/sites/osn.com/osn.com.test.js b/sites/osn.com/osn.com.test.js index 48266025..ed7be799 100644 --- a/sites/osn.com/osn.com.test.js +++ b/sites/osn.com/osn.com.test.js @@ -10,32 +10,19 @@ dayjs.extend(utc) const date = dayjs.utc('2021-10-24', 'YYYY-MM-DD').startOf('d') const channelAR = { site_id: 'AAN', xmltv_id: 'AlAanTV.ae', lang: 'ar' } const channelEN = { site_id: 'AAN', xmltv_id: 'AlAanTV.ae', lang: 'en' } -const content = JSON.stringify({ - d: '[{"IsPlaying":"0","Durationtime":null,"StartMinute":0,"EndMinute":0,"EmptyDivWidth":1152,"TotalDivWidth":576,"IsTodayDate":false,"IsLastRow":false,"StartDateTime":"24 Oct 2021, 22:00","EndDateTime":"\\/Date(-62135596800000)\\/","Title":"Al Aan TV","Arab_Title":"تلفزيون الآن","GenreEnglishName":null,"GenreArabicName":null,"ChannelNumber":140,"ChannelCode":"AAN","Duration":"\\/Date(-62135596800000)\\/","Showtime":"\\/Date(-62135596800000)\\/","EpisodeId":738257,"ProgramType":null,"EPGUNIQID":"AAN202110271800738257"}]' -}) - -it('can generate valid request data', () => { - const result = request.data({ channel: channelAR, date }) - expect(result).toMatchObject({ - newDate: '10/24/2021', - selectedCountry: 'AE', - channelCode: 'AAN', - isMobile: false, - hoursForMobile: 0 - }) -}) +const content = '[{"IsPlaying":"0","Durationtime":null,"StartMinute":0,"EndMinute":0,"EmptyDivWidth":1152,"TotalDivWidth":576,"IsTodayDate":false,"IsLastRow":false,"StartDateTime":"24 Oct 2021, 22:00","EndDateTime":"\\/Date(-62135596800000)\\/","Title":"Al Aan TV","Arab_Title":"تلفزيون الآن","GenreEnglishName":null,"GenreArabicName":null,"ChannelNumber":140,"ChannelCode":"AAN","Duration":"\\/Date(-62135596800000)\\/","Showtime":"\\/Date(-62135596800000)\\/","EpisodeId":738257,"ProgramType":null,"EPGUNIQID":"AAN202110271800738257"}]' it('can generate valid request headers', () => { - const result = request.headers + const result = request.headers({ channel: channelAR, date }) expect(result).toMatchObject({ - 'Content-Type': 'application/json; charset=UTF-8', - Referer: 'https://www.osn.com' + Referer: 'https://www.osn.com/ar-ae/watch/tv-schedule' }) }) it('can generate valid url', () => { - expect(url).toBe( - 'https://www.osn.com/CMSPages/TVScheduleWebService.asmx/GetTVChannelsProgramTimeTable' + const result = url({ channel: channelAR, date }) + expect(result).toBe( + 'https://www.osn.com/api/TVScheduleWebService.asmx/GetTVChannelsProgramTimeTable?newDate=10%2F24%2F2021&selectedCountry=AE&channelCode=AAN&isMobile=false&hoursForMobile=0' ) }) @@ -64,6 +51,6 @@ it('can parse response (en)', () => { }) it('can handle empty guide', () => { - const result = parser({ date, channel: channelAR, content: JSON.stringify({ d: '[]' }) }) + const result = parser({ date, channel: channelAR, content: '[]' }) expect(result).toMatchObject([]) }) diff --git a/sites/osn.com/osn.com_ar.channels.xml b/sites/osn.com/osn.com_ar.channels.xml index 4c123011..695646e6 100644 --- a/sites/osn.com/osn.com_ar.channels.xml +++ b/sites/osn.com/osn.com_ar.channels.xml @@ -1,64 +1,33 @@ + Kapatid TV5 - Al Aan TV - Al Dafrah TV Alfa Series +2 Alfa Series Channel - AL Hurra HD - AlMamlaka TV Al Safwa - Al Wosta from Al Dhaid - Al Yawm + Alfa Al Yawm ANC - Arirang TV - ART Aflam 1 - ART Aflam 2 - ART Cinema - Hekayat - Hekayat 2 - B4U Aflam - B4U Plus - BabyTV Europe - Bahrain TV - BBC Arabic - BBC World + BabyTV Bloomberg - CGTN - CGTN Arabic - Cinema 1 - Cinema 2 + Alfa Cinema 1 + Alfa Cinema 2 Cinema One Global Cine Mo - CNBC Arabia CNBC - Crime + Investigation Network + CNN + Crime & Investigation Network Discovery HD Discovery Science HD Disney HD Disney Junior - Dubai Racing 1 HD - Dubai Racing 3 - E! Entertainment HD - Fann - France 24 - France 24 English + E! Entertainment + Alfa Fann GMA Life TV GMA News TV GMA Pinoy TV H2 HD History HD Discovery ID - KTV1 HD - KTV2 HD - KTV Majlis HD - Al Qurain HD - KTV Arabe HD - KTV Ethraa HD - KTV Sport HD - KTV Sport Plus HD - Madani TV - Marina TV Moonbug Kids MTV 00s MTV Live HD @@ -66,39 +35,32 @@ Myx Nat Geo HD Nat Geo Wild HD - NHK World TV Nickelodeon HD - Nick Jr + Nick Jr. NickToons HD - OSN Comedy - OSN Family - OSN Kids - OSN Kidzone - OSN Living - OSN Mezze - OSN Movies Action - OSN Movies Hollywood - OSN Movies Premiere - OSN Movies Premiere +2 - OSN News - OSN Popup - OSN Series Prime - OSN Showcase - OSN W - OSN Yahala - OSN Yahala Aflam - OSN Yahala Bil Arabi + OSN TV Comedy + OSN TV Crime + OSN TV Kids + OSN TV Kidzone + OSN TV Mezze + OSN TV Movies Action + OSN TV Movies Comedy + OSN TV Movies Family + OSN TV Movies Hollywood + OSN TV Movies Premiere + OSN TV News + OSN TV Now + OSN TV One + OSN TV Showcase + OSN TV Showcase Classics + OSN TV Yahala + OSN TV Yahala Aflam + OSN TV Yahala Bil Arabi PBA Rush - Al Roya TV - Rusiya Al Yawm - Sharjah Sport HD - Sharjah TV - Sharqiya from Kalba - Sky News Arabia Sky News HD Star Movies HD Star World HD DZMM Teleradyo TFC TLC HD - \ No newline at end of file + diff --git a/sites/osn.com/osn.com_en.channels.xml b/sites/osn.com/osn.com_en.channels.xml index d69387d3..3fb3f61d 100644 --- a/sites/osn.com/osn.com_en.channels.xml +++ b/sites/osn.com/osn.com_en.channels.xml @@ -1,64 +1,33 @@ + Kapatid TV5 - Al Aan TV - Al Dafrah TV Alfa Series +2 Alfa Series Channel - AL Hurra HD - AlMamlaka TV Al Safwa - Al Wosta from Al Dhaid - Al Yawm + Alfa Al Yawm ANC - Arirang TV - ART Aflam 1 - ART Aflam 2 - ART Cinema - Hekayat - Hekayat 2 - B4U Aflam - B4U Plus - BabyTV Europe - Bahrain TV - BBC Arabic - BBC World + BabyTV Bloomberg - CGTN - CGTN Arabic - Cinema 1 - Cinema 2 + Alfa Cinema 1 + Alfa Cinema 2 Cinema One Global Cine Mo - CNBC Arabia CNBC - Crime + Investigation Network + CNN + Crime & Investigation Network Discovery HD Discovery Science HD Disney HD Disney Junior - Dubai Racing 1 HD - Dubai Racing 3 - E! Entertainment HD - Fann - France 24 - France 24 English + E! Entertainment + Alfa Fann GMA Life TV GMA News TV GMA Pinoy TV H2 HD History HD Discovery ID - KTV1 HD - KTV2 HD - KTV Majlis HD - Al Qurain HD - KTV Arabe HD - KTV Ethraa HD - KTV Sport HD - KTV Sport Plus HD - Madani TV - Marina TV Moonbug Kids MTV 00s MTV Live HD @@ -66,39 +35,32 @@ Myx Nat Geo HD Nat Geo Wild HD - NHK World TV Nickelodeon HD - Nick Jr + Nick Jr. NickToons HD - OSN Comedy - OSN Family - OSN Kids - OSN Kidzone - OSN Living - OSN Mezze - OSN Movies Action - OSN Movies Hollywood - OSN Movies Premiere - OSN Movies Premiere +2 - OSN News - OSN Popup - OSN Series Prime - OSN Showcase - OSN W - OSN Yahala - OSN Yahala Aflam - OSN Yahala Bil Arabi + OSN TV Comedy + OSN TV Crime + OSN TV Kids + OSN TV Kidzone + OSN TV Mezze + OSN TV Movies Action + OSN TV Movies Comedy + OSN TV Movies Family + OSN TV Movies Hollywood + OSN TV Movies Premiere + OSN TV News + OSN TV Now + OSN TV One + OSN TV Showcase + OSN TV Showcase Classics + OSN TV Yahala + OSN TV Yahala Aflam + OSN TV Yahala Bil Arabi PBA Rush - Al Roya TV - Rusiya Al Yawm - Sharjah Sport HD - Sharjah TV - Sharqiya from Kalba - Sky News Arabia Sky News HD Star Movies HD Star World HD DZMM Teleradyo TFC TLC HD - \ No newline at end of file +