diff --git a/sites/kplus.vn/kplus.vn.channels.xml b/sites/kplus.vn/kplus.vn.channels.xml deleted file mode 100644 index d5f91a94..00000000 --- a/sites/kplus.vn/kplus.vn.channels.xml +++ /dev/null @@ -1,29 +0,0 @@ - - - AFC - AXN HD - CARTOON NETWORK - DISCOVERY CHANNEL - HBO HD - HTV7 - HTV9 - KBS WORLD - K+CINE HD - K+LIFE HD - K+PM HD - K+PC HD - NHK WORLD JAPAN - SCTV PHIMTONGHOP - VTC7-TODAY TV - TV5 MONDE - VTC1 - VTV2 - VTV3 HD - VTV4 - VTV6 HD - VTV7 - VTV8 - VTV9 - VTVCab1-GIAITRITV - YOU TV - diff --git a/sites/kplus.vn/kplus.vn.config.js b/sites/kplus.vn/kplus.vn.config.js deleted file mode 100644 index 7fef7448..00000000 --- a/sites/kplus.vn/kplus.vn.config.js +++ /dev/null @@ -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) -} diff --git a/sites/kplus.vn/kplus.vn.test.js b/sites/kplus.vn/kplus.vn.test.js deleted file mode 100644 index 4eebea9d..00000000 --- a/sites/kplus.vn/kplus.vn.test.js +++ /dev/null @@ -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([]) -}) diff --git a/sites/kplus.vn/readme.md b/sites/kplus.vn/readme.md deleted file mode 100644 index 1ac0bb5e..00000000 --- a/sites/kplus.vn/readme.md +++ /dev/null @@ -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 -```