mirror of
https://github.com/iptv-org/epg
synced 2026-04-29 22:16:59 -04:00
Replace LF endings with CRLF
This commit is contained in:
@@ -1,49 +1,49 @@
|
||||
const dayjs = require('dayjs')
|
||||
const utc = require('dayjs/plugin/utc')
|
||||
const timezone = require('dayjs/plugin/timezone')
|
||||
|
||||
dayjs.extend(utc)
|
||||
dayjs.extend(timezone)
|
||||
|
||||
module.exports = {
|
||||
site: 'pluto.tv',
|
||||
days: 3,
|
||||
|
||||
url: function ({ date, channel }) {
|
||||
const channelId = channel.site_id
|
||||
|
||||
const localTimezone = dayjs.tz.guess()
|
||||
|
||||
const startTime = dayjs(date).tz(localTimezone).startOf('day').toISOString()
|
||||
const endTime = dayjs(date).tz(localTimezone).add(this.days, 'day').endOf('day').toISOString()
|
||||
|
||||
const generatedUrl = `https://api.pluto.tv/v2/channels/${channelId}?start=${startTime}&stop=${endTime}`
|
||||
return generatedUrl
|
||||
},
|
||||
|
||||
parser: function ({ content }) {
|
||||
const data = JSON.parse(content)
|
||||
const programs = []
|
||||
|
||||
if (data.timelines) {
|
||||
data.timelines.forEach(item => {
|
||||
programs.push({
|
||||
title: item.title,
|
||||
subTitle: item.episode?.name || '',
|
||||
description: item.episode?.description || '',
|
||||
episode: item.episode?.number || '',
|
||||
season: item.episode?.season || '',
|
||||
actors: item.episode?.clip?.actors || [],
|
||||
categories: [item.episode?.genre, item.episode?.subGenre].filter(Boolean),
|
||||
rating: item.episode?.rating || '',
|
||||
date: item.episode?.clip?.originalReleaseDate || '',
|
||||
icon: item.episode?.series?.tile?.path || '',
|
||||
start: item.start,
|
||||
stop: item.stop
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
return programs
|
||||
}
|
||||
}
|
||||
const dayjs = require('dayjs')
|
||||
const utc = require('dayjs/plugin/utc')
|
||||
const timezone = require('dayjs/plugin/timezone')
|
||||
|
||||
dayjs.extend(utc)
|
||||
dayjs.extend(timezone)
|
||||
|
||||
module.exports = {
|
||||
site: 'pluto.tv',
|
||||
days: 3,
|
||||
|
||||
url: function ({ date, channel }) {
|
||||
const channelId = channel.site_id
|
||||
|
||||
const localTimezone = dayjs.tz.guess()
|
||||
|
||||
const startTime = dayjs(date).tz(localTimezone).startOf('day').toISOString()
|
||||
const endTime = dayjs(date).tz(localTimezone).add(this.days, 'day').endOf('day').toISOString()
|
||||
|
||||
const generatedUrl = `https://api.pluto.tv/v2/channels/${channelId}?start=${startTime}&stop=${endTime}`
|
||||
return generatedUrl
|
||||
},
|
||||
|
||||
parser: function ({ content }) {
|
||||
const data = JSON.parse(content)
|
||||
const programs = []
|
||||
|
||||
if (data.timelines) {
|
||||
data.timelines.forEach(item => {
|
||||
programs.push({
|
||||
title: item.title,
|
||||
subTitle: item.episode?.name || '',
|
||||
description: item.episode?.description || '',
|
||||
episode: item.episode?.number || '',
|
||||
season: item.episode?.season || '',
|
||||
actors: item.episode?.clip?.actors || [],
|
||||
categories: [item.episode?.genre, item.episode?.subGenre].filter(Boolean),
|
||||
rating: item.episode?.rating || '',
|
||||
date: item.episode?.clip?.originalReleaseDate || '',
|
||||
icon: item.episode?.series?.tile?.path || '',
|
||||
start: item.start,
|
||||
stop: item.stop
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
return programs
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,59 +1,59 @@
|
||||
const config = require('./pluto.tv.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('2024-12-28', 'YYYY-MM-DD').startOf('d')
|
||||
const channel = {
|
||||
site_id: '5ee92e72fb286e0007285fec',
|
||||
xmltv_id: 'Naruto'
|
||||
}
|
||||
|
||||
it('can generate valid url', () => {
|
||||
const url = config.url({ date, channel })
|
||||
expect(url).toBe(
|
||||
'https://api.pluto.tv/v2/channels/5ee92e72fb286e0007285fec?start=2024-12-27T12:00:00.000Z&stop=2024-12-31T11:59:59.999Z'
|
||||
)
|
||||
})
|
||||
|
||||
it('can parse response', () => {
|
||||
const content = fs.readFileSync(path.resolve(__dirname, '__data__/content.json'), 'utf8')
|
||||
const results = config.parser({ content }).map(p => {
|
||||
p.start = dayjs(p.start).toJSON()
|
||||
p.stop = dayjs(p.stop).toJSON()
|
||||
return p
|
||||
})
|
||||
|
||||
expect(results[0]).toMatchObject({
|
||||
start: '2024-12-28T00:21:00.000Z',
|
||||
stop: '2024-12-28T00:48:00.000Z',
|
||||
title: 'Naruto: El Tercer Hokage, Eternamente',
|
||||
description:
|
||||
'Gaara y Naruto continúan combatiendo con todas sus fuerzas. Decidido a proteger a Sakura, Naruto ataca a Gaara una y otra vez.',
|
||||
subTitle: 'El Tercer Hokage, Eternamente',
|
||||
episode: 80,
|
||||
season: 2,
|
||||
actors: [
|
||||
'Isabel Martion (Naruto Uzumaki)',
|
||||
'Christine Byrd (Sakura Haruno)',
|
||||
'Victor Ugarte (Sasuke Uchiha)',
|
||||
'Alfonso Obreg (Kakashi Hatake)'
|
||||
],
|
||||
categories: ['Anime', 'Anime Action & Adventure'],
|
||||
rating: 'TV-14',
|
||||
date: '2004-04-21T00:00:00.000Z',
|
||||
icon: 'https://images.pluto.tv/series/5e73b850e40c9f001a0a9fb4/tile.jpg?fill=blur&fit=fill&fm=jpg&h=660&q=75&w=660'
|
||||
})
|
||||
})
|
||||
|
||||
it('can handle empty guide', () => {
|
||||
const results = config.parser({
|
||||
content: '[]'
|
||||
})
|
||||
expect(results).toMatchObject([])
|
||||
})
|
||||
const config = require('./pluto.tv.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('2024-12-28', 'YYYY-MM-DD').startOf('d')
|
||||
const channel = {
|
||||
site_id: '5ee92e72fb286e0007285fec',
|
||||
xmltv_id: 'Naruto'
|
||||
}
|
||||
|
||||
it('can generate valid url', () => {
|
||||
const url = config.url({ date, channel })
|
||||
expect(url).toBe(
|
||||
'https://api.pluto.tv/v2/channels/5ee92e72fb286e0007285fec?start=2024-12-27T12:00:00.000Z&stop=2024-12-31T11:59:59.999Z'
|
||||
)
|
||||
})
|
||||
|
||||
it('can parse response', () => {
|
||||
const content = fs.readFileSync(path.resolve(__dirname, '__data__/content.json'), 'utf8')
|
||||
const results = config.parser({ content }).map(p => {
|
||||
p.start = dayjs(p.start).toJSON()
|
||||
p.stop = dayjs(p.stop).toJSON()
|
||||
return p
|
||||
})
|
||||
|
||||
expect(results[0]).toMatchObject({
|
||||
start: '2024-12-28T00:21:00.000Z',
|
||||
stop: '2024-12-28T00:48:00.000Z',
|
||||
title: 'Naruto: El Tercer Hokage, Eternamente',
|
||||
description:
|
||||
'Gaara y Naruto continúan combatiendo con todas sus fuerzas. Decidido a proteger a Sakura, Naruto ataca a Gaara una y otra vez.',
|
||||
subTitle: 'El Tercer Hokage, Eternamente',
|
||||
episode: 80,
|
||||
season: 2,
|
||||
actors: [
|
||||
'Isabel Martion (Naruto Uzumaki)',
|
||||
'Christine Byrd (Sakura Haruno)',
|
||||
'Victor Ugarte (Sasuke Uchiha)',
|
||||
'Alfonso Obreg (Kakashi Hatake)'
|
||||
],
|
||||
categories: ['Anime', 'Anime Action & Adventure'],
|
||||
rating: 'TV-14',
|
||||
date: '2004-04-21T00:00:00.000Z',
|
||||
icon: 'https://images.pluto.tv/series/5e73b850e40c9f001a0a9fb4/tile.jpg?fill=blur&fit=fill&fm=jpg&h=660&q=75&w=660'
|
||||
})
|
||||
})
|
||||
|
||||
it('can handle empty guide', () => {
|
||||
const results = config.parser({
|
||||
content: '[]'
|
||||
})
|
||||
expect(results).toMatchObject([])
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user