Replace LF endings with CRLF

This commit is contained in:
freearhey
2025-07-31 22:29:01 +03:00
parent 17e3b4ddda
commit 29aa427923
379 changed files with 29332 additions and 29332 deletions

View File

@@ -1,71 +1,71 @@
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 languages = { en: 'ENG', id: 'IND' }
module.exports = {
site: 'visionplus.id',
days: 2,
url({ date, channel }) {
return `https://www.visionplus.id/managetv/tvinfo/events/schedule?language=${
languages[channel.lang]
}&serviceId=${channel.site_id}&start=${date.format('YYYY-MM-DD')}T00%3A00%3A00Z&end=${date
.add(1, 'd')
.format('YYYY-MM-DD')}T00%3A00%3A00Z&view=cd-events-grid-view`
},
parser({ content, channel }) {
const programs = []
const json = JSON.parse(content)
if (Array.isArray(json.evs)) {
for (const ev of json.evs) {
if (ev.sid === channel.site_id) {
const title = ev.con && ev.con.loc ? ev.con.loc[0].tit : ev.con.oti
const [, , season, , episode] = title.match(/( S(\d+))?(, Ep (\d+))/) || [
null,
null,
null,
null,
null
]
programs.push({
title,
description: ev.con && ev.con.loc ? ev.con.loc[0].syn : null,
categories: ev.con ? ev.con.categories : null,
season: season ? parseInt(season) : season,
episode: episode ? parseInt(episode) : episode,
start: dayjs(ev.sta),
stop: dayjs(ev.end)
})
}
}
}
return programs
},
async channels({ lang = 'id' }) {
const result = []
const axios = require('axios')
const json = await axios
.get(`https://www.visionplus.id/managetv/tvinfo/channels/get?language=${languages[lang]}`)
.then(response => response.data)
.catch(console.error)
if (Array.isArray(json?.chs)) {
for (const ch of json.chs) {
result.push({
lang,
site_id: ch.sid,
name: ch.loc[0].nam
})
}
}
return result
}
}
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 languages = { en: 'ENG', id: 'IND' }
module.exports = {
site: 'visionplus.id',
days: 2,
url({ date, channel }) {
return `https://www.visionplus.id/managetv/tvinfo/events/schedule?language=${
languages[channel.lang]
}&serviceId=${channel.site_id}&start=${date.format('YYYY-MM-DD')}T00%3A00%3A00Z&end=${date
.add(1, 'd')
.format('YYYY-MM-DD')}T00%3A00%3A00Z&view=cd-events-grid-view`
},
parser({ content, channel }) {
const programs = []
const json = JSON.parse(content)
if (Array.isArray(json.evs)) {
for (const ev of json.evs) {
if (ev.sid === channel.site_id) {
const title = ev.con && ev.con.loc ? ev.con.loc[0].tit : ev.con.oti
const [, , season, , episode] = title.match(/( S(\d+))?(, Ep (\d+))/) || [
null,
null,
null,
null,
null
]
programs.push({
title,
description: ev.con && ev.con.loc ? ev.con.loc[0].syn : null,
categories: ev.con ? ev.con.categories : null,
season: season ? parseInt(season) : season,
episode: episode ? parseInt(episode) : episode,
start: dayjs(ev.sta),
stop: dayjs(ev.end)
})
}
}
}
return programs
},
async channels({ lang = 'id' }) {
const result = []
const axios = require('axios')
const json = await axios
.get(`https://www.visionplus.id/managetv/tvinfo/channels/get?language=${languages[lang]}`)
.then(response => response.data)
.catch(console.error)
if (Array.isArray(json?.chs)) {
for (const ch of json.chs) {
result.push({
lang,
site_id: ch.sid,
name: ch.loc[0].nam
})
}
}
return result
}
}

View File

@@ -1,73 +1,73 @@
const { parser, url } = require('./visionplus.id.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)
jest.mock('axios')
const date = dayjs.utc('2024-11-24', 'YYYY-MM-DD').startOf('d')
const channel = {
site_id: '00000000000000000079',
xmltv_id: 'AXN.id',
lang: 'en'
}
const channelId = { ...channel, lang: 'id' }
it('can generate valid url', () => {
expect(url({ channel, date })).toBe(
'https://www.visionplus.id/managetv/tvinfo/events/schedule?language=ENG&serviceId=00000000000000000079&start=2024-11-24T00%3A00%3A00Z&end=2024-11-25T00%3A00%3A00Z&view=cd-events-grid-view'
)
expect(url({ channel: channelId, date })).toBe(
'https://www.visionplus.id/managetv/tvinfo/events/schedule?language=IND&serviceId=00000000000000000079&start=2024-11-24T00%3A00%3A00Z&end=2024-11-25T00%3A00%3A00Z&view=cd-events-grid-view'
)
})
it('can parse response', () => {
let content = fs.readFileSync(path.resolve(__dirname, '__data__/content_en.json'))
let results = parser({ content, channel, date }).map(p => {
p.start = p.start.toJSON()
p.stop = p.stop.toJSON()
return p
})
expect(results.length).toBe(1)
expect(results[0]).toMatchObject({
start: '2024-11-23T23:30:00.000Z',
stop: '2024-11-24T00:15:00.000Z',
title: 'FBI: Most Wanted S4, Ep 18',
description:
'After two agents from the Bureau of Land Management go missing while executing a land seizure warrant in Wyoming, the Fugitive Task Force heads west to track them down in an unwelcoming county.',
season: 4,
episode: 18
})
content = fs.readFileSync(path.resolve(__dirname, '__data__/content_id.json'))
results = parser({ content, channel: channelId, date }).map(p => {
p.start = p.start.toJSON()
p.stop = p.stop.toJSON()
return p
})
expect(results.length).toBe(1)
expect(results[0]).toMatchObject({
start: '2024-11-23T23:30:00.000Z',
stop: '2024-11-24T00:15:00.000Z',
title: 'FBI: Most Wanted S4, Ep 18',
description:
'Satgas Buronan pergi ke wilayah barat untuk melacak keberadaan dua petugas Biro Pengelolaan Lahan yang menghilang saat menjalankan perintah penyitaan lahan di negara bagian yang tak ramah, Wyoming.',
season: 4,
episode: 18
})
})
it('can handle empty guide', () => {
const content = fs.readFileSync(path.resolve(__dirname, '__data__/no_content.json'))
const results = parser({ content, channel })
expect(results).toMatchObject([])
})
const { parser, url } = require('./visionplus.id.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)
jest.mock('axios')
const date = dayjs.utc('2024-11-24', 'YYYY-MM-DD').startOf('d')
const channel = {
site_id: '00000000000000000079',
xmltv_id: 'AXN.id',
lang: 'en'
}
const channelId = { ...channel, lang: 'id' }
it('can generate valid url', () => {
expect(url({ channel, date })).toBe(
'https://www.visionplus.id/managetv/tvinfo/events/schedule?language=ENG&serviceId=00000000000000000079&start=2024-11-24T00%3A00%3A00Z&end=2024-11-25T00%3A00%3A00Z&view=cd-events-grid-view'
)
expect(url({ channel: channelId, date })).toBe(
'https://www.visionplus.id/managetv/tvinfo/events/schedule?language=IND&serviceId=00000000000000000079&start=2024-11-24T00%3A00%3A00Z&end=2024-11-25T00%3A00%3A00Z&view=cd-events-grid-view'
)
})
it('can parse response', () => {
let content = fs.readFileSync(path.resolve(__dirname, '__data__/content_en.json'))
let results = parser({ content, channel, date }).map(p => {
p.start = p.start.toJSON()
p.stop = p.stop.toJSON()
return p
})
expect(results.length).toBe(1)
expect(results[0]).toMatchObject({
start: '2024-11-23T23:30:00.000Z',
stop: '2024-11-24T00:15:00.000Z',
title: 'FBI: Most Wanted S4, Ep 18',
description:
'After two agents from the Bureau of Land Management go missing while executing a land seizure warrant in Wyoming, the Fugitive Task Force heads west to track them down in an unwelcoming county.',
season: 4,
episode: 18
})
content = fs.readFileSync(path.resolve(__dirname, '__data__/content_id.json'))
results = parser({ content, channel: channelId, date }).map(p => {
p.start = p.start.toJSON()
p.stop = p.stop.toJSON()
return p
})
expect(results.length).toBe(1)
expect(results[0]).toMatchObject({
start: '2024-11-23T23:30:00.000Z',
stop: '2024-11-24T00:15:00.000Z',
title: 'FBI: Most Wanted S4, Ep 18',
description:
'Satgas Buronan pergi ke wilayah barat untuk melacak keberadaan dua petugas Biro Pengelolaan Lahan yang menghilang saat menjalankan perintah penyitaan lahan di negara bagian yang tak ramah, Wyoming.',
season: 4,
episode: 18
})
})
it('can handle empty guide', () => {
const content = fs.readFileSync(path.resolve(__dirname, '__data__/no_content.json'))
const results = parser({ content, channel })
expect(results).toMatchObject([])
})