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