mirror of
https://github.com/iptv-org/epg.git
synced 2025-05-09 16:40:07 -04:00
Fix linter issues in sites/
This commit is contained in:
parent
d6d20b6413
commit
5df982bb7c
129 changed files with 3316 additions and 3226 deletions
|
@ -1,102 +1,114 @@
|
|||
const dayjs = require('dayjs')
|
||||
const timezone = require('dayjs/plugin/timezone')
|
||||
const utc = require('dayjs/plugin/utc')
|
||||
|
||||
dayjs.extend(timezone)
|
||||
dayjs.extend(utc)
|
||||
|
||||
module.exports = {
|
||||
site: 'cubmu.com',
|
||||
days: 2,
|
||||
url({ channel, date }) {
|
||||
return `https://servicebuss.transvision.co.id/v2/cms/getEPGData?app_id=cubmu&tvs_platform_id=standalone&schedule_date=${date.format('YYYY-MM-DD')}&channel_id=${channel.site_id}`
|
||||
},
|
||||
parser({ content, channel }) {
|
||||
const programs = []
|
||||
const items = parseItems(content)
|
||||
items.forEach(item => {
|
||||
programs.push({
|
||||
title: parseTitle(item),
|
||||
description: parseDescription(item, channel.lang),
|
||||
episode: parseEpisode(item),
|
||||
start: parseStart(item).toISOString(),
|
||||
stop: parseStop(item).toISOString()
|
||||
})
|
||||
})
|
||||
|
||||
return programs
|
||||
},
|
||||
async channels({ lang = 'id' }) {
|
||||
const axios = require('axios')
|
||||
const cheerio = require('cheerio')
|
||||
const result = await axios
|
||||
.get('https://cubmu.com/live-tv')
|
||||
.then(response => response.data)
|
||||
.catch(console.error)
|
||||
|
||||
const $ = cheerio.load(result)
|
||||
|
||||
// retrieve service api data
|
||||
const config = JSON.parse($('#__NEXT_DATA__').text()).runtimeConfig || {}
|
||||
|
||||
const options = {
|
||||
headers: {
|
||||
Origin: 'https://cubmu.com',
|
||||
Referer: 'https://cubmu.com/live-tv'
|
||||
}
|
||||
}
|
||||
// login to service bus
|
||||
const token = await axios
|
||||
.post(`https://servicebuss.transvision.co.id/tvs/login/external?email=${config.email}&password=${config.password}&deviceId=${config.deviceId}&deviceType=${config.deviceType}&deviceModel=${config.deviceModel}&deviceToken=&serial=&platformId=${config.platformId}`, options)
|
||||
.then(response => response.data)
|
||||
.catch(console.error)
|
||||
// list channels
|
||||
const subscribedChannels = await axios
|
||||
.post(`https://servicebuss.transvision.co.id/tvs/subscribe_product/list?platformId=${config.platformId}`, options)
|
||||
.then(response => response.data)
|
||||
.catch(console.error)
|
||||
|
||||
const channels = []
|
||||
const included = []
|
||||
if (Array.isArray(subscribedChannels.channelPackageList)) {
|
||||
subscribedChannels.channelPackageList.forEach(pkg => {
|
||||
pkg.channelList.forEach(channel => {
|
||||
if (included.indexOf(channel.id) < 0) {
|
||||
included.push(channel.id)
|
||||
channels.push({
|
||||
lang,
|
||||
site_id: channel.id,
|
||||
name: channel.name
|
||||
})
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
return channels
|
||||
}
|
||||
}
|
||||
|
||||
function parseItems(content) {
|
||||
return content ? JSON.parse(content.trim()).result || [] : []
|
||||
}
|
||||
|
||||
function parseTitle(item) {
|
||||
return item.scehedule_title
|
||||
}
|
||||
|
||||
function parseDescription(item, lang = 'id') {
|
||||
return lang === 'id' ? item.schedule_json.primarySynopsis : item.schedule_json.secondarySynopsis
|
||||
}
|
||||
|
||||
function parseEpisode(item) {
|
||||
return item.schedule_json.episodeName
|
||||
}
|
||||
|
||||
function parseStart(item) {
|
||||
return dayjs.tz(item.schedule_date, 'YYYY-MM-DD HH:mm:ss', 'Asia/Jakarta')
|
||||
}
|
||||
|
||||
function parseStop(item) {
|
||||
return dayjs.tz([item.schedule_date.split(' ')[0], item.schedule_end_time].join(' '), 'YYYY-MM-DD HH:mm:ss', 'Asia/Jakarta')
|
||||
}
|
||||
const dayjs = require('dayjs')
|
||||
const timezone = require('dayjs/plugin/timezone')
|
||||
const utc = require('dayjs/plugin/utc')
|
||||
|
||||
dayjs.extend(timezone)
|
||||
dayjs.extend(utc)
|
||||
|
||||
module.exports = {
|
||||
site: 'cubmu.com',
|
||||
days: 2,
|
||||
url({ channel, date }) {
|
||||
return `https://servicebuss.transvision.co.id/v2/cms/getEPGData?app_id=cubmu&tvs_platform_id=standalone&schedule_date=${date.format(
|
||||
'YYYY-MM-DD'
|
||||
)}&channel_id=${channel.site_id}`
|
||||
},
|
||||
parser({ content, channel }) {
|
||||
const programs = []
|
||||
const items = parseItems(content)
|
||||
items.forEach(item => {
|
||||
programs.push({
|
||||
title: parseTitle(item),
|
||||
description: parseDescription(item, channel.lang),
|
||||
episode: parseEpisode(item),
|
||||
start: parseStart(item).toISOString(),
|
||||
stop: parseStop(item).toISOString()
|
||||
})
|
||||
})
|
||||
|
||||
return programs
|
||||
},
|
||||
async channels({ lang = 'id' }) {
|
||||
const axios = require('axios')
|
||||
const cheerio = require('cheerio')
|
||||
const result = await axios
|
||||
.get('https://cubmu.com/live-tv')
|
||||
.then(response => response.data)
|
||||
.catch(console.error)
|
||||
|
||||
const $ = cheerio.load(result)
|
||||
|
||||
// retrieve service api data
|
||||
const config = JSON.parse($('#__NEXT_DATA__').text()).runtimeConfig || {}
|
||||
|
||||
const options = {
|
||||
headers: {
|
||||
Origin: 'https://cubmu.com',
|
||||
Referer: 'https://cubmu.com/live-tv'
|
||||
}
|
||||
}
|
||||
// login to service bus
|
||||
await axios
|
||||
.post(
|
||||
`https://servicebuss.transvision.co.id/tvs/login/external?email=${config.email}&password=${config.password}&deviceId=${config.deviceId}&deviceType=${config.deviceType}&deviceModel=${config.deviceModel}&deviceToken=&serial=&platformId=${config.platformId}`,
|
||||
options
|
||||
)
|
||||
.then(response => response.data)
|
||||
.catch(console.error)
|
||||
// list channels
|
||||
const subscribedChannels = await axios
|
||||
.post(
|
||||
`https://servicebuss.transvision.co.id/tvs/subscribe_product/list?platformId=${config.platformId}`,
|
||||
options
|
||||
)
|
||||
.then(response => response.data)
|
||||
.catch(console.error)
|
||||
|
||||
const channels = []
|
||||
const included = []
|
||||
if (Array.isArray(subscribedChannels.channelPackageList)) {
|
||||
subscribedChannels.channelPackageList.forEach(pkg => {
|
||||
pkg.channelList.forEach(channel => {
|
||||
if (included.indexOf(channel.id) < 0) {
|
||||
included.push(channel.id)
|
||||
channels.push({
|
||||
lang,
|
||||
site_id: channel.id,
|
||||
name: channel.name
|
||||
})
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
return channels
|
||||
}
|
||||
}
|
||||
|
||||
function parseItems(content) {
|
||||
return content ? JSON.parse(content.trim()).result || [] : []
|
||||
}
|
||||
|
||||
function parseTitle(item) {
|
||||
return item.scehedule_title
|
||||
}
|
||||
|
||||
function parseDescription(item, lang = 'id') {
|
||||
return lang === 'id' ? item.schedule_json.primarySynopsis : item.schedule_json.secondarySynopsis
|
||||
}
|
||||
|
||||
function parseEpisode(item) {
|
||||
return item.schedule_json.episodeName
|
||||
}
|
||||
|
||||
function parseStart(item) {
|
||||
return dayjs.tz(item.schedule_date, 'YYYY-MM-DD HH:mm:ss', 'Asia/Jakarta')
|
||||
}
|
||||
|
||||
function parseStop(item) {
|
||||
return dayjs.tz(
|
||||
[item.schedule_date.split(' ')[0], item.schedule_end_time].join(' '),
|
||||
'YYYY-MM-DD HH:mm:ss',
|
||||
'Asia/Jakarta'
|
||||
)
|
||||
}
|
||||
|
|
|
@ -1,47 +1,47 @@
|
|||
const { url, parser } = require('./cubmu.com.config.js')
|
||||
const dayjs = require('dayjs')
|
||||
const utc = require('dayjs/plugin/utc')
|
||||
dayjs.extend(utc)
|
||||
|
||||
const date = dayjs.utc('2023-11-05', 'DD/MM/YYYY').startOf('d')
|
||||
const channel = { site_id: '4028c68574537fcd0174be43042758d8', xmltv_id: 'TransTV.id', lang: 'id' }
|
||||
const channelEn = Object.assign({}, channel, { lang: 'en' })
|
||||
|
||||
it('can generate valid url', () => {
|
||||
expect(url({ channel, date })).toBe(
|
||||
'https://servicebuss.transvision.co.id/v2/cms/getEPGData?app_id=cubmu&tvs_platform_id=standalone&schedule_date=2023-11-05&channel_id=4028c68574537fcd0174be43042758d8'
|
||||
)
|
||||
})
|
||||
|
||||
it('can parse response', () => {
|
||||
const content =
|
||||
'{"result":[{"channel_id":"4028c68574537fcd0174be43042758d8","channel_name":"Trans TV","scehedule_title":"CNN Tech News","schedule_date":"2023-11-05 01:30:00","schedule_end_time":"02:00:00","schedule_json":{"availability":0,"channelId":"4028c68574537fcd0174be43042758d8","channelName":"Trans TV","duration":1800,"editable":true,"episodeName":"","imageUrl":"https://cdnjkt2.transvision.co.id:1001/catchup/schedule/thumbnail/4028c68574537fcd0174be43042758d8/4028c6858b8b3621018b9330e3701a7e/458x640","imageUrlWide":"https://cdnjkt2.transvision.co.id:1001/catchup/schedule/thumbnail/4028c68574537fcd0174be43042758d8/4028c6858b8b3621018b9330e3701a7e/320x180","name":"CNN Tech News","ottImageUrl":"","primarySynopsis":"CNN Indonesia Tech News adalah berita teknologi yang membawa pemirsa ke dunia teknologi yang penuh dengan informasi, pendidikan, hiburan sampai informasi kesehatan terkini.","scheduleId":"4028c6858b8b3621018b9330e3701a7e","scheduleTime":"18:30:00","secondarySynopsis":"CNN Indonesia Tech News is tech news brings viewers into the world of technology that provides information, education, entertainment to the latest health information.","startDt":"20231104183000","url":""},"schedule_start_time":"01:30:00"}]}'
|
||||
|
||||
const idResults = parser({ content, channel })
|
||||
expect(idResults).toMatchObject([
|
||||
{
|
||||
start: '2023-11-04T18:30:00.000Z',
|
||||
stop: '2023-11-04T19:00:00.000Z',
|
||||
title: 'CNN Tech News',
|
||||
description:
|
||||
'CNN Indonesia Tech News adalah berita teknologi yang membawa pemirsa ke dunia teknologi yang penuh dengan informasi, pendidikan, hiburan sampai informasi kesehatan terkini.'
|
||||
}
|
||||
])
|
||||
|
||||
const enResults = parser({ content, channel: channelEn })
|
||||
expect(enResults).toMatchObject([
|
||||
{
|
||||
start: '2023-11-04T18:30:00.000Z',
|
||||
stop: '2023-11-04T19:00:00.000Z',
|
||||
title: 'CNN Tech News',
|
||||
description:
|
||||
'CNN Indonesia Tech News is tech news brings viewers into the world of technology that provides information, education, entertainment to the latest health information.'
|
||||
}
|
||||
])
|
||||
})
|
||||
|
||||
it('can handle empty guide', () => {
|
||||
const results = parser({ content: '' })
|
||||
|
||||
expect(results).toMatchObject([])
|
||||
})
|
||||
const { url, parser } = require('./cubmu.com.config.js')
|
||||
const dayjs = require('dayjs')
|
||||
const utc = require('dayjs/plugin/utc')
|
||||
dayjs.extend(utc)
|
||||
|
||||
const date = dayjs.utc('2023-11-05', 'DD/MM/YYYY').startOf('d')
|
||||
const channel = { site_id: '4028c68574537fcd0174be43042758d8', xmltv_id: 'TransTV.id', lang: 'id' }
|
||||
const channelEn = Object.assign({}, channel, { lang: 'en' })
|
||||
|
||||
it('can generate valid url', () => {
|
||||
expect(url({ channel, date })).toBe(
|
||||
'https://servicebuss.transvision.co.id/v2/cms/getEPGData?app_id=cubmu&tvs_platform_id=standalone&schedule_date=2023-11-05&channel_id=4028c68574537fcd0174be43042758d8'
|
||||
)
|
||||
})
|
||||
|
||||
it('can parse response', () => {
|
||||
const content =
|
||||
'{"result":[{"channel_id":"4028c68574537fcd0174be43042758d8","channel_name":"Trans TV","scehedule_title":"CNN Tech News","schedule_date":"2023-11-05 01:30:00","schedule_end_time":"02:00:00","schedule_json":{"availability":0,"channelId":"4028c68574537fcd0174be43042758d8","channelName":"Trans TV","duration":1800,"editable":true,"episodeName":"","imageUrl":"https://cdnjkt2.transvision.co.id:1001/catchup/schedule/thumbnail/4028c68574537fcd0174be43042758d8/4028c6858b8b3621018b9330e3701a7e/458x640","imageUrlWide":"https://cdnjkt2.transvision.co.id:1001/catchup/schedule/thumbnail/4028c68574537fcd0174be43042758d8/4028c6858b8b3621018b9330e3701a7e/320x180","name":"CNN Tech News","ottImageUrl":"","primarySynopsis":"CNN Indonesia Tech News adalah berita teknologi yang membawa pemirsa ke dunia teknologi yang penuh dengan informasi, pendidikan, hiburan sampai informasi kesehatan terkini.","scheduleId":"4028c6858b8b3621018b9330e3701a7e","scheduleTime":"18:30:00","secondarySynopsis":"CNN Indonesia Tech News is tech news brings viewers into the world of technology that provides information, education, entertainment to the latest health information.","startDt":"20231104183000","url":""},"schedule_start_time":"01:30:00"}]}'
|
||||
|
||||
const idResults = parser({ content, channel })
|
||||
expect(idResults).toMatchObject([
|
||||
{
|
||||
start: '2023-11-04T18:30:00.000Z',
|
||||
stop: '2023-11-04T19:00:00.000Z',
|
||||
title: 'CNN Tech News',
|
||||
description:
|
||||
'CNN Indonesia Tech News adalah berita teknologi yang membawa pemirsa ke dunia teknologi yang penuh dengan informasi, pendidikan, hiburan sampai informasi kesehatan terkini.'
|
||||
}
|
||||
])
|
||||
|
||||
const enResults = parser({ content, channel: channelEn })
|
||||
expect(enResults).toMatchObject([
|
||||
{
|
||||
start: '2023-11-04T18:30:00.000Z',
|
||||
stop: '2023-11-04T19:00:00.000Z',
|
||||
title: 'CNN Tech News',
|
||||
description:
|
||||
'CNN Indonesia Tech News is tech news brings viewers into the world of technology that provides information, education, entertainment to the latest health information.'
|
||||
}
|
||||
])
|
||||
})
|
||||
|
||||
it('can handle empty guide', () => {
|
||||
const results = parser({ content: '' })
|
||||
|
||||
expect(results).toMatchObject([])
|
||||
})
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue