mirror of
https://github.com/iptv-org/epg.git
synced 2025-05-09 16:40:07 -04:00
Fixes linter errors
This commit is contained in:
parent
57e508fc3b
commit
63c86a2b30
393 changed files with 28447 additions and 28443 deletions
|
@ -1,71 +1,71 @@
|
|||
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,
|
||||
url: 'https://www.osn.com/CMSPages/TVScheduleWebService.asmx/GetTVChannelsProgramTimeTable',
|
||||
request: {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json; charset=UTF-8',
|
||||
Referer: 'https://www.osn.com'
|
||||
},
|
||||
data({ channel, date }) {
|
||||
return {
|
||||
newDate: date.format('MM/DD/YYYY'),
|
||||
selectedCountry: 'AE',
|
||||
channelCode: channel.site_id,
|
||||
isMobile: false,
|
||||
hoursForMobile: 0
|
||||
}
|
||||
},
|
||||
jar: null
|
||||
},
|
||||
parser: function ({ content, channel }) {
|
||||
let programs = []
|
||||
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) {
|
||||
if (!content) return []
|
||||
const json = JSON.parse(content)
|
||||
|
||||
return json.d ? JSON.parse(json.d) : []
|
||||
}
|
||||
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,
|
||||
url: 'https://www.osn.com/CMSPages/TVScheduleWebService.asmx/GetTVChannelsProgramTimeTable',
|
||||
request: {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json; charset=UTF-8',
|
||||
Referer: 'https://www.osn.com'
|
||||
},
|
||||
data({ channel, date }) {
|
||||
return {
|
||||
newDate: date.format('MM/DD/YYYY'),
|
||||
selectedCountry: 'AE',
|
||||
channelCode: channel.site_id,
|
||||
isMobile: false,
|
||||
hoursForMobile: 0
|
||||
}
|
||||
},
|
||||
jar: null
|
||||
},
|
||||
parser: function ({ content, channel }) {
|
||||
let programs = []
|
||||
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) {
|
||||
if (!content) return []
|
||||
const json = JSON.parse(content)
|
||||
|
||||
return json.d ? JSON.parse(json.d) : []
|
||||
}
|
||||
|
|
|
@ -1,69 +1,69 @@
|
|||
// NODE_OPTIONS=--insecure-http-parser npx epg-grabber --config=sites/osn.com/osn.com.config.js --channels=sites/osn.com/osn.com.channels.xml --output=guide.xml --days=2
|
||||
|
||||
const { parser, url, request } = require('./osn.com.config.js')
|
||||
const dayjs = require('dayjs')
|
||||
const utc = require('dayjs/plugin/utc')
|
||||
const customParseFormat = require('dayjs/plugin/customParseFormat')
|
||||
dayjs.extend(customParseFormat)
|
||||
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
|
||||
})
|
||||
})
|
||||
|
||||
it('can generate valid request headers', () => {
|
||||
const result = request.headers
|
||||
expect(result).toMatchObject({
|
||||
'Content-Type': 'application/json; charset=UTF-8',
|
||||
Referer: 'https://www.osn.com'
|
||||
})
|
||||
})
|
||||
|
||||
it('can generate valid url', () => {
|
||||
expect(url).toBe(
|
||||
'https://www.osn.com/CMSPages/TVScheduleWebService.asmx/GetTVChannelsProgramTimeTable'
|
||||
)
|
||||
})
|
||||
|
||||
it('can parse response (ar)', () => {
|
||||
const result = parser({ date, channel: channelAR, content })
|
||||
expect(result).toMatchObject([
|
||||
{
|
||||
start: 'Sun, 24 Oct 2021 18:00:00 GMT',
|
||||
stop: 'Sun, 24 Oct 2021 20:00:00 GMT',
|
||||
title: 'تلفزيون الآن',
|
||||
category: null
|
||||
}
|
||||
])
|
||||
})
|
||||
|
||||
it('can parse response (en)', () => {
|
||||
const result = parser({ date, channel: channelEN, content })
|
||||
expect(result).toMatchObject([
|
||||
{
|
||||
start: 'Sun, 24 Oct 2021 18:00:00 GMT',
|
||||
stop: 'Sun, 24 Oct 2021 20:00:00 GMT',
|
||||
title: 'Al Aan TV',
|
||||
category: null
|
||||
}
|
||||
])
|
||||
})
|
||||
|
||||
it('can handle empty guide', () => {
|
||||
const result = parser({ date, channel: channelAR, content: JSON.stringify({ d: '[]' }) })
|
||||
expect(result).toMatchObject([])
|
||||
})
|
||||
// NODE_OPTIONS=--insecure-http-parser npx epg-grabber --config=sites/osn.com/osn.com.config.js --channels=sites/osn.com/osn.com.channels.xml --output=guide.xml --days=2
|
||||
|
||||
const { parser, url, request } = require('./osn.com.config.js')
|
||||
const dayjs = require('dayjs')
|
||||
const utc = require('dayjs/plugin/utc')
|
||||
const customParseFormat = require('dayjs/plugin/customParseFormat')
|
||||
dayjs.extend(customParseFormat)
|
||||
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
|
||||
})
|
||||
})
|
||||
|
||||
it('can generate valid request headers', () => {
|
||||
const result = request.headers
|
||||
expect(result).toMatchObject({
|
||||
'Content-Type': 'application/json; charset=UTF-8',
|
||||
Referer: 'https://www.osn.com'
|
||||
})
|
||||
})
|
||||
|
||||
it('can generate valid url', () => {
|
||||
expect(url).toBe(
|
||||
'https://www.osn.com/CMSPages/TVScheduleWebService.asmx/GetTVChannelsProgramTimeTable'
|
||||
)
|
||||
})
|
||||
|
||||
it('can parse response (ar)', () => {
|
||||
const result = parser({ date, channel: channelAR, content })
|
||||
expect(result).toMatchObject([
|
||||
{
|
||||
start: 'Sun, 24 Oct 2021 18:00:00 GMT',
|
||||
stop: 'Sun, 24 Oct 2021 20:00:00 GMT',
|
||||
title: 'تلفزيون الآن',
|
||||
category: null
|
||||
}
|
||||
])
|
||||
})
|
||||
|
||||
it('can parse response (en)', () => {
|
||||
const result = parser({ date, channel: channelEN, content })
|
||||
expect(result).toMatchObject([
|
||||
{
|
||||
start: 'Sun, 24 Oct 2021 18:00:00 GMT',
|
||||
stop: 'Sun, 24 Oct 2021 20:00:00 GMT',
|
||||
title: 'Al Aan TV',
|
||||
category: null
|
||||
}
|
||||
])
|
||||
})
|
||||
|
||||
it('can handle empty guide', () => {
|
||||
const result = parser({ date, channel: channelAR, content: JSON.stringify({ d: '[]' }) })
|
||||
expect(result).toMatchObject([])
|
||||
})
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue