From d77656a4bc26b957269493dfd1234246ffadd040 Mon Sep 17 00:00:00 2001 From: Hans5958 Date: Mon, 8 Aug 2022 14:13:07 +0000 Subject: [PATCH 1/6] Add UseeTV EPG --- sites/useetv.com/useetv.com.config.js | 71 +++++++++ sites/useetv.com/useetv.com.test.js | 55 +++++++ sites/useetv.com/useetv.com_id.channels.xml | 162 ++++++++++++++++++++ 3 files changed, 288 insertions(+) create mode 100644 sites/useetv.com/useetv.com.config.js create mode 100644 sites/useetv.com/useetv.com.test.js create mode 100644 sites/useetv.com/useetv.com_id.channels.xml diff --git a/sites/useetv.com/useetv.com.config.js b/sites/useetv.com/useetv.com.config.js new file mode 100644 index 00000000..57d58237 --- /dev/null +++ b/sites/useetv.com/useetv.com.config.js @@ -0,0 +1,71 @@ +const cheerio = require('cheerio') +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: 'vidio.com', + url({ channel }) { + return `https://www.useetv.com/tvod/${channel.site_id}` + }, + parser({ content, date }) { + const programs = [] + const items = parseItems(content, date) + items.forEach(item => { + const prev = programs[programs.length - 1] + const $item = cheerio.load(item) + let start = parseStart($item, date) + if (prev && start.isBefore(prev.start)) { + start = start.add(1, 'd') + date = date.add(1, 'd') + } + let stop = parseStop($item, date) + if (stop.isBefore(start)) { + stop = stop.add(1, 'd') + date = date.add(1, 'd') + } + programs.push({ + title: parseTitle($item), + start, + stop + }) + }) + + return programs + } +} + +function parseStart($item, date) { + const timeString = $item('p').text() + const [_, start] = timeString.match(/(\d{2}:\d{2}) -/) || [null, null] + const dateString = `${date.format('YYYY-MM-DD')} ${start}` + + return dayjs.tz(dateString, 'YYYY-MM-DD HH:mm', 'Asia/Jakarta') +} + +function parseStop($item, date) { + const timeString = $item('p').text() + const [_, stop] = timeString.match(/- (\d{2}:\d{2})/) || [null, null] + const dateString = `${date.format('YYYY-MM-DD')} ${stop}` + + return dayjs.tz(dateString, 'YYYY-MM-DD HH:mm', 'Asia/Jakarta') +} + +function parseTitle($item) { + return $item('b').text() +} + +function parseItems(content, date) { + const $ = cheerio.load(content) + + return $( + `#pills-${date.format( + 'YYYY-MM-DD' + )} .schedule-item` + ).toArray() +} diff --git a/sites/useetv.com/useetv.com.test.js b/sites/useetv.com/useetv.com.test.js new file mode 100644 index 00000000..20bdab95 --- /dev/null +++ b/sites/useetv.com/useetv.com.test.js @@ -0,0 +1,55 @@ +const { parser, url, request } = require('./useetv.com.config.js') +const dayjs = require('dayjs') +const utc = require('dayjs/plugin/utc') +dayjs.extend(utc) + +const date = dayjs.utc('2022-08-08', 'YYYY-MM-DD').startOf('d') +const channel = { + site_id: 'metrotv', + xmltv_id: 'MetroTV.id' +} +const content = `
` + +it('can generate valid url', () => { + expect(url({ channel })).toBe('https://www.useetv.com/tvod/metrotv') +}) + +it('can parse response', () => { + const result = parser({ content, channel, date }).map(p => { + p.start = p.start.toJSON() + p.stop = p.stop.toJSON() + return p + }) + + expect(result).toMatchObject([ + { + title: 'Headline News', + start: '2022-08-08T00:00:00.000Z', + stop: '2022-08-08T00:05:00.000Z' + }, + { + title: 'Editorial Media Indonesia', + start: '2022-08-08T00:05:00.000Z', + stop: '2022-08-08T00:30:00.000Z' + }, + { + title: 'Editorial Media Indonesia', + start: '2022-08-08T00:30:00.000Z', + stop: '2022-08-08T00:45:00.000Z' + }, + { + title: 'Editorial Media Indonesia', + start: '2022-08-08T00:45:00.000Z', + stop: '2022-08-08T01:00:00.000Z' + } + ]) +}) + +it('can handle empty guide', () => { + const result = parser({ + date, + channel, + content: `` + }) + expect(result).toMatchObject([]) +}) diff --git a/sites/useetv.com/useetv.com_id.channels.xml b/sites/useetv.com/useetv.com_id.channels.xml new file mode 100644 index 00000000..92882aa7 --- /dev/null +++ b/sites/useetv.com/useetv.com_id.channels.xml @@ -0,0 +1,162 @@ + + + + UseePrime + Usee Photo + + Ruang Trampil + SEA Today + Trans7 + TransTV + ANTV + TV One + Metro TV + Kompas TV + iNews + TVRI + Rajawali TV + Rodja TV + JTV + MNC News + Berita Satu + RRI NET + Bali TV + MQTV + MTATV + + JakTV + Nusantara TV + + + + TV Edukasi + Arirang + MUI TV + Tawaf TV + TV9 NU + + + CCTV4 + DW (English) + ABC Australia + + Euronews + TRT World + France 24 + CGTN Documentary + SCTV + Indosiar + + + beIN Sports 1 + beIN Sports 3 + SPOTV + SPOTV2 + NBA + NBA + egg network + Fight Sport + TVN Movies + IMC + Galaxy Premium + Galaxy + + + Bioskop Indonesia + Celestial Movie + ZBioskop + Paramount + Thrill + My Cinema Asia + My Family + My Cinema + Cinema World + CNN Indonesia + CNBC Indonesia + Bloomberg + News Asia + CNN International + Aljazeera + CNBC Asia + TVBS News + TVN + AXN + AXN + Kplus + KBS World + Citra Drama + Warner + Rock Extreme + TLC + History + Dunia Lain + Rock Entertainment + ANIPlus + Animax + SONE + Kix + Lifetime + TV5Monde + NHK World Premium + + + Zhejiang + Shenzen + + CTI Asia + Cartoon Network + Horee + Nick Junior + Nickelodeon + Dunia anak + Boomerang + MyKidz + Mentari TV + + Nat Geo + Nat Geo + Discovery Channel + Discovery Channel + Nat Geo Wild + Nat Geo Wild + Tech Storm + Crime Investigation + Lingua + + Asian Food Network + HGTV + Eat N Go + FashionTV + MTV Live + Citra Dangdut + + O Channel + Insert + + + Net. + Daai TV + IDX + + + M Shop + Seru! + UChannel + + NHK World Japan + ATV + Outdoor Channel + Horizon Sports + + Star Chinese Movies + Star Chinese Channel + + Baby First + Dreamworks + + + + \ No newline at end of file From 6dcb31c11803f862971fbb3bf686ec6ec8688e6c Mon Sep 17 00:00:00 2001 From: Aleksandr Statciuk Date: Mon, 8 Aug 2022 19:53:34 +0300 Subject: [PATCH 2/6] Update useetv.com.config.js --- sites/useetv.com/useetv.com.config.js | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/sites/useetv.com/useetv.com.config.js b/sites/useetv.com/useetv.com.config.js index 57d58237..26ab90b1 100644 --- a/sites/useetv.com/useetv.com.config.js +++ b/sites/useetv.com/useetv.com.config.js @@ -9,7 +9,7 @@ dayjs.extend(timezone) dayjs.extend(customParseFormat) module.exports = { - site: 'vidio.com', + site: 'useetv.com', url({ channel }) { return `https://www.useetv.com/tvod/${channel.site_id}` }, @@ -63,9 +63,5 @@ function parseTitle($item) { function parseItems(content, date) { const $ = cheerio.load(content) - return $( - `#pills-${date.format( - 'YYYY-MM-DD' - )} .schedule-item` - ).toArray() + return $(`#pills-${date.format('YYYY-MM-DD')} .schedule-item`).toArray() } From 2cace3714705a2ac031344e144b0c932edacd8ed Mon Sep 17 00:00:00 2001 From: Aleksandr Statciuk Date: Mon, 8 Aug 2022 19:54:11 +0300 Subject: [PATCH 3/6] Update useetv.com.test.js --- sites/useetv.com/useetv.com.test.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sites/useetv.com/useetv.com.test.js b/sites/useetv.com/useetv.com.test.js index 20bdab95..3033ebf9 100644 --- a/sites/useetv.com/useetv.com.test.js +++ b/sites/useetv.com/useetv.com.test.js @@ -1,3 +1,5 @@ +// npx epg-grabber --config=sites/useetv.com/useetv.com.config.js --channels=sites/useetv.com/useetv.com_id.channels.xml --output=guide.xml --timeout=30000 --days=2 + const { parser, url, request } = require('./useetv.com.config.js') const dayjs = require('dayjs') const utc = require('dayjs/plugin/utc') From 7fd51ce880e2d99eaabcaa5808e19bc40a72e06e Mon Sep 17 00:00:00 2001 From: Aleksandr Statciuk Date: Mon, 8 Aug 2022 19:55:29 +0300 Subject: [PATCH 4/6] Create useetv.com.yml --- .github/workflows/useetv.com.yml | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 .github/workflows/useetv.com.yml diff --git a/.github/workflows/useetv.com.yml b/.github/workflows/useetv.com.yml new file mode 100644 index 00000000..e448ba37 --- /dev/null +++ b/.github/workflows/useetv.com.yml @@ -0,0 +1,17 @@ +name: useetv.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 747a30bcc5929d24cc269c996af76197936decd5 Mon Sep 17 00:00:00 2001 From: Aleksandr Statciuk Date: Tue, 9 Aug 2022 17:07:52 +0300 Subject: [PATCH 5/6] Update useetv.com.yml --- .github/workflows/useetv.com.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/useetv.com.yml b/.github/workflows/useetv.com.yml index e448ba37..68aa420c 100644 --- a/.github/workflows/useetv.com.yml +++ b/.github/workflows/useetv.com.yml @@ -1,7 +1,7 @@ name: useetv.com on: schedule: - - cron: '0 0 * * *' + - cron: '0 7 * * *' workflow_dispatch: workflow_run: workflows: [_trigger] From d6f4f0f886f7078664b11c86f6a5e66acb462299 Mon Sep 17 00:00:00 2001 From: Aleksandr Statciuk Date: Tue, 23 Aug 2022 02:46:35 +0300 Subject: [PATCH 6/6] Update useetv.com_id.channels.xml --- sites/useetv.com/useetv.com_id.channels.xml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/sites/useetv.com/useetv.com_id.channels.xml b/sites/useetv.com/useetv.com_id.channels.xml index 92882aa7..62a63c49 100644 --- a/sites/useetv.com/useetv.com_id.channels.xml +++ b/sites/useetv.com/useetv.com_id.channels.xml @@ -9,17 +9,17 @@ Trans7 TransTV ANTV - TV One + TV One Metro TV Kompas TV - iNews + iNews TVRI Rajawali TV Rodja TV JTV MNC News Berita Satu - RRI NET + RRI NET Bali TV MQTV MTATV @@ -101,7 +101,7 @@ Zhejiang - Shenzen + CTI Asia Cartoon Network