2023-10-15 14:08:23 +03:00
|
|
|
const dayjs = require('dayjs')
|
|
|
|
|
const utc = require('dayjs/plugin/utc')
|
|
|
|
|
const timezone = require('dayjs/plugin/timezone')
|
|
|
|
|
|
|
|
|
|
dayjs.extend(utc)
|
|
|
|
|
dayjs.extend(timezone)
|
|
|
|
|
|
|
|
|
|
module.exports = {
|
|
|
|
|
site: 'osn.com',
|
|
|
|
|
days: 2,
|
2023-11-05 13:55:24 +07:00
|
|
|
headers({ channel }) {
|
|
|
|
|
return {
|
2023-10-15 14:08:23 +03:00
|
|
|
'Content-Type': 'application/json; charset=UTF-8',
|
2023-11-05 13:55:24 +07:00
|
|
|
Referer: `https://www.osn.com/${channel.lang}-ae/watch/tv-schedule`,
|
|
|
|
|
}
|
2023-10-15 14:08:23 +03:00
|
|
|
},
|
2023-11-05 13:55:24 +07:00
|
|
|
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=6`
|
|
|
|
|
},
|
|
|
|
|
parser({ content, channel }) {
|
|
|
|
|
const programs = []
|
2023-10-15 14:08:23 +03:00
|
|
|
const items = parseItems(content)
|
|
|
|
|
items.forEach(item => {
|
|
|
|
|
const start = parseStart(item, channel)
|
|
|
|
|
const duration = parseDuration(item)
|
|
|
|
|
const stop = start.add(duration, 'm')
|
|
|
|
|
programs.push({
|
|
|
|
|
title: parseTitle(item, channel),
|
|
|
|
|
category: parseCategory(item, channel),
|
|
|
|
|
start: start.toString(),
|
|
|
|
|
stop: stop.toString()
|
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
return programs
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function parseTitle(item, channel) {
|
|
|
|
|
return channel.lang === 'ar' ? item.Arab_Title : item.Title
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function parseCategory(item, channel) {
|
|
|
|
|
return channel.lang === 'ar' ? item.GenreArabicName : item.GenreEnglishName
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function parseDuration(item) {
|
|
|
|
|
return parseInt(item.TotalDivWidth / 4.8)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function parseStart(item) {
|
|
|
|
|
const time = item.StartDateTime
|
|
|
|
|
|
|
|
|
|
return dayjs.tz(time, 'DD MMM YYYY, HH:mm', 'Asia/Dubai')
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function parseItems(content) {
|
2023-11-05 13:55:24 +07:00
|
|
|
return content ? JSON.parse(content) : []
|
2023-10-15 14:08:23 +03:00
|
|
|
}
|