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,86 +1,86 @@
|
||||
const cheerio = require('cheerio')
|
||||
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 = 'Europe/Istanbul'
|
||||
|
||||
module.exports = {
|
||||
site: 'digiturk.com.tr',
|
||||
days: 2,
|
||||
url({ date }) {
|
||||
return `https://www.digiturk.com.tr/Ajax/GetTvGuideFromDigiturk?Day=${
|
||||
encodeURIComponent(date.format('MM/DD/YYYY'))
|
||||
}+00%3A00%3A00`
|
||||
},
|
||||
request: {
|
||||
cache: {
|
||||
ttl: 24 * 60 * 60 * 1000 // 1 day
|
||||
}
|
||||
},
|
||||
parser({ content, channel, date }) {
|
||||
const programs = []
|
||||
if (content) {
|
||||
const $ = cheerio.load(content)
|
||||
$('.channelDetail').toArray()
|
||||
.forEach(item => {
|
||||
const $item = $(item)
|
||||
const title = $item.find('.tvGuideResult-box-wholeDates-title')
|
||||
if (title.length) {
|
||||
const channelId = title.attr('onclick')
|
||||
if (channelId) {
|
||||
const site_id = channelId.match(/\s(\d+)\)/)[1]
|
||||
if (channel.site_id === site_id) {
|
||||
const startTime = $item.find('.tvGuideResult-box-wholeDates-time-hour').text().trim()
|
||||
const duration = $item.find('.tvGuideResult-box-wholeDates-time-totalMinute')
|
||||
.text().trim().match(/\d+/)[0]
|
||||
const start = dayjs.tz(`${date.format('YYYY-MM-DD')} ${startTime}`, 'YYYY-MM-DD HH:mm', tz)
|
||||
const stop = start.add(parseInt(duration), 'm')
|
||||
programs.push({
|
||||
title: title.text().trim(),
|
||||
start,
|
||||
stop
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
return programs
|
||||
},
|
||||
async channels() {
|
||||
const channels = {}
|
||||
const axios = require('axios')
|
||||
const data = await axios
|
||||
.get(this.url({ date: dayjs() }))
|
||||
.then(r => r.data)
|
||||
.catch(console.error)
|
||||
|
||||
const $ = cheerio.load(data)
|
||||
$('.channelContent').toArray()
|
||||
.forEach(el => {
|
||||
const item = $(el)
|
||||
const channelId = item.find('.channelDetail .tvGuideResult-box-wholeDates-title')
|
||||
.first()
|
||||
.attr('onclick')
|
||||
if (channelId) {
|
||||
const site_id = channelId.match(/\s(\d+)\)/)[1]
|
||||
if (channels[site_id] === undefined) {
|
||||
channels[site_id] = {
|
||||
lang: 'tr',
|
||||
site_id,
|
||||
name: item.find('#channelID').val()
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
return Object.values(channels)
|
||||
}
|
||||
}
|
||||
const cheerio = require('cheerio')
|
||||
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 = 'Europe/Istanbul'
|
||||
|
||||
module.exports = {
|
||||
site: 'digiturk.com.tr',
|
||||
days: 2,
|
||||
url({ date }) {
|
||||
return `https://www.digiturk.com.tr/Ajax/GetTvGuideFromDigiturk?Day=${
|
||||
encodeURIComponent(date.format('MM/DD/YYYY'))
|
||||
}+00%3A00%3A00`
|
||||
},
|
||||
request: {
|
||||
cache: {
|
||||
ttl: 24 * 60 * 60 * 1000 // 1 day
|
||||
}
|
||||
},
|
||||
parser({ content, channel, date }) {
|
||||
const programs = []
|
||||
if (content) {
|
||||
const $ = cheerio.load(content)
|
||||
$('.channelDetail').toArray()
|
||||
.forEach(item => {
|
||||
const $item = $(item)
|
||||
const title = $item.find('.tvGuideResult-box-wholeDates-title')
|
||||
if (title.length) {
|
||||
const channelId = title.attr('onclick')
|
||||
if (channelId) {
|
||||
const site_id = channelId.match(/\s(\d+)\)/)[1]
|
||||
if (channel.site_id === site_id) {
|
||||
const startTime = $item.find('.tvGuideResult-box-wholeDates-time-hour').text().trim()
|
||||
const duration = $item.find('.tvGuideResult-box-wholeDates-time-totalMinute')
|
||||
.text().trim().match(/\d+/)[0]
|
||||
const start = dayjs.tz(`${date.format('YYYY-MM-DD')} ${startTime}`, 'YYYY-MM-DD HH:mm', tz)
|
||||
const stop = start.add(parseInt(duration), 'm')
|
||||
programs.push({
|
||||
title: title.text().trim(),
|
||||
start,
|
||||
stop
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
return programs
|
||||
},
|
||||
async channels() {
|
||||
const channels = {}
|
||||
const axios = require('axios')
|
||||
const data = await axios
|
||||
.get(this.url({ date: dayjs() }))
|
||||
.then(r => r.data)
|
||||
.catch(console.error)
|
||||
|
||||
const $ = cheerio.load(data)
|
||||
$('.channelContent').toArray()
|
||||
.forEach(el => {
|
||||
const item = $(el)
|
||||
const channelId = item.find('.channelDetail .tvGuideResult-box-wholeDates-title')
|
||||
.first()
|
||||
.attr('onclick')
|
||||
if (channelId) {
|
||||
const site_id = channelId.match(/\s(\d+)\)/)[1]
|
||||
if (channels[site_id] === undefined) {
|
||||
channels[site_id] = {
|
||||
lang: 'tr',
|
||||
site_id,
|
||||
name: item.find('#channelID').val()
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
return Object.values(channels)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,48 +1,48 @@
|
||||
const { parser, url } = require('./digiturk.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-01-12', 'YYYY-MM-DD').startOf('d')
|
||||
const channel = {
|
||||
site_id: '351',
|
||||
xmltv_id: 'Nickelodeon.tr'
|
||||
}
|
||||
|
||||
it('can generate valid url', () => {
|
||||
const result = url({ date, channel })
|
||||
expect(result).toBe(
|
||||
'https://www.digiturk.com.tr/Ajax/GetTvGuideFromDigiturk?Day=01%2F12%2F2025+00%3A00%3A00'
|
||||
)
|
||||
})
|
||||
|
||||
it('can parse response', () => {
|
||||
const content = fs.readFileSync(path.join(__dirname, '__data__', 'content.html'))
|
||||
const results = parser({ content, channel, date }).map(p => {
|
||||
p.start = p.start.toJSON()
|
||||
p.stop = p.stop.toJSON()
|
||||
return p
|
||||
})
|
||||
|
||||
expect(results.length).toBe(57)
|
||||
expect(results[0]).toMatchObject({
|
||||
start: '2025-01-11T21:00:00.000Z',
|
||||
stop: '2025-01-11T21:25:00.000Z',
|
||||
title: 'Sünger Bob Kare Pantolon'
|
||||
})
|
||||
expect(results[56]).toMatchObject({
|
||||
start: '2025-01-12T17:40:00.000Z',
|
||||
stop: '2025-01-12T18:00:00.000Z',
|
||||
title: 'Casagrande Ailesi'
|
||||
})
|
||||
})
|
||||
|
||||
it('can handle empty guide', () => {
|
||||
const result = parser({ content: '', channel, date })
|
||||
expect(result).toMatchObject([])
|
||||
})
|
||||
const { parser, url } = require('./digiturk.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-01-12', 'YYYY-MM-DD').startOf('d')
|
||||
const channel = {
|
||||
site_id: '351',
|
||||
xmltv_id: 'Nickelodeon.tr'
|
||||
}
|
||||
|
||||
it('can generate valid url', () => {
|
||||
const result = url({ date, channel })
|
||||
expect(result).toBe(
|
||||
'https://www.digiturk.com.tr/Ajax/GetTvGuideFromDigiturk?Day=01%2F12%2F2025+00%3A00%3A00'
|
||||
)
|
||||
})
|
||||
|
||||
it('can parse response', () => {
|
||||
const content = fs.readFileSync(path.join(__dirname, '__data__', 'content.html'))
|
||||
const results = parser({ content, channel, date }).map(p => {
|
||||
p.start = p.start.toJSON()
|
||||
p.stop = p.stop.toJSON()
|
||||
return p
|
||||
})
|
||||
|
||||
expect(results.length).toBe(57)
|
||||
expect(results[0]).toMatchObject({
|
||||
start: '2025-01-11T21:00:00.000Z',
|
||||
stop: '2025-01-11T21:25:00.000Z',
|
||||
title: 'Sünger Bob Kare Pantolon'
|
||||
})
|
||||
expect(results[56]).toMatchObject({
|
||||
start: '2025-01-12T17:40:00.000Z',
|
||||
stop: '2025-01-12T18:00:00.000Z',
|
||||
title: 'Casagrande Ailesi'
|
||||
})
|
||||
})
|
||||
|
||||
it('can handle empty guide', () => {
|
||||
const result = parser({ content: '', channel, date })
|
||||
expect(result).toMatchObject([])
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user