mirror of
https://github.com/iptv-org/epg.git
synced 2025-05-10 17:10:07 -04:00
Merge pull request #294 from iptv-org/update-turksatkablo-com-tr
Update turksatkablo.com.tr
This commit is contained in:
commit
f10f72e72a
2 changed files with 52 additions and 28 deletions
|
@ -9,26 +9,28 @@ dayjs.extend(customParseFormat)
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
site: 'turksatkablo.com.tr',
|
site: 'turksatkablo.com.tr',
|
||||||
ignore: true, // NOTE: server is not stable
|
|
||||||
url: function ({ date }) {
|
url: function ({ date }) {
|
||||||
return `https://www.turksatkablo.com.tr/userUpload/EPG/y.json?_=${date.valueOf()}`
|
return `https://www.turksatkablo.com.tr/userUpload/EPG/y.json?_=${date.valueOf()}`
|
||||||
},
|
},
|
||||||
parser: function ({ content, channel, date }) {
|
parser: function ({ content, channel, date }) {
|
||||||
let PM = false
|
|
||||||
let programs = []
|
let programs = []
|
||||||
const items = parseItems(content, channel)
|
const items = parseItems(content, channel)
|
||||||
items.forEach(item => {
|
items.forEach(item => {
|
||||||
|
const prev = programs[programs.length - 1]
|
||||||
let start = parseStart(item, date)
|
let start = parseStart(item, date)
|
||||||
if (start.hour() > 11) PM = true
|
if (prev && start.isBefore(prev.start)) {
|
||||||
if (start.hour() < 12 && PM) start = start.add(1, 'd')
|
start = start.add(1, 'd')
|
||||||
|
date = date.add(1, 'd')
|
||||||
|
}
|
||||||
let stop = parseStop(item, date)
|
let stop = parseStop(item, date)
|
||||||
if (stop.hour() > 11) PM = true
|
if (prev && stop.isBefore(start)) {
|
||||||
if (stop.hour() < 12 && PM) stop = stop.add(1, 'd')
|
stop = stop.add(1, 'd')
|
||||||
|
date = date.add(1, 'd')
|
||||||
|
}
|
||||||
programs.push({
|
programs.push({
|
||||||
title: item.b,
|
title: item.b,
|
||||||
start: start.toString(),
|
start,
|
||||||
stop: stop.toString()
|
stop
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -37,22 +39,24 @@ module.exports = {
|
||||||
}
|
}
|
||||||
|
|
||||||
function parseStart(item, date) {
|
function parseStart(item, date) {
|
||||||
const time = `${date.format('MM/DD/YYYY')} ${item.c}`
|
const time = `${date.format('YYYY-MM-DD')} ${item.c}`
|
||||||
|
|
||||||
return dayjs.tz(time, 'MM/DD/YYYY HH:mm', 'Europe/Istanbul')
|
return dayjs.tz(time, 'YYYY-MM-DD HH:mm', 'Europe/Istanbul')
|
||||||
}
|
}
|
||||||
|
|
||||||
function parseStop(item, date) {
|
function parseStop(item, date) {
|
||||||
const time = `${date.format('MM/DD/YYYY')} ${item.d}`
|
const time = `${date.format('YYYY-MM-DD')} ${item.d}`
|
||||||
|
|
||||||
return dayjs.tz(time, 'MM/DD/YYYY HH:mm', 'Europe/Istanbul')
|
return dayjs.tz(time, 'YYYY-MM-DD HH:mm', 'Europe/Istanbul')
|
||||||
}
|
}
|
||||||
|
|
||||||
function parseItems(content, channel) {
|
function parseItems(content, channel) {
|
||||||
const parsed = JSON.parse(content)
|
let parsed
|
||||||
const channels = parsed.k
|
try {
|
||||||
if (!channels) return []
|
parsed = JSON.parse(content)
|
||||||
const data = channels.find(c => c.x == channel.site_id)
|
} catch (e) {}
|
||||||
|
if (!parsed || !parsed.k) return []
|
||||||
|
const data = parsed.k.find(c => c.x == channel.site_id)
|
||||||
|
|
||||||
return data ? data.p : []
|
return data ? data.p : []
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
// npx epg-grabber --config=sites/turksatkablo.com.tr/turksatkablo.com.tr.config.js --channels=sites/turksatkablo.com.tr/turksatkablo.com.tr_tr.channels.xml --days=2 --output=.gh-pages/guides/tr/turksatkablo.com.tr.epg.xml
|
// npx epg-grabber --config=sites/turksatkablo.com.tr/turksatkablo.com.tr.config.js --channels=sites/turksatkablo.com.tr/turksatkablo.com.tr_tr.channels.xml --output=.gh-pages/guides/tr/turksatkablo.com.tr.epg.xml --days=2
|
||||||
|
|
||||||
const { parser, url } = require('./turksatkablo.com.tr.config.js')
|
const { parser, url } = require('./turksatkablo.com.tr.config.js')
|
||||||
const dayjs = require('dayjs')
|
const dayjs = require('dayjs')
|
||||||
|
@ -17,15 +17,35 @@ it('can generate valid url', () => {
|
||||||
})
|
})
|
||||||
|
|
||||||
it('can parse response', () => {
|
it('can parse response', () => {
|
||||||
const result = parser({ date, channel, content })
|
const result = parser({ date, channel, content }).map(p => {
|
||||||
expect(result[0]).toMatchObject({
|
p.start = p.start.toJSON()
|
||||||
start: 'Sun, 24 Oct 2021 22:15:00 GMT',
|
p.stop = p.stop.toJSON()
|
||||||
stop: 'Mon, 25 Oct 2021 00:00:00 GMT',
|
return p
|
||||||
title: 'Ölüm Ormanı'
|
|
||||||
})
|
|
||||||
expect(result[2]).toMatchObject({
|
|
||||||
start: 'Mon, 25 Oct 2021 20:45:00 GMT',
|
|
||||||
stop: 'Tue, 26 Oct 2021 00:45:00 GMT',
|
|
||||||
title: 'Kaçakçı'
|
|
||||||
})
|
})
|
||||||
|
expect(result).toMatchObject([
|
||||||
|
{
|
||||||
|
start: '2021-10-24T22:15:00.000Z',
|
||||||
|
stop: '2021-10-25T00:00:00.000Z',
|
||||||
|
title: 'Ölüm Ormanı'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
start: '2021-10-25T12:00:00.000Z',
|
||||||
|
stop: '2021-10-25T14:00:00.000Z',
|
||||||
|
title: 'Kızım'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
start: '2021-10-25T20:45:00.000Z',
|
||||||
|
stop: '2021-10-26T00:45:00.000Z',
|
||||||
|
title: 'Kaçakçı'
|
||||||
|
}
|
||||||
|
])
|
||||||
|
})
|
||||||
|
|
||||||
|
it('can handle empty guide', () => {
|
||||||
|
const result = parser({
|
||||||
|
date,
|
||||||
|
channel,
|
||||||
|
content: `<!DOCTYPE html><html><head></head><body></body></html>`
|
||||||
|
})
|
||||||
|
expect(result).toMatchObject([])
|
||||||
})
|
})
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue