Bump dens.tv api to dens3.

Signed-off-by: Toha <tohenk@yahoo.com>
This commit is contained in:
Toha 2024-11-24 23:12:46 +07:00
parent 8693a1b062
commit 9d6b1c3a07
No known key found for this signature in database
GPG key ID: 2D7AA6389D44DCAB
5 changed files with 30 additions and 19 deletions

File diff suppressed because one or more lines are too long

View file

@ -1 +1 @@
{"response":201,"data":[],"sum_list":1}
{"success":false,"error":{"status":"Not Found"}}

View file

@ -10,8 +10,8 @@
<channel site="dens.tv" lang="id" xmltv_id="AniplusAsia.sg" site_id="38">ANIPLUS HD</channel>
<channel site="dens.tv" lang="id" xmltv_id="ANTV.id" site_id="8">antv</channel>
<channel site="dens.tv" lang="id" xmltv_id="BTV.id" site_id="80">BTV</channel>
<channel site="dens.tv" lang="id" xmltv_id="CCM.hk" site_id="110">CCM (Celestial Classic MV)</channel>
<channel site="dens.tv" lang="id" xmltv_id="CCTV4Asia.cn" site_id="85">CCTV-4</channel>
<channel site="dens.tv" lang="id" xmltv_id="CelestialClassicMovies.id" site_id="110">CCM (Celestial Classic MV)</channel>
<channel site="dens.tv" lang="id" xmltv_id="CelestialMoviesIndonesia.id" site_id="99">Celestial Movies HD</channel>
<channel site="dens.tv" lang="id" xmltv_id="CGTN.cn" site_id="16">CGTN Documentary</channel>
<channel site="dens.tv" lang="id" xmltv_id="ChannelJowo.id" site_id="137">Channel Jowo</channel>

View file

@ -7,13 +7,15 @@ dayjs.extend(utc)
dayjs.extend(timezone)
dayjs.extend(customParseFormat)
const tz = 'Asia/Jakarta'
module.exports = {
site: 'dens.tv',
days: 2,
url({ channel, date }) {
return `https://www.dens.tv/tvpage_octo/epgchannel2/${date.format('YYYY-MM-DD')}/${
return `https://www.dens.tv/api/dens3/tv/TvChannels/listEpgByDate?date=${date.format('YYYY-MM-DD')}&id_channel=${
channel.site_id
}`
}&app_type=10`
},
parser({ content }) {
// parsing
@ -22,10 +24,16 @@ module.exports = {
if (Array.isArray(response?.data)) {
response.data.forEach(item => {
const title = item.title
const [, , , season, , , episode] = title.match(/( (Season |Season|S)(\d+))?( (Episode|Ep) (\d+))/) ||
[null, null, null, null, null, null, null]
programs.push({
title: item.title,
start: dayjs.tz(item.starttime, 'YYYY-MM-DD HH:mm:ss', 'Asia/Jakarta'),
stop: dayjs.tz(item.endtime, 'YYYY-MM-DD HH:mm:ss', 'Asia/Jakarta')
title,
description: item.description,
season: season ? parseInt(season) : season,
episode: episode ? parseInt(episode) : episode,
start: dayjs.tz(item.start_time, 'YYYY-MM-DD HH:mm:ss', tz),
stop: dayjs.tz(item.end_time, 'YYYY-MM-DD HH:mm:ss', tz)
})
})
}

View file

@ -6,11 +6,11 @@ const utc = require('dayjs/plugin/utc')
dayjs.extend(utc)
const date = dayjs.utc('2023-11-10').startOf('d')
const channel = { site_id: '6', xmltv_id: 'MetroTV.id', lang: 'id' }
const date = dayjs.utc('2024-11-24').startOf('d')
const channel = { site_id: '38', xmltv_id: 'AniplusAsia.sg', lang: 'id' }
it('can generate valid url', () => {
expect(url({ channel, date })).toBe('https://www.dens.tv/tvpage_octo/epgchannel2/2023-11-10/6')
expect(url({ channel, date })).toBe('https://www.dens.tv/api/dens3/tv/TvChannels/listEpgByDate?date=2024-11-24&id_channel=38&app_type=10')
})
it('can parse response', () => {
@ -22,18 +22,21 @@ it('can parse response', () => {
return p
})
expect(results.length).toBe(26)
expect(results.length).toBe(2)
expect(results[0]).toMatchObject({
start: '2023-11-09T17:00:00.000Z',
stop: '2023-11-09T17:05:00.000Z',
title: 'Follow Up'
start: '2024-11-23T17:00:00.000Z',
stop: '2024-11-23T17:30:00.000Z',
title: 'Migi & Dali Episode 2',
episode: 2
})
expect(results[12]).toMatchObject({
start: '2023-11-10T04:05:00.000Z',
stop: '2023-11-10T06:05:00.000Z',
title: 'Metro Siang'
expect(results[1]).toMatchObject({
start: '2024-11-23T19:30:00.000Z',
stop: '2024-11-23T20:00:00.000Z',
title: 'Attack on Titan Season 3 Episode 7',
season: 3,
episode: 7
})
})