From 248051998a84ba6d00e23f7c7140aa4c51b951fb Mon Sep 17 00:00:00 2001 From: Aleksandr Statciuk Date: Tue, 19 Apr 2022 18:34:22 +0300 Subject: [PATCH 1/5] Create seezntv.com.test.js --- sites/seezntv.com/seezntv.com.test.js | 53 +++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 sites/seezntv.com/seezntv.com.test.js diff --git a/sites/seezntv.com/seezntv.com.test.js b/sites/seezntv.com/seezntv.com.test.js new file mode 100644 index 00000000..aba41f2c --- /dev/null +++ b/sites/seezntv.com/seezntv.com.test.js @@ -0,0 +1,53 @@ +// npm run channels:parse -- --config=sites/seezntv.com/seezntv.com.config.js --output=sites/seezntv.com/seezntv.com_kr.channels.xml +// npx epg-grabber --config=sites/seezntv.com/seezntv.com.config.js --channels=sites/seezntv.com/seezntv.com_kr.channels.xml --output=guide.xml --days=2 + +const { parser, url, request } = require('./seezntv.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('2022-04-18', 'YYYY-MM-DD').startOf('d') +const channel = { + site_id: '285', + xmltv_id: 'MNet.kr' +} + +it('can generate valid url', () => { + expect(url({ channel })).toBe( + 'https://api.seezntv.com/svc/menu/app6/api/epg_proglist?ch_no=285&search_day=1' + ) +}) + +it('can generate valid request headers', () => { + expect(request.headers).toMatchObject({ + 'X-DEVICE-TYPE': 'PCWEB', + transactionId: '0' + }) +}) + +it('can parse response', () => { + const content = `{"data":{"list":[{"rebroad":"Y","onair_yn":"N","program_subname":"","program_name":"%ED%80%B8%EB%8D%A4+2","block_yn":"N","ch_image_list":"http://img.megatvdnp.co.kr/uploads/images/channel_image/imgurl/20150910/OMSMNG_20150910145634780.png","hd":"Y","frequency":"3","ch_image_detail":"http://img.megatvdnp.co.kr/uploads/images/channel_image/imgurl/20150910/OMSMNG_20150910145634780.png","director":"","live_url":"http://menu.megatvdnp.co.kr:38086/app6/api/epg_play?ch_no=27","start_ymd":"20220418","free_yn":"N","service_ch_name":"Mnet","cast":"태연,이용진","ch_image_onair":"http://img.megatvdnp.co.kr/uploads/images/channel_image/imgurl/20150910/OMSMNG_20150910145634780.png","end_time":"00:00","start_time":"21:50","pack_group_id":"MTVBA","rating":"15","program_id":"C315691275285","live":"N"},{"rebroad":"Y","onair_yn":"N","program_subname":"","program_name":"My+Boyfriend+is+Better","block_yn":"N","ch_image_list":"http://img.megatvdnp.co.kr/uploads/images/channel_image/imgurl/20150910/OMSMNG_20150910145634780.png","hd":"Y","frequency":"4","ch_image_detail":"http://img.megatvdnp.co.kr/uploads/images/channel_image/imgurl/20150910/OMSMNG_20150910145634780.png","director":"","live_url":"http://menu.megatvdnp.co.kr:38086/app6/api/epg_play?ch_no=27","start_ymd":"20220419","free_yn":"N","service_ch_name":"Mnet","cast":"","ch_image_onair":"http://img.megatvdnp.co.kr/uploads/images/channel_image/imgurl/20150910/OMSMNG_20150910145634780.png","end_time":"01:50","start_time":"00:00","pack_group_id":"MTVBA","rating":"15","program_id":"C315691277285","live":"N"}]},"meta":{"code":"200"}}` + const result = parser({ content, date }).map(p => { + p.start = p.start.toJSON() + p.stop = p.stop.toJSON() + return p + }) + + expect(result).toMatchObject([ + { + start: '2022-04-18T12:50:00.000Z', + stop: '2022-04-18T15:00:00.000Z', + title: '퀸덤 2' + } + ]) +}) + +it('can handle empty guide', () => { + const result = parser({ + content: `{"meta":{"error_type":"Non Content","error_message":"클라이언트의 요구를 처리했으나 전송할 데이터가 없음","code":"204"}}`, + date + }) + expect(result).toMatchObject([]) +}) From f45b017710c4cf25dda98edb67f2aa37d1ba2961 Mon Sep 17 00:00:00 2001 From: Aleksandr Statciuk Date: Tue, 19 Apr 2022 18:34:25 +0300 Subject: [PATCH 2/5] Create seezntv.com.config.js --- sites/seezntv.com/seezntv.com.config.js | 86 +++++++++++++++++++++++++ 1 file changed, 86 insertions(+) create mode 100644 sites/seezntv.com/seezntv.com.config.js diff --git a/sites/seezntv.com/seezntv.com.config.js b/sites/seezntv.com/seezntv.com.config.js new file mode 100644 index 00000000..ba93138d --- /dev/null +++ b/sites/seezntv.com/seezntv.com.config.js @@ -0,0 +1,86 @@ +const axios = require('axios') +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: 'seezntv.com', + url: function ({ channel }) { + return `https://api.seezntv.com/svc/menu/app6/api/epg_proglist?ch_no=${channel.site_id}&search_day=1` + }, + request: { + headers: { + 'X-DEVICE-TYPE': 'PCWEB', + transactionId: '0' + } + }, + parser: function ({ content, date }) { + let programs = [] + const items = parseItems(content, date) + items.forEach(item => { + const start = parseStart(item) + let stop = parseStop(item) + if (stop.isBefore(start)) { + stop = stop.add(1, 'd') + } + + programs.push({ + title: parseTitle(item), + start, + stop + }) + }) + + return programs + }, + async channels({ country }) { + const channels = [] + + const data = await axios + .get(`https://api.seezntv.com/svc/menu/app6/api/epg_chlist?category_id=1`, { + headers: { + 'X-DEVICE-TYPE': 'PCWEB', + transactionId: '0' + } + }) + .then(r => r.data.data.list[0]) + .catch(console.log) + + data.list_channel.forEach(i => { + channels.push({ + name: i.service_ch_name, + site_id: i.ch_no, + lang: 'ko' + }) + }) + + return channels + } +} + +function parseTitle(item) { + const name = item.program_name.replace(/\+/g, ' ') + + return decodeURIComponent(name) +} + +function parseStart(item) { + return dayjs.tz(`${item.start_ymd} ${item.start_time}`, 'YYYYMMDD HH:mm', 'Asia/Seoul') +} + +function parseStop(item) { + return dayjs.tz(`${item.start_ymd} ${item.end_time}`, 'YYYYMMDD HH:mm', 'Asia/Seoul') +} + +function parseItems(content, date) { + const data = JSON.parse(content) + if (!data || !data.data || !Array.isArray(data.data.list)) return [] + const d = date.format('YYYYMMDD') + + return data.data.list.filter(i => i.start_ymd === d) +} From 85d60b229c9c058a9a9dbe23232fe8554d9eef74 Mon Sep 17 00:00:00 2001 From: Aleksandr Statciuk Date: Tue, 19 Apr 2022 18:34:32 +0300 Subject: [PATCH 3/5] Create seezntv.com_kr.channels.xml --- sites/seezntv.com/seezntv.com_kr.channels.xml | 102 ++++++++++++++++++ 1 file changed, 102 insertions(+) create mode 100644 sites/seezntv.com/seezntv.com_kr.channels.xml diff --git a/sites/seezntv.com/seezntv.com_kr.channels.xml b/sites/seezntv.com/seezntv.com_kr.channels.xml new file mode 100644 index 00000000..b3f43ae4 --- /dev/null +++ b/sites/seezntv.com/seezntv.com_kr.channels.xml @@ -0,0 +1,102 @@ + + + + All the K-POP + 애니박스 + 애니맥스 + 애니원티비 + 애니플러스 + Asia N + 바둑TV + BBC WN + billiards tv + 캐리TV + 채널A + 채널차이나 + 채널 olleh tv + 채널 seezn + 중화TV + 시네마천국 + CJ ONSTYLE + CJ ONSTYLE+ + CNN Int'l + 스페인 국왕컵 축구 + 어린이TV + 디스커버리채널 + 드림웍스 채널 + EBS English(중학3) + EBS kids + EBS플러스1(고등) + EBS플러스2(초등1,2) + FTV + GOLF&PBA + GS MY SHOP + GS SHOP + 홈&쇼핑 + 허니TV + 현대홈쇼핑 + 현대홈쇼핑+샵 + IB SPORTS + iHQ drama + 인디필름 + JTBC + JTBC2 + JTBC4 + JTBC Golf + JTBC GOLF&SPORTS + K바둑 + 한국경제TV + 프로축구 1 + 프로축구 2 + K쇼핑 + 롯데홈쇼핑 + 롯데OneTV + MBN + Miao Mi + 미드나잇 채널 + Mnet + NAT GEO WILD + NS홈쇼핑 + NS SHOP+ + OBS + OCN + OGN + OLIFE + Olive + 핑크퐁 + 플레이보이 TV + PLAYY 액션 영화 + PLAYY 힐링 영화 + PLAYY 프리미엄 + PLAYY 웰메이드 + 뽀요TV + 프로야구 1 + 프로야구 2 + 프로야구 3 + 프로야구 4 + 프로야구 5 + 공영쇼핑 + SBS F!L + SBS 골프 + 스크린골프존 + 신세계쇼핑 + 쇼핑엔티 + SK스토아 + skySports + 텔레노벨라 + THE MOVIE + 토마토증권통 + Tooniverse + TV CHOSUN + tvN + tvN DRAMA + tvN SHOW + tvN STORY + VIKI + W쇼핑 + 연합뉴스TV + YTN + YTN2 + 사이언스TV + + From 93f2f9a15f43a0a9f2faaa8bf0a78b12bddc82cb Mon Sep 17 00:00:00 2001 From: Aleksandr Statciuk Date: Tue, 19 Apr 2022 18:34:57 +0300 Subject: [PATCH 4/5] Create seezntv.com.yml --- .github/workflows/seezntv.com.yml | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 .github/workflows/seezntv.com.yml diff --git a/.github/workflows/seezntv.com.yml b/.github/workflows/seezntv.com.yml new file mode 100644 index 00000000..4e1e4eed --- /dev/null +++ b/.github/workflows/seezntv.com.yml @@ -0,0 +1,17 @@ +name: seezntv.com +on: + schedule: + - cron: '0 0 * * *' + workflow_dispatch: + workflow_run: + workflows: [_trigger] + types: + - completed +jobs: + load: + uses: ./.github/workflows/_load.yml + with: + site: ${{github.workflow}} + secrets: + APP_ID: ${{ secrets.APP_ID }} + APP_PRIVATE_KEY: ${{ secrets.APP_PRIVATE_KEY }} From 89a994eef562b29e1e485a968bbbe21c5de55697 Mon Sep 17 00:00:00 2001 From: Aleksandr Statciuk Date: Tue, 19 Apr 2022 18:36:24 +0300 Subject: [PATCH 5/5] Update seezntv.com_kr.channels.xml --- sites/seezntv.com/seezntv.com_kr.channels.xml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/sites/seezntv.com/seezntv.com_kr.channels.xml b/sites/seezntv.com/seezntv.com_kr.channels.xml index b3f43ae4..6e2b33b8 100644 --- a/sites/seezntv.com/seezntv.com_kr.channels.xml +++ b/sites/seezntv.com/seezntv.com_kr.channels.xml @@ -15,7 +15,7 @@ 채널차이나 채널 olleh tv 채널 seezn - 중화TV + 중화TV 시네마천국 CJ ONSTYLE CJ ONSTYLE+ @@ -88,10 +88,10 @@ 토마토증권통 Tooniverse TV CHOSUN - tvN - tvN DRAMA - tvN SHOW - tvN STORY + tvN + tvN DRAMA + tvN SHOW + tvN STORY VIKI W쇼핑 연합뉴스TV