mirror of
https://github.com/iptv-org/epg.git
synced 2025-05-09 16:40:07 -04:00
commit
4223fa26d0
4 changed files with 0 additions and 194 deletions
|
@ -1,29 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<channels>
|
||||
<channel site="kplus.vn" lang="vi" xmltv_id="AsianFoodNetwork.sg" site_id="4529">AFC</channel>
|
||||
<channel site="kplus.vn" lang="vi" xmltv_id="AXN.vn" site_id="7036">AXN HD</channel>
|
||||
<channel site="kplus.vn" lang="vi" xmltv_id="CartoonNetwork.vn" site_id="7063">CARTOON NETWORK</channel>
|
||||
<channel site="kplus.vn" lang="vi" xmltv_id="DiscoveryChannelSoutheastAsia.sg" site_id="7057">DISCOVERY CHANNEL</channel>
|
||||
<channel site="kplus.vn" lang="vi" xmltv_id="HBOAsia.sg" site_id="7035">HBO HD</channel>
|
||||
<channel site="kplus.vn" lang="vi" xmltv_id="HTV7.vn" site_id="4550">HTV7</channel>
|
||||
<channel site="kplus.vn" lang="vi" xmltv_id="HTV9.vn" site_id="4638">HTV9</channel>
|
||||
<channel site="kplus.vn" lang="vi" xmltv_id="KBSWorld.kr" site_id="7054">KBS WORLD</channel>
|
||||
<channel site="kplus.vn" lang="vi" xmltv_id="KPlusCine.vn" site_id="7008">K+CINE HD</channel>
|
||||
<channel site="kplus.vn" lang="vi" xmltv_id="KPlusLife.vn" site_id="7010">K+LIFE HD</channel>
|
||||
<channel site="kplus.vn" lang="vi" xmltv_id="KPlusSport1.vn" site_id="7012">K+PM HD</channel>
|
||||
<channel site="kplus.vn" lang="vi" xmltv_id="KPlusSport2.vn" site_id="7014">K+PC HD</channel>
|
||||
<channel site="kplus.vn" lang="vi" xmltv_id="NHKWorldJapan.jp" site_id="7070">NHK WORLD JAPAN</channel>
|
||||
<channel site="kplus.vn" lang="vi" xmltv_id="" site_id="7034">SCTV PHIMTONGHOP</channel>
|
||||
<channel site="kplus.vn" lang="vi" xmltv_id="TodayTV.vn" site_id="7049">VTC7-TODAY TV</channel>
|
||||
<channel site="kplus.vn" lang="vi" xmltv_id="TV5MondeAsia.fr" site_id="7068">TV5 MONDE</channel>
|
||||
<channel site="kplus.vn" lang="vi" xmltv_id="VTC1.vn" site_id="7069">VTC1</channel>
|
||||
<channel site="kplus.vn" lang="vi" xmltv_id="VTV2.vn" site_id="4478">VTV2</channel>
|
||||
<channel site="kplus.vn" lang="vi" xmltv_id="VTV3.vn" site_id="7017">VTV3 HD</channel>
|
||||
<channel site="kplus.vn" lang="vi" xmltv_id="VTV4.vn" site_id="4481">VTV4</channel>
|
||||
<channel site="kplus.vn" lang="vi" xmltv_id="VTVCanTho.vn" site_id="7018">VTV6 HD</channel>
|
||||
<channel site="kplus.vn" lang="vi" xmltv_id="VTV7.vn" site_id="7030">VTV7</channel>
|
||||
<channel site="kplus.vn" lang="vi" xmltv_id="VTV8.vn" site_id="7031">VTV8</channel>
|
||||
<channel site="kplus.vn" lang="vi" xmltv_id="VTV9.vn" site_id="4486">VTV9</channel>
|
||||
<channel site="kplus.vn" lang="vi" xmltv_id="VTVCab1.vn" site_id="4508">VTVCab1-GIAITRITV</channel>
|
||||
<channel site="kplus.vn" lang="vi" xmltv_id="YouTV.vn" site_id="7079">YOU TV</channel>
|
||||
</channels>
|
|
@ -1,79 +0,0 @@
|
|||
const axios = require('axios')
|
||||
const dayjs = require('dayjs')
|
||||
const utc = require('dayjs/plugin/utc')
|
||||
const timezone = require('dayjs/plugin/timezone')
|
||||
|
||||
dayjs.extend(timezone)
|
||||
dayjs.extend(utc)
|
||||
|
||||
const API_ENDPOINT = 'https://www.kplus.vn/Schedule/getSchedule'
|
||||
|
||||
module.exports = {
|
||||
site: 'kplus.vn',
|
||||
days: 2,
|
||||
url: API_ENDPOINT,
|
||||
request: {
|
||||
headers: {
|
||||
'Content-Type': 'application/x-www-form-urlencoded'
|
||||
},
|
||||
data({ date }) {
|
||||
const params = new URLSearchParams()
|
||||
params.append('date', date.format('D-M-YYYY'))
|
||||
params.append('categories', '')
|
||||
|
||||
return params
|
||||
},
|
||||
method: 'POST'
|
||||
},
|
||||
parser: function ({ content, channel }) {
|
||||
let programs = []
|
||||
const items = parseItems(content, channel)
|
||||
items.forEach(item => {
|
||||
const prev = programs[programs.length - 1]
|
||||
const start = parseStart(item)
|
||||
const stop = start.add(1, 'h')
|
||||
if (prev) prev.stop = start
|
||||
programs.push({
|
||||
title: item.Program.Name,
|
||||
image: item.Program.Images,
|
||||
category: item.Program.Genres,
|
||||
start,
|
||||
stop
|
||||
})
|
||||
})
|
||||
|
||||
return programs
|
||||
},
|
||||
async channels() {
|
||||
const params = new URLSearchParams()
|
||||
params.append('date', dayjs().format('D-M-YYYY'))
|
||||
params.append('categories', '')
|
||||
const data = await axios
|
||||
.post(API_ENDPOINT, params, {
|
||||
headers: {
|
||||
'Content-Type': 'application/x-www-form-urlencoded'
|
||||
}
|
||||
})
|
||||
.then(r => r.data)
|
||||
.catch(console.log)
|
||||
|
||||
return data.Channels.map(item => {
|
||||
return {
|
||||
lang: 'vi',
|
||||
site_id: item.Id,
|
||||
name: item.Name
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
function parseStart(item) {
|
||||
return dayjs.tz(item.ShowingTime, 'Asia/Ho_Chi_Minh')
|
||||
}
|
||||
|
||||
function parseItems(content, channel) {
|
||||
const data = JSON.parse(content)
|
||||
if (!data || !Array.isArray(data.Schedules)) return []
|
||||
|
||||
return data.Schedules.filter(i => i.ChannelId == channel.site_id)
|
||||
}
|
|
@ -1,65 +0,0 @@
|
|||
const { parser, url, request } = require('./kplus.vn.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('2022-03-15', 'YYYY-MM-DD').startOf('d')
|
||||
const channel = {
|
||||
site_id: '7019',
|
||||
xmltv_id: 'KPlus1HD.vn'
|
||||
}
|
||||
|
||||
it('can generate valid url', () => {
|
||||
expect(url).toBe('https://www.kplus.vn/Schedule/getSchedule')
|
||||
})
|
||||
|
||||
it('can generate valid request headers', () => {
|
||||
expect(request.headers).toMatchObject({
|
||||
'Content-Type': 'application/x-www-form-urlencoded'
|
||||
})
|
||||
})
|
||||
|
||||
it('can generate valid request data', () => {
|
||||
const data = request.data({ date })
|
||||
|
||||
expect(data.get('date')).toBe('15-3-2022')
|
||||
expect(data.get('categories')).toBe('')
|
||||
})
|
||||
|
||||
it('can parse response', () => {
|
||||
const content =
|
||||
'{"SchedulesCount":1105,"ChannelsCount":28,"Schedules":[{"Id":12195,"ChannelId":7019,"ProgramId":35111026,"EpgProgramId":"1252496\\r","ShowingTime":"2022-03-15T06:15:00","EpgBroadcastId":"HD_ENT_DOC_LNO_21_2649421_2652183_4383385_OnAir","EpgId":"HD_ENT_DOC_LNO_21_2649421_2652183_4383385_OnAir","IsDeleted":false,"CreatedOn":"2022-03-15T06:22:45","UpdatedOn":"0001-01-01T00:00:00","Channel":{"Id":7019,"Name":"K+1 HD","Image":"https://kplus-website-production-cdn.azureedge.net/content/upload/7/images-mkt/logo-k-1-hd-new.png","LiveUrlSegment":"highlights/broadcast-schedule/K-1-HD","FeatureImage":"https://kplus-website-production-cdn.azureedge.net/content/upload/7/images-mkt/logo-k-1-hd-new.png","EpgId":null,"IsOTTEnabled":false,"StartOver":0,"DisplayOrder":0},"Program":{"Id":35111026,"Name":"WEEKLY FILMS AND STARS, EP740","BodyContent":"","Cast":"","Director":"","Duration":0,"EpgId":"93701","EpgProgramId":null,"Episode":0,"Genres":"Documentary","Images":"https://img.kplus.vn/images?filename=Media/HDVN/2022_02/ENT_DOC_LNO_21_2649421_2652183_2652183.jpg","IsFeatured":false,"IsOTTEnabled":true,"IsRebroadcast":false,"ShortDescription":"","SubTitle":"","Trailers":"","UrlSegment":"highlights/broadcast-schedule/93701/weekly-films-and-stars-ep740","CreatedOn":"2022-03-16T00:15:45","UpdatedOn":"2022-03-16T00:15:45","ParentalRating":null},"RelatedSchedules":null},{"Id":12196,"ChannelId":7019,"ProgramId":35111279,"EpgProgramId":"798685\\r","ShowingTime":"2022-03-15T07:00:00","EpgBroadcastId":"HD_MOV_COM__2632318_4383386_OnAir","EpgId":"HD_MOV_COM__2632318_4383386_OnAir","IsDeleted":false,"CreatedOn":"2022-03-15T07:02:46","UpdatedOn":"0001-01-01T00:00:00","Channel":{"Id":7019,"Name":"K+1 HD","Image":"https://kplus-website-production-cdn.azureedge.net/content/upload/7/images-mkt/logo-k-1-hd-new.png","LiveUrlSegment":"highlights/broadcast-schedule/K-1-HD","FeatureImage":"https://kplus-website-production-cdn.azureedge.net/content/upload/7/images-mkt/logo-k-1-hd-new.png","EpgId":null,"IsOTTEnabled":false,"StartOver":0,"DisplayOrder":0},"Program":{"Id":35111279,"Name":"ST. VINCENT","BodyContent":"","Cast":"Bill Murray, Melissa McCarthy, Naomi Watts","Director":"Theodore Melfi","Duration":0,"EpgId":"93959","EpgProgramId":null,"Episode":0,"Genres":"Comedy","Images":"https://img.kplus.vn/images?filename=Media/HDVN/2020_05/MOV_COM__2632318_2632318.jpg","IsFeatured":false,"IsOTTEnabled":true,"IsRebroadcast":false,"ShortDescription":"","SubTitle":"","Trailers":"","UrlSegment":"highlights/broadcast-schedule/93959/st-vincent","CreatedOn":"2022-03-16T00:15:45","UpdatedOn":"2022-03-16T00:15:45","ParentalRating":null},"RelatedSchedules":null}]}'
|
||||
const result = parser({ content, channel }).map(p => {
|
||||
p.start = p.start.toJSON()
|
||||
p.stop = p.stop.toJSON()
|
||||
return p
|
||||
})
|
||||
|
||||
expect(result).toMatchObject([
|
||||
{
|
||||
start: '2022-03-14T23:15:00.000Z',
|
||||
stop: '2022-03-15T00:00:00.000Z',
|
||||
title: 'WEEKLY FILMS AND STARS, EP740',
|
||||
image:
|
||||
'https://img.kplus.vn/images?filename=Media/HDVN/2022_02/ENT_DOC_LNO_21_2649421_2652183_2652183.jpg',
|
||||
category: 'Documentary'
|
||||
},
|
||||
{
|
||||
start: '2022-03-15T00:00:00.000Z',
|
||||
stop: '2022-03-15T01:00:00.000Z',
|
||||
title: 'ST. VINCENT',
|
||||
image: 'https://img.kplus.vn/images?filename=Media/HDVN/2020_05/MOV_COM__2632318_2632318.jpg',
|
||||
category: 'Comedy'
|
||||
}
|
||||
])
|
||||
})
|
||||
|
||||
it('can handle empty guide', () => {
|
||||
const result = parser({
|
||||
content: '{"SchedulesCount":0,"ChannelsCount":0,"Schedules":[],"Channels":[],"MinDuration":0}',
|
||||
channel
|
||||
})
|
||||
expect(result).toMatchObject([])
|
||||
})
|
|
@ -1,21 +0,0 @@
|
|||
# kplus.vn
|
||||
|
||||
https://www.kplus.vn/highlights/broadcast-schedule
|
||||
|
||||
### Download the guide
|
||||
|
||||
```sh
|
||||
npm run grab --- --site=kplus.vn
|
||||
```
|
||||
|
||||
### Update channel list
|
||||
|
||||
```sh
|
||||
npm run channels:parse --- --config=./sites/kplus.vn/kplus.vn.config.js --output=./sites/kplus.vn/kplus.vn.channels.xml
|
||||
```
|
||||
|
||||
### Test
|
||||
|
||||
```sh
|
||||
npm test --- kplus.vn
|
||||
```
|
Loading…
Add table
Add a link
Reference in a new issue