mirror of
https://github.com/iptv-org/epg.git
synced 2025-05-10 17:10:07 -04:00
Update dsmart.com.tr.config.js
This commit is contained in:
parent
2318291727
commit
52094dae00
1 changed files with 20 additions and 13 deletions
|
@ -9,21 +9,21 @@ module.exports = {
|
||||||
},
|
},
|
||||||
site: 'dsmart.com.tr',
|
site: 'dsmart.com.tr',
|
||||||
url({ date, channel }) {
|
url({ date, channel }) {
|
||||||
return `https://www.dsmart.com.tr/api/v1/public/epg/schedules?page=${
|
const [page] = channel.site_id.split('#')
|
||||||
channel.site_id
|
|
||||||
}&limit=1&day=${date.format('YYYY-MM-DD')}`
|
|
||||||
},
|
|
||||||
logo({ content }) {
|
|
||||||
const data = JSON.parse(content)
|
|
||||||
if (!data || !data.data.channels.length) return null
|
|
||||||
const logoId = data.data.channels[0].logo
|
|
||||||
|
|
||||||
return logoId ? `https://www.dsmart.com.tr/epg/images/0x50/${logoId}` : null
|
return `https://www.dsmart.com.tr/api/v1/public/epg/schedules?page=${page}&limit=1&day=${date.format(
|
||||||
|
'YYYY-MM-DD'
|
||||||
|
)}`
|
||||||
|
},
|
||||||
|
logo({ content, channel }) {
|
||||||
|
const data = parseContent(content, channel)
|
||||||
|
|
||||||
|
return data && data.logo ? `https://www.dsmart.com.tr/epg/images/0x50/${data.logo}` : null
|
||||||
},
|
},
|
||||||
parser: function ({ content, channel, date }) {
|
parser: function ({ content, channel, date }) {
|
||||||
let offset = -1
|
let offset = -1
|
||||||
let programs = []
|
let programs = []
|
||||||
const items = parseItems(content)
|
const items = parseItems(content, channel)
|
||||||
items.forEach(item => {
|
items.forEach(item => {
|
||||||
let start = parseStart(item, date)
|
let start = parseStart(item, date)
|
||||||
if (offset === -1 && start.hour() > 18) start = start.subtract(1, 'd')
|
if (offset === -1 && start.hour() > 18) start = start.subtract(1, 'd')
|
||||||
|
@ -52,9 +52,16 @@ function parseStop(item, date) {
|
||||||
return dayjs.utc(item.end_date).set('date', date.get('date'))
|
return dayjs.utc(item.end_date).set('date', date.get('date'))
|
||||||
}
|
}
|
||||||
|
|
||||||
function parseItems(content) {
|
function parseContent(content, channel) {
|
||||||
const data = JSON.parse(content)
|
const data = JSON.parse(content)
|
||||||
if (!data || !data.data.channels.length) return []
|
if (!data || !data.data || !Array.isArray(data.data.channels)) return null
|
||||||
|
const [_, channelId] = channel.site_id.split('#')
|
||||||
|
|
||||||
return data.data.channels[0].schedule
|
return data.data.channels.find(i => i.ch_no == channelId)
|
||||||
|
}
|
||||||
|
|
||||||
|
function parseItems(content, channel) {
|
||||||
|
const data = parseContent(content, channel)
|
||||||
|
|
||||||
|
return data ? data.schedule : []
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue