mirror of
https://github.com/iptv-org/epg
synced 2025-12-16 10:26:41 -05:00
Replace LF endings with CRLF
This commit is contained in:
@@ -1,73 +1,73 @@
|
||||
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)
|
||||
|
||||
const tz = 'Asia/Jakarta'
|
||||
|
||||
module.exports = {
|
||||
site: 'dens.tv',
|
||||
days: 2,
|
||||
url({ channel, date }) {
|
||||
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
|
||||
const response = JSON.parse(content)
|
||||
const programs = []
|
||||
|
||||
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,
|
||||
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)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
return programs
|
||||
},
|
||||
async channels() {
|
||||
const axios = require('axios')
|
||||
|
||||
const categories = {
|
||||
local: 1,
|
||||
premium: 2,
|
||||
international: 3
|
||||
}
|
||||
|
||||
const channels = []
|
||||
for (const id_category of Object.values(categories)) {
|
||||
const data = await axios
|
||||
.get('https://www.dens.tv/api/dens3/tv/TvChannels/listByCategory', {
|
||||
params: { id_category }
|
||||
})
|
||||
.then(r => r.data)
|
||||
.catch(console.error)
|
||||
|
||||
data.data.contents.forEach(item => {
|
||||
channels.push({
|
||||
lang: 'id',
|
||||
site_id: item.meta.id,
|
||||
name: item.meta.title
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
return channels
|
||||
}
|
||||
}
|
||||
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)
|
||||
|
||||
const tz = 'Asia/Jakarta'
|
||||
|
||||
module.exports = {
|
||||
site: 'dens.tv',
|
||||
days: 2,
|
||||
url({ channel, date }) {
|
||||
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
|
||||
const response = JSON.parse(content)
|
||||
const programs = []
|
||||
|
||||
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,
|
||||
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)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
return programs
|
||||
},
|
||||
async channels() {
|
||||
const axios = require('axios')
|
||||
|
||||
const categories = {
|
||||
local: 1,
|
||||
premium: 2,
|
||||
international: 3
|
||||
}
|
||||
|
||||
const channels = []
|
||||
for (const id_category of Object.values(categories)) {
|
||||
const data = await axios
|
||||
.get('https://www.dens.tv/api/dens3/tv/TvChannels/listByCategory', {
|
||||
params: { id_category }
|
||||
})
|
||||
.then(r => r.data)
|
||||
.catch(console.error)
|
||||
|
||||
data.data.contents.forEach(item => {
|
||||
channels.push({
|
||||
lang: 'id',
|
||||
site_id: item.meta.id,
|
||||
name: item.meta.title
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
return channels
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,50 +1,50 @@
|
||||
const { url, parser } = require('./dens.tv.config.js')
|
||||
const fs = require('fs')
|
||||
const path = require('path')
|
||||
const dayjs = require('dayjs')
|
||||
const utc = require('dayjs/plugin/utc')
|
||||
|
||||
dayjs.extend(utc)
|
||||
|
||||
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/api/dens3/tv/TvChannels/listEpgByDate?date=2024-11-24&id_channel=38&app_type=10'
|
||||
)
|
||||
})
|
||||
|
||||
it('can parse response', () => {
|
||||
const content = fs.readFileSync(path.resolve(__dirname, '__data__/content.json'))
|
||||
let results = parser({ content })
|
||||
results = results.map(p => {
|
||||
p.start = p.start.toJSON()
|
||||
p.stop = p.stop.toJSON()
|
||||
return p
|
||||
})
|
||||
|
||||
expect(results.length).toBe(2)
|
||||
|
||||
expect(results[0]).toMatchObject({
|
||||
start: '2024-11-23T17:00:00.000Z',
|
||||
stop: '2024-11-23T17:30:00.000Z',
|
||||
title: 'Migi & Dali Episode 2',
|
||||
episode: 2
|
||||
})
|
||||
|
||||
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
|
||||
})
|
||||
})
|
||||
|
||||
it('can handle empty guide', () => {
|
||||
const content = fs.readFileSync(path.resolve(__dirname, '__data__/no_content.json'))
|
||||
const results = parser({ content })
|
||||
|
||||
expect(results).toMatchObject([])
|
||||
})
|
||||
const { url, parser } = require('./dens.tv.config.js')
|
||||
const fs = require('fs')
|
||||
const path = require('path')
|
||||
const dayjs = require('dayjs')
|
||||
const utc = require('dayjs/plugin/utc')
|
||||
|
||||
dayjs.extend(utc)
|
||||
|
||||
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/api/dens3/tv/TvChannels/listEpgByDate?date=2024-11-24&id_channel=38&app_type=10'
|
||||
)
|
||||
})
|
||||
|
||||
it('can parse response', () => {
|
||||
const content = fs.readFileSync(path.resolve(__dirname, '__data__/content.json'))
|
||||
let results = parser({ content })
|
||||
results = results.map(p => {
|
||||
p.start = p.start.toJSON()
|
||||
p.stop = p.stop.toJSON()
|
||||
return p
|
||||
})
|
||||
|
||||
expect(results.length).toBe(2)
|
||||
|
||||
expect(results[0]).toMatchObject({
|
||||
start: '2024-11-23T17:00:00.000Z',
|
||||
stop: '2024-11-23T17:30:00.000Z',
|
||||
title: 'Migi & Dali Episode 2',
|
||||
episode: 2
|
||||
})
|
||||
|
||||
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
|
||||
})
|
||||
})
|
||||
|
||||
it('can handle empty guide', () => {
|
||||
const content = fs.readFileSync(path.resolve(__dirname, '__data__/no_content.json'))
|
||||
const results = parser({ content })
|
||||
|
||||
expect(results).toMatchObject([])
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user