mirror of
https://github.com/iptv-org/epg.git
synced 2025-05-10 00:50:09 -04:00
Add guide for unifi.com.my
This commit is contained in:
parent
a0c1b7db91
commit
407dfa8003
3 changed files with 185 additions and 0 deletions
72
sites/unifi.com.my/unifi.com.my.channels.xml
Normal file
72
sites/unifi.com.my/unifi.com.my.channels.xml
Normal file
|
@ -0,0 +1,72 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<site site="unifi.com.my">
|
||||
<channels>
|
||||
<channel lang="en" xmltv_id="8TV.my" site_id="20000017">8TV</channel>
|
||||
<channel lang="en" xmltv_id="AlJazeeraEnglish.qa" site_id="20000067">Al Jazeera</channel>
|
||||
<channel lang="en" xmltv_id="AnimaxAsia.sg" site_id="57622558">Animax</channel>
|
||||
<channel lang="en" xmltv_id="ArirangTV.kr" site_id="51783925">arirang TV</channel>
|
||||
<channel lang="en" xmltv_id="AXNMalaysia.my" site_id="51882833">AXN</channel>
|
||||
<channel lang="en" xmltv_id="BBCEarthAsia.uk" site_id="20000092">BBC Earth HD</channel>
|
||||
<channel lang="en" xmltv_id="BBCLifestyleAsia.uk" site_id="20000040">BBC Lifestyle HD</channel>
|
||||
<channel lang="en" xmltv_id="BBCWorldNewsAsiaPacific.uk" site_id="20000074">BBC World News HD</channel>
|
||||
<channel lang="en" xmltv_id="beINSports.qa" site_id="55456338">beIN SPORTS</channel>
|
||||
<channel lang="en" xmltv_id="beINSports3.qa" site_id="55456355">beIN SPORTS 3</channel>
|
||||
<channel lang="en" xmltv_id="beINSports4.qa" site_id="57682031">beIN SPORTS 4</channel>
|
||||
<channel lang="ia" xmltv_id="BernamaTV.my" site_id="20000091">Bernama TV</channel>
|
||||
<channel lang="en" xmltv_id="BoomerangAsia.sg" site_id="20000030">Boomerang HD</channel>
|
||||
<channel lang="en" xmltv_id="CBeebiesAsia.uk" site_id="20000006">CBeebies HD</channel>
|
||||
<channel lang="en" xmltv_id="CCMMalaysia.my" site_id="52014451">CCM</channel>
|
||||
<channel lang="en" xmltv_id="CCTV4Asia.cn" site_id="55697154">CCTV-4 HD</channel>
|
||||
<channel lang="en" xmltv_id="CelestialMoviesMalaysia.my" site_id="51882317">Celestial Movies</channel>
|
||||
<channel lang="en" xmltv_id="CGTN.cn" site_id="55697173">CGTN HD</channel>
|
||||
<channel lang="en" xmltv_id="CinemaWorld.my" site_id="20000080">CinemaWorld HD</channel>
|
||||
<channel lang="en" xmltv_id="CNA.sg" site_id="20000016">CNA</channel>
|
||||
<channel lang="hi" xmltv_id="ColorsCineplex.in" site_id="20000038">Colors Cineplex</channel>
|
||||
<channel lang="hi" xmltv_id="ColorsTamil.in" site_id="20000113">Colors Tamil HD</channel>
|
||||
<channel lang="my" xmltv_id="NTV7.my" site_id="20000031">DidikTV KPM </channel>
|
||||
<channel lang="en" xmltv_id="DreamWorksChannelAsia.us" site_id="20000103">Dreamworks HD</channel>
|
||||
<channel lang="my" xmltv_id="DuniaSinema.my" site_id="20000046">Dunia Sinema HD</channel>
|
||||
<channel lang="en" xmltv_id="DWEnglish.de" site_id="20000087">DW</channel>
|
||||
<channel lang="en" xmltv_id="EuronewsEnglish.fr" site_id="20000083">Euronews</channel>
|
||||
<channel lang="en" xmltv_id="France24English.fr" site_id="57622577">France 24</channel>
|
||||
<channel lang="en" xmltv_id="GEM.sg" site_id="51882374">GEM</channel>
|
||||
<channel lang="en" xmltv_id="HITS.sg" site_id="51872269">HITS</channel>
|
||||
<channel lang="en" xmltv_id="HITSMovies.sg" site_id="52014611">HITS Movies</channel>
|
||||
<channel lang="my" xmltv_id="Inspirasi.my" site_id="20000003">Inspirasi</channel>
|
||||
<channel lang="en" xmltv_id="KPlus.sg" site_id="51880949">K-Plus</channel>
|
||||
<channel lang="my" xmltv_id="LakuMall.my" site_id="20000105">LAKU mall </channel>
|
||||
<channel lang="en" xmltv_id="LoveNature.ca" site_id="40413728">Love Nature HD</channel>
|
||||
<channel lang="en" xmltv_id="LuxeTV.lu" site_id="20000086">Luxe.TV HD</channel>
|
||||
<channel lang="en" xmltv_id="MTVLive.uk" site_id="20000061">MTV Live</channel>
|
||||
<channel lang="en" xmltv_id="NHKWorldJapan.jp" site_id="20000066">NHK WORLD-JAPAN</channel>
|
||||
<channel lang="en" xmltv_id="NickJrAsia.sg" site_id="20000004">Nick Jr.</channel>
|
||||
<channel lang="en" xmltv_id="nowJelli.hk" site_id="20000055">Now Jelli HD</channel>
|
||||
<channel lang="en" xmltv_id="ParamountNetworkMalaysia.my" site_id="20000019">Paramount Network</channel>
|
||||
<channel lang="my" xmltv_id="ParlimenMalaysia.my" site_id="57623657">Parlimen Malaysia</channel>
|
||||
<channel lang="my" xmltv_id="Pesona.my" site_id="20000063">Pesona HD</channel>
|
||||
<channel lang="en" xmltv_id="ROCKAction.sg" site_id="20000081">ROCK Action</channel>
|
||||
<channel lang="en" xmltv_id="ROCKEntertainment.sg" site_id="20000029">ROCK Entertainment</channel>
|
||||
<channel lang="my" xmltv_id="SalamTV.id" site_id="20000070">Salam HD</channel>
|
||||
<channel lang="my" xmltv_id="Sensasi.my" site_id="20000089">Sensasi</channel>
|
||||
<channel lang="en" xmltv_id="SETInternational.tw" site_id="20000082">SETI</channel>
|
||||
<channel lang="my" xmltv_id="SIAR.my" site_id="56919296">SIAR</channel>
|
||||
<channel lang="hi" xmltv_id="SonyYay.in" site_id="56657229">Sony YAY!</channel>
|
||||
<channel lang="en" xmltv_id="SPOTV.kr" site_id="20000076">SPOTV</channel>
|
||||
<channel lang="en" xmltv_id="SPOTV2.kr" site_id="20000109">SPOTV2</channel>
|
||||
<channel lang="en" xmltv_id="TechStorm.sg" site_id="52014533">TechStorm</channel>
|
||||
<channel lang="en" xmltv_id="TravelChannelSoutheastAsia.sg" site_id="20000088">Travel Channel HD</channel>
|
||||
<channel lang="my" xmltv_id="TVAlhijrah.my" site_id="20000014">TV AlHijrah HD</channel>
|
||||
<channel lang="my" xmltv_id="TV1.my" site_id="20000009">TV1</channel>
|
||||
<channel lang="my" xmltv_id="TV2.my" site_id="20000036">TV2</channel>
|
||||
<channel lang="my" xmltv_id="TV3.my" site_id="20000011">TV3</channel>
|
||||
<channel lang="my" xmltv_id="TV9.my" site_id="20000020">TV9</channel>
|
||||
<channel lang="en" xmltv_id="tvNAsia.hk" site_id="20000062">tvN HD</channel>
|
||||
<channel lang="en" xmltv_id="tvNMoviesAsia.hk" site_id="20000021">tvN Movies HD</channel>
|
||||
<channel lang="my" xmltv_id="UnifiSports1.my" site_id="54185493">unifi Sports 1</channel>
|
||||
<channel lang="my" xmltv_id="UnifiSports2.my" site_id="41210859">unifi Sports 2</channel>
|
||||
<channel lang="my" xmltv_id="UnifiSports3.my" site_id="52026408">unifi Sports 3</channel>
|
||||
<channel lang="my" xmltv_id="UnifiSports14.my" site_id="57623639">unifi Sports 4</channel>
|
||||
<channel lang="en" xmltv_id="WarnerTVPhilippines.ph" site_id="20000012">Warner TV HD</channel>
|
||||
<channel lang="en" xmltv_id="WION.in" site_id="56750195">Wion</channel>
|
||||
</channels>
|
||||
</site>
|
61
sites/unifi.com.my/unifi.com.my.config.js
Normal file
61
sites/unifi.com.my/unifi.com.my.config.js
Normal file
|
@ -0,0 +1,61 @@
|
|||
const dayjs = require('dayjs')
|
||||
const utc = require('dayjs/plugin/utc')
|
||||
const timezone = require('dayjs/plugin/timezone')
|
||||
const customParseFormat = require('dayjs/plugin/customParseFormat')
|
||||
|
||||
dayjs.extend(utc)
|
||||
dayjs.extend(timezone)
|
||||
dayjs.extend(customParseFormat)
|
||||
|
||||
module.exports = {
|
||||
site: 'unifi.com.my',
|
||||
days: 2,
|
||||
url: `https://unifi.com.my/tv/api/tv`,
|
||||
request: {
|
||||
cache: {
|
||||
ttl: 60 * 60 * 1000 // 1 hour
|
||||
},
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
|
||||
},
|
||||
data({ date }) {
|
||||
const params = new URLSearchParams()
|
||||
params.append('date', date.format('YYYY-MM-DD'))
|
||||
return params
|
||||
}
|
||||
},
|
||||
parser({ content, channel, date }) {
|
||||
let programs = []
|
||||
const items = parseItems(content, channel)
|
||||
items.forEach(item => {
|
||||
const start = parseStart(item, date)
|
||||
const stop = start.add(item.minute, 'minute')
|
||||
programs.push({
|
||||
title: item.name,
|
||||
start,
|
||||
stop
|
||||
})
|
||||
})
|
||||
return programs
|
||||
}
|
||||
}
|
||||
|
||||
function parseItems(content, channel) {
|
||||
try {
|
||||
const data = JSON.parse(content)
|
||||
if (!data) return []
|
||||
if (!Array.isArray(data)) return []
|
||||
|
||||
const channelData = data.find(i => i.id == channel.site_id)
|
||||
return channelData.items && Array.isArray(channelData.items) ? channelData.items : []
|
||||
} catch (err) {
|
||||
return []
|
||||
}
|
||||
}
|
||||
|
||||
function parseStart(item, date) {
|
||||
const time = `${date.format('YYYY-MM-DD')} ${item.start_time}`
|
||||
return dayjs.tz(time, 'YYYY-MM-DD H:mma', 'Asia/Kuala_Lumpur')
|
||||
}
|
||||
|
52
sites/unifi.com.my/unifi.com.my.test.js
Normal file
52
sites/unifi.com.my/unifi.com.my.test.js
Normal file
|
@ -0,0 +1,52 @@
|
|||
// npx epg-grabber --config=sites/unifi.com.my/unifi.com.my.config.js --channels=sites/unifi.com.my/unifi.com.my.channels.xml --output=guide.xml --days=2
|
||||
|
||||
const { parser, url, request } = require('./unifi.com.my.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('2023-01-09', 'YYYY-MM-DD').startOf('d')
|
||||
const channel = {
|
||||
site_id: '51882833',
|
||||
xmltv_id: 'AXNMalaysia.my'
|
||||
}
|
||||
|
||||
it('can generate valid url', () => {
|
||||
expect(url).toBe(`https://unifi.com.my/tv/api/tv`)
|
||||
})
|
||||
|
||||
it('can generate valid request method', () => {
|
||||
expect(request.method).toBe('POST')
|
||||
})
|
||||
|
||||
it('can generate valid request headers', () => {
|
||||
expect(request.headers).toMatchObject({
|
||||
'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
|
||||
})
|
||||
})
|
||||
|
||||
it('can parse response', () => {
|
||||
const content = `[{"id":"51882833","name":"AXN","logo":"https://playtv.unifi.com.my:7047/CPS/images/universal/film/logo/202109/20210927/2021092701574706798y.png","items":[{"name":"Blue Bloods (Season 11)","interval":"one","minute":55,"start_time":"4:20am","end_time":"5:15am"}]}]`
|
||||
|
||||
const result = parser({ content, channel, date }).map(p => {
|
||||
p.start = p.start.toJSON()
|
||||
p.stop = p.stop.toJSON()
|
||||
return p
|
||||
})
|
||||
|
||||
expect(result).toMatchObject([
|
||||
{
|
||||
title: 'Blue Bloods (Season 11)',
|
||||
start: '2023-01-08T20:20:00.000Z',
|
||||
stop: '2023-01-08T21:15:00.000Z'
|
||||
}
|
||||
])
|
||||
})
|
||||
|
||||
it('can handle empty guide', () => {
|
||||
const content = `[{"id":"51882833","name":"AXN","logo":"https://playtv.unifi.com.my:7047/CPS/images/universal/film/logo/202109/20210927/2021092701574706798y.png","items":[]}]`
|
||||
const result = parser({ content, channel })
|
||||
expect(result).toMatchObject([])
|
||||
})
|
Loading…
Add table
Add a link
Reference in a new issue