mirror of
https://github.com/iptv-org/epg
synced 2026-05-02 15:36:59 -04:00
Replace LF endings with CRLF
This commit is contained in:
@@ -1,88 +1,88 @@
|
||||
const { DateTime } = require('luxon')
|
||||
|
||||
module.exports = {
|
||||
site: 'turksatkablo.com.tr',
|
||||
days: 2,
|
||||
url({ date }) {
|
||||
const dayOfMonth = date.format('DD') // Get the current day of the month (01-31)
|
||||
|
||||
return `https://www.turksatkablo.com.tr/userUpload/EPG/${dayOfMonth}.json?_=${date.valueOf()}`
|
||||
},
|
||||
request: {
|
||||
timeout: 60000,
|
||||
cache: {
|
||||
ttl: 60 * 60 * 1000 // 1 hour
|
||||
}
|
||||
},
|
||||
parser: function ({ content, channel, date }) {
|
||||
let programs = []
|
||||
const items = parseItems(content, channel)
|
||||
items.forEach(item => {
|
||||
const prev = programs[programs.length - 1]
|
||||
let start = parseStart(item, date)
|
||||
if (prev && start < prev.start) {
|
||||
start = start.plus({ days: 1 })
|
||||
date = date.add(1, 'd')
|
||||
}
|
||||
let stop = parseStop(item, date)
|
||||
if (prev && stop < start) {
|
||||
stop = stop.plus({ days: 1 })
|
||||
date = date.add(1, 'd')
|
||||
}
|
||||
programs.push({
|
||||
title: item.b,
|
||||
start,
|
||||
stop
|
||||
})
|
||||
})
|
||||
|
||||
return programs
|
||||
},
|
||||
async channels() {
|
||||
const axios = require('axios')
|
||||
const dayjs = require('dayjs')
|
||||
const dayOfMonth = dayjs().format('DD')
|
||||
|
||||
const data = await axios
|
||||
.get(`https://www.turksatkablo.com.tr/userUpload/EPG/${dayOfMonth}.json`)
|
||||
.then(r => r.data)
|
||||
.catch(console.log)
|
||||
|
||||
let channels = []
|
||||
|
||||
data.k.forEach(item => {
|
||||
channels.push({
|
||||
lang: 'tr',
|
||||
site_id: item.x,
|
||||
name: item.n
|
||||
})
|
||||
})
|
||||
|
||||
return channels
|
||||
}
|
||||
}
|
||||
|
||||
function parseStart(item, date) {
|
||||
const time = `${date.format('YYYY-MM-DD')} ${item.c}`
|
||||
|
||||
return DateTime.fromFormat(time, 'yyyy-MM-dd HH:mm', { zone: 'Europe/Istanbul' }).toUTC()
|
||||
}
|
||||
|
||||
function parseStop(item, date) {
|
||||
const time = `${date.format('YYYY-MM-DD')} ${item.d}`
|
||||
|
||||
return DateTime.fromFormat(time, 'yyyy-MM-dd HH:mm', { zone: 'Europe/Istanbul' }).toUTC()
|
||||
}
|
||||
|
||||
function parseItems(content, channel) {
|
||||
let parsed
|
||||
try {
|
||||
parsed = JSON.parse(content)
|
||||
} catch {
|
||||
return []
|
||||
}
|
||||
if (!parsed || !parsed.k) return []
|
||||
const data = parsed.k.find(c => c.x == channel.site_id)
|
||||
|
||||
return data ? data.p : []
|
||||
}
|
||||
const { DateTime } = require('luxon')
|
||||
|
||||
module.exports = {
|
||||
site: 'turksatkablo.com.tr',
|
||||
days: 2,
|
||||
url({ date }) {
|
||||
const dayOfMonth = date.format('DD') // Get the current day of the month (01-31)
|
||||
|
||||
return `https://www.turksatkablo.com.tr/userUpload/EPG/${dayOfMonth}.json?_=${date.valueOf()}`
|
||||
},
|
||||
request: {
|
||||
timeout: 60000,
|
||||
cache: {
|
||||
ttl: 60 * 60 * 1000 // 1 hour
|
||||
}
|
||||
},
|
||||
parser: function ({ content, channel, date }) {
|
||||
let programs = []
|
||||
const items = parseItems(content, channel)
|
||||
items.forEach(item => {
|
||||
const prev = programs[programs.length - 1]
|
||||
let start = parseStart(item, date)
|
||||
if (prev && start < prev.start) {
|
||||
start = start.plus({ days: 1 })
|
||||
date = date.add(1, 'd')
|
||||
}
|
||||
let stop = parseStop(item, date)
|
||||
if (prev && stop < start) {
|
||||
stop = stop.plus({ days: 1 })
|
||||
date = date.add(1, 'd')
|
||||
}
|
||||
programs.push({
|
||||
title: item.b,
|
||||
start,
|
||||
stop
|
||||
})
|
||||
})
|
||||
|
||||
return programs
|
||||
},
|
||||
async channels() {
|
||||
const axios = require('axios')
|
||||
const dayjs = require('dayjs')
|
||||
const dayOfMonth = dayjs().format('DD')
|
||||
|
||||
const data = await axios
|
||||
.get(`https://www.turksatkablo.com.tr/userUpload/EPG/${dayOfMonth}.json`)
|
||||
.then(r => r.data)
|
||||
.catch(console.log)
|
||||
|
||||
let channels = []
|
||||
|
||||
data.k.forEach(item => {
|
||||
channels.push({
|
||||
lang: 'tr',
|
||||
site_id: item.x,
|
||||
name: item.n
|
||||
})
|
||||
})
|
||||
|
||||
return channels
|
||||
}
|
||||
}
|
||||
|
||||
function parseStart(item, date) {
|
||||
const time = `${date.format('YYYY-MM-DD')} ${item.c}`
|
||||
|
||||
return DateTime.fromFormat(time, 'yyyy-MM-dd HH:mm', { zone: 'Europe/Istanbul' }).toUTC()
|
||||
}
|
||||
|
||||
function parseStop(item, date) {
|
||||
const time = `${date.format('YYYY-MM-DD')} ${item.d}`
|
||||
|
||||
return DateTime.fromFormat(time, 'yyyy-MM-dd HH:mm', { zone: 'Europe/Istanbul' }).toUTC()
|
||||
}
|
||||
|
||||
function parseItems(content, channel) {
|
||||
let parsed
|
||||
try {
|
||||
parsed = JSON.parse(content)
|
||||
} catch {
|
||||
return []
|
||||
}
|
||||
if (!parsed || !parsed.k) return []
|
||||
const data = parsed.k.find(c => c.x == channel.site_id)
|
||||
|
||||
return data ? data.p : []
|
||||
}
|
||||
|
||||
@@ -1,48 +1,48 @@
|
||||
const { parser, url } = require('./turksatkablo.com.tr.config.js')
|
||||
const fs = require('fs')
|
||||
const path = require('path')
|
||||
const dayjs = require('dayjs')
|
||||
const utc = require('dayjs/plugin/utc')
|
||||
const customParseFormat = require('dayjs/plugin/customParseFormat')
|
||||
dayjs.extend(customParseFormat)
|
||||
dayjs.extend(utc)
|
||||
|
||||
const date = dayjs.utc('2025-05-30', 'YYYY-MM-DD').startOf('d')
|
||||
const channel = { site_id: '1908' }
|
||||
|
||||
it('can generate valid url', () => {
|
||||
const result = url({ date })
|
||||
|
||||
expect(result).toBe('https://www.turksatkablo.com.tr/userUpload/EPG/30.json?_=1748563200000')
|
||||
})
|
||||
|
||||
it('can parse response', () => {
|
||||
const content = fs.readFileSync(path.resolve(__dirname, '__data__/content.json'))
|
||||
const results = parser({ date, channel, content }).map(p => {
|
||||
p.start = p.start.toJSON()
|
||||
p.stop = p.stop.toJSON()
|
||||
return p
|
||||
})
|
||||
|
||||
expect(results.length).toBe(14)
|
||||
expect(results[0]).toMatchObject({
|
||||
title: '-',
|
||||
start: '2025-05-29T21:00:00.000Z',
|
||||
stop: '2025-05-29T22:30:00.000Z'
|
||||
})
|
||||
expect(results[1]).toMatchObject({
|
||||
title: 'Şeytanın Evi',
|
||||
start: '2025-05-29T22:30:00.000Z',
|
||||
stop: '2025-05-30T00:00:00.000Z'
|
||||
})
|
||||
})
|
||||
|
||||
it('can handle empty guide', () => {
|
||||
const content = fs.readFileSync(path.resolve(__dirname, '__data__/no_content.html'))
|
||||
const result = parser({
|
||||
date,
|
||||
channel,
|
||||
content
|
||||
})
|
||||
expect(result).toMatchObject([])
|
||||
})
|
||||
const { parser, url } = require('./turksatkablo.com.tr.config.js')
|
||||
const fs = require('fs')
|
||||
const path = require('path')
|
||||
const dayjs = require('dayjs')
|
||||
const utc = require('dayjs/plugin/utc')
|
||||
const customParseFormat = require('dayjs/plugin/customParseFormat')
|
||||
dayjs.extend(customParseFormat)
|
||||
dayjs.extend(utc)
|
||||
|
||||
const date = dayjs.utc('2025-05-30', 'YYYY-MM-DD').startOf('d')
|
||||
const channel = { site_id: '1908' }
|
||||
|
||||
it('can generate valid url', () => {
|
||||
const result = url({ date })
|
||||
|
||||
expect(result).toBe('https://www.turksatkablo.com.tr/userUpload/EPG/30.json?_=1748563200000')
|
||||
})
|
||||
|
||||
it('can parse response', () => {
|
||||
const content = fs.readFileSync(path.resolve(__dirname, '__data__/content.json'))
|
||||
const results = parser({ date, channel, content }).map(p => {
|
||||
p.start = p.start.toJSON()
|
||||
p.stop = p.stop.toJSON()
|
||||
return p
|
||||
})
|
||||
|
||||
expect(results.length).toBe(14)
|
||||
expect(results[0]).toMatchObject({
|
||||
title: '-',
|
||||
start: '2025-05-29T21:00:00.000Z',
|
||||
stop: '2025-05-29T22:30:00.000Z'
|
||||
})
|
||||
expect(results[1]).toMatchObject({
|
||||
title: 'Şeytanın Evi',
|
||||
start: '2025-05-29T22:30:00.000Z',
|
||||
stop: '2025-05-30T00:00:00.000Z'
|
||||
})
|
||||
})
|
||||
|
||||
it('can handle empty guide', () => {
|
||||
const content = fs.readFileSync(path.resolve(__dirname, '__data__/no_content.html'))
|
||||
const result = parser({
|
||||
date,
|
||||
channel,
|
||||
content
|
||||
})
|
||||
expect(result).toMatchObject([])
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user