mirror of
https://github.com/iptv-org/epg
synced 2026-05-09 02:47:00 -04:00
4897
sites/ayn.om/__data__/content.html
Normal file
4897
sites/ayn.om/__data__/content.html
Normal file
File diff suppressed because it is too large
Load Diff
2091
sites/ayn.om/__data__/no_content.html
Normal file
2091
sites/ayn.om/__data__/no_content.html
Normal file
File diff suppressed because it is too large
Load Diff
7
sites/ayn.om/ayn.om.channels.xml
Normal file
7
sites/ayn.om/ayn.om.channels.xml
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<channels>
|
||||||
|
<channel site="ayn.om" site_id="158/قناة-عمان-العامة" lang="ar" xmltv_id="OmanTV.om">قناة عمان العامة</channel>
|
||||||
|
<channel site="ayn.om" site_id="159/قناة-عمان-الرياضية" lang="ar" xmltv_id="OmanSportsTV.om">قناة عمان الرياضية</channel>
|
||||||
|
<channel site="ayn.om" site_id="160/قناة-عمان-الثقافية" lang="ar" xmltv_id="OmanTVCultural.om">قناة عمان الثقافية</channel>
|
||||||
|
<channel site="ayn.om" site_id="161/قناة-عمان-مباشر" lang="ar" xmltv_id="OmanTVMubashir.om">قناة عمان مباشر</channel>
|
||||||
|
</channels>
|
||||||
104
sites/ayn.om/ayn.om.config.js
Normal file
104
sites/ayn.om/ayn.om.config.js
Normal file
@@ -0,0 +1,104 @@
|
|||||||
|
const cheerio = require('cheerio')
|
||||||
|
const dayjs = require('dayjs')
|
||||||
|
const utc = require('dayjs/plugin/utc')
|
||||||
|
const isToday = require('dayjs/plugin/isToday')
|
||||||
|
const timezone = require('dayjs/plugin/timezone')
|
||||||
|
const customParseFormat = require('dayjs/plugin/customParseFormat')
|
||||||
|
|
||||||
|
require('dayjs/locale/ar')
|
||||||
|
|
||||||
|
dayjs.extend(utc)
|
||||||
|
dayjs.extend(isToday)
|
||||||
|
dayjs.extend(timezone)
|
||||||
|
dayjs.extend(customParseFormat)
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
site: 'ayn.om',
|
||||||
|
days: 2,
|
||||||
|
url({ channel }) {
|
||||||
|
return `https://ayn.om/schedule/${channel.site_id}`
|
||||||
|
},
|
||||||
|
parser({ content, date }) {
|
||||||
|
const items = parseItems(content, date)
|
||||||
|
|
||||||
|
let programs = []
|
||||||
|
items.forEach(item => {
|
||||||
|
const prev = programs[programs.length - 1]
|
||||||
|
const $item = cheerio.load(item)
|
||||||
|
const start = parseStart($item, date)
|
||||||
|
if (prev) prev.stop = start
|
||||||
|
const stop = start.add(1, 'h')
|
||||||
|
|
||||||
|
programs.push({
|
||||||
|
title: parseTitle($item),
|
||||||
|
start,
|
||||||
|
stop
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
return programs
|
||||||
|
},
|
||||||
|
channels() {
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
lang: 'ar',
|
||||||
|
name: 'قناة عمان العامة',
|
||||||
|
site_id: '158/قناة-عمان-العامة'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
lang: 'ar',
|
||||||
|
name: 'قناة عمان الرياضية',
|
||||||
|
site_id: '159/قناة-عمان-الرياضية'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
lang: 'ar',
|
||||||
|
name: 'قناة عمان الثقافية',
|
||||||
|
site_id: '160/قناة-عمان-الثقافية'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
lang: 'ar',
|
||||||
|
name: 'قناة عمان مباشر',
|
||||||
|
site_id: '161/قناة-عمان-مباشر'
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function parseTitle($item) {
|
||||||
|
return $item('*').attr('title')
|
||||||
|
}
|
||||||
|
|
||||||
|
function parseStart($item, date) {
|
||||||
|
const time = $item('p').text().trim()
|
||||||
|
|
||||||
|
return dayjs.tz(`${date.format('YYYY-MM-DD')} ${time}`, 'YYYY-MM-DD HH:mm', 'Asia/Muscat')
|
||||||
|
}
|
||||||
|
|
||||||
|
function parseItems(content, date) {
|
||||||
|
const $ = cheerio.load(content)
|
||||||
|
|
||||||
|
let day
|
||||||
|
if (date.isToday()) {
|
||||||
|
day = 'اليوم'
|
||||||
|
} else {
|
||||||
|
day = date.locale('ar').format('dddd')
|
||||||
|
}
|
||||||
|
|
||||||
|
const $heading = $(
|
||||||
|
`#day-1 > div.epg_bottom_sec > div > div > div.epg_channel_wrap > div > div.epg_timeline_aside > div > div > div > div > h3:contains("${day}")`
|
||||||
|
)
|
||||||
|
|
||||||
|
if (!$heading.length) return []
|
||||||
|
|
||||||
|
const $wrapper = $heading.closest('.epg_channel_wrap')
|
||||||
|
|
||||||
|
if (!$wrapper.length) return []
|
||||||
|
|
||||||
|
const items = $wrapper
|
||||||
|
.find('.epg_swipe_wrapper > .epg_swipe_inner_wrap > .epg_timeline_show_row > .epg_tl_item')
|
||||||
|
.toArray()
|
||||||
|
|
||||||
|
if (!Array.isArray(items)) return []
|
||||||
|
|
||||||
|
return items
|
||||||
|
}
|
||||||
70
sites/ayn.om/ayn.om.test.js
Normal file
70
sites/ayn.om/ayn.om.test.js
Normal file
@@ -0,0 +1,70 @@
|
|||||||
|
const { parser, url } = require('./ayn.om.config.js')
|
||||||
|
const fs = require('fs')
|
||||||
|
const path = require('path')
|
||||||
|
const dayjs = require('dayjs')
|
||||||
|
const utc = require('dayjs/plugin/utc')
|
||||||
|
const customParseFormat = require('dayjs/plugin/customParseFormat')
|
||||||
|
dayjs.extend(customParseFormat)
|
||||||
|
dayjs.extend(utc)
|
||||||
|
|
||||||
|
const channel = {
|
||||||
|
site_id: '159/قناة-عمان-الرياضية'
|
||||||
|
}
|
||||||
|
|
||||||
|
it('can generate valid url', () => {
|
||||||
|
expect(url({ channel })).toBe('https://ayn.om/schedule/159/قناة-عمان-الرياضية')
|
||||||
|
})
|
||||||
|
|
||||||
|
it('can parse response for today', () => {
|
||||||
|
jest.useFakeTimers().setSystemTime(new Date('2026-04-08'))
|
||||||
|
const date = dayjs.utc('2026-04-08', 'YYYY-MM-DD').startOf('d')
|
||||||
|
const content = fs.readFileSync(path.resolve(__dirname, '__data__/content.html'))
|
||||||
|
|
||||||
|
const results = parser({ content, date }).map(p => {
|
||||||
|
p.start = p.start.toJSON()
|
||||||
|
p.stop = p.stop.toJSON()
|
||||||
|
|
||||||
|
return p
|
||||||
|
})
|
||||||
|
|
||||||
|
expect(results.length).toBe(22)
|
||||||
|
expect(results[0]).toMatchObject({
|
||||||
|
title: 'لا يوجد جدول',
|
||||||
|
start: '2026-04-07T20:00:00.000Z',
|
||||||
|
stop: '2026-04-07T21:00:00.000Z'
|
||||||
|
})
|
||||||
|
|
||||||
|
jest.useRealTimers()
|
||||||
|
})
|
||||||
|
|
||||||
|
it('can parse response for friday', () => {
|
||||||
|
const date = dayjs.utc('2026-04-10', 'YYYY-MM-DD').startOf('d')
|
||||||
|
const content = fs.readFileSync(path.resolve(__dirname, '__data__/content.html'))
|
||||||
|
|
||||||
|
const results = parser({ content, date }).map(p => {
|
||||||
|
p.start = p.start.toJSON()
|
||||||
|
p.stop = p.stop.toJSON()
|
||||||
|
|
||||||
|
return p
|
||||||
|
})
|
||||||
|
|
||||||
|
expect(results.length).toBe(24)
|
||||||
|
expect(results[0]).toMatchObject({
|
||||||
|
title: 'دوري جندال لكرة القدم 2025-2026 - الحلقة 73',
|
||||||
|
start: '2026-04-09T20:00:00.000Z',
|
||||||
|
stop: '2026-04-09T21:00:00.000Z'
|
||||||
|
})
|
||||||
|
expect(results[23]).toMatchObject({
|
||||||
|
title: 'الدكـة - S1- 2026 - الحلقة 23',
|
||||||
|
start: '2026-04-10T19:00:00.000Z',
|
||||||
|
stop: '2026-04-10T20:00:00.000Z'
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
it('can handle empty guide', () => {
|
||||||
|
const date = dayjs.utc('2026-04-10', 'YYYY-MM-DD').startOf('d')
|
||||||
|
const content = fs.readFileSync(path.resolve(__dirname, '__data__/no_content.html'))
|
||||||
|
const results = parser({ content, date })
|
||||||
|
|
||||||
|
expect(results).toMatchObject([])
|
||||||
|
})
|
||||||
21
sites/ayn.om/readme.md
Normal file
21
sites/ayn.om/readme.md
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
# ayn.om
|
||||||
|
|
||||||
|
https://ayn.om [Geo-blocked]
|
||||||
|
|
||||||
|
### Download the guide
|
||||||
|
|
||||||
|
```sh
|
||||||
|
npm run grab --- --site=ayn.om
|
||||||
|
```
|
||||||
|
|
||||||
|
### Update channel list
|
||||||
|
|
||||||
|
```sh
|
||||||
|
npm run channels:parse --- --config=./sites/ayn.om/ayn.om.config.js --output=./sites/ayn.om/ayn.om.channels.xml
|
||||||
|
```
|
||||||
|
|
||||||
|
### Test
|
||||||
|
|
||||||
|
```sh
|
||||||
|
npm test --- ayn.om
|
||||||
|
```
|
||||||
Reference in New Issue
Block a user