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,74 +1,74 @@
const dayjs = require('dayjs')
const utc = require('dayjs/plugin/utc')
dayjs.extend(utc)
module.exports = {
delay: 1000,
site: 'tv.trueid.net',
days: 1,
url({ channel }) {
return `https://tv.trueid.net/_next/data/1380644e0f1fb6b14c82894a0c682d147e015c9d/th-${channel.lang}.json?channelSlug=${channel.site_id}&path=${channel.site_id}`
},
parser({ content, channel }) {
const programs = []
parseItems(content, channel).forEach(item => {
programs.push({
title: item.title,
description: parseDescription(item, channel.lang),
image: parseImage(item),
start: parseStart(item),
stop: parseStop(item)
})
})
return programs
},
async channels({ token, lang = 'en' }) {
const axios = require('axios')
const ACCESS_TOKEN = token
? token
: 'MTM4MDY0NGUwZjFmYjZiMTRjODI4OTRhMGM2ODJkMTQ3ZTAxNWM5ZDoxZmI2YjE0YzgyODk0YTBjNjgyZDE0N2UwMTVjOWQ='
const data = await axios
.get(`https://tv.trueid.net/api/channel/getChannelListByAllCate?lang=${lang}&country=th`, {
headers: {
authorization: `Basic ${ACCESS_TOKEN}`
}
})
.then(r => r.data)
.catch(console.error)
return data.data.channelsList
.find(i => i.catSlug === 'TrueID : All')
.channels.map(item => {
return {
lang,
site_id: item.slug,
name: item.title
}
})
}
}
function parseDescription(item, lang) {
const description = item.info?.[`synopsis_${lang}`]
return description && description !== '.' ? description : null
}
function parseImage(item) {
return item.info?.image || null
}
function parseStart(item) {
return item.start_date ? dayjs.utc(item.start_date) : null
}
function parseStop(item) {
return item.end_date ? dayjs.utc(item.end_date) : null
}
function parseItems(content) {
const data = content ? JSON.parse(content) : null
return data?.pageProps?.epgList || []
}
const dayjs = require('dayjs')
const utc = require('dayjs/plugin/utc')
dayjs.extend(utc)
module.exports = {
delay: 1000,
site: 'tv.trueid.net',
days: 1,
url({ channel }) {
return `https://tv.trueid.net/_next/data/1380644e0f1fb6b14c82894a0c682d147e015c9d/th-${channel.lang}.json?channelSlug=${channel.site_id}&path=${channel.site_id}`
},
parser({ content, channel }) {
const programs = []
parseItems(content, channel).forEach(item => {
programs.push({
title: item.title,
description: parseDescription(item, channel.lang),
image: parseImage(item),
start: parseStart(item),
stop: parseStop(item)
})
})
return programs
},
async channels({ token, lang = 'en' }) {
const axios = require('axios')
const ACCESS_TOKEN = token
? token
: 'MTM4MDY0NGUwZjFmYjZiMTRjODI4OTRhMGM2ODJkMTQ3ZTAxNWM5ZDoxZmI2YjE0YzgyODk0YTBjNjgyZDE0N2UwMTVjOWQ='
const data = await axios
.get(`https://tv.trueid.net/api/channel/getChannelListByAllCate?lang=${lang}&country=th`, {
headers: {
authorization: `Basic ${ACCESS_TOKEN}`
}
})
.then(r => r.data)
.catch(console.error)
return data.data.channelsList
.find(i => i.catSlug === 'TrueID : All')
.channels.map(item => {
return {
lang,
site_id: item.slug,
name: item.title
}
})
}
}
function parseDescription(item, lang) {
const description = item.info?.[`synopsis_${lang}`]
return description && description !== '.' ? description : null
}
function parseImage(item) {
return item.info?.image || null
}
function parseStart(item) {
return item.start_date ? dayjs.utc(item.start_date) : null
}
function parseStop(item) {
return item.end_date ? dayjs.utc(item.end_date) : null
}
function parseItems(content) {
const data = content ? JSON.parse(content) : null
return data?.pageProps?.epgList || []
}

View File

@@ -1,62 +1,62 @@
const { parser, url } = require('./tv.trueid.net.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('2023-12-11').startOf('d')
const channel = {
lang: 'en',
site_id: 'true-movie-hits',
xmltv_id: 'TrueMovieHits.th'
}
const channelTh = Object.assign({}, channel, { lang: 'th' })
const data = fs.readFileSync(path.resolve(__dirname, '__data__/data.json'))
it('can generate valid url', () => {
const result = url({ channel, date })
expect(result).toBe(
'https://tv.trueid.net/_next/data/1380644e0f1fb6b14c82894a0c682d147e015c9d/th-en.json?channelSlug=true-movie-hits&path=true-movie-hits'
)
})
it('can parse English response', () => {
const result = parser({ date, channel, content: data }).map(p => {
p.start = p.start.toJSON()
p.stop = p.stop.toJSON()
return p
})
expect(result[0]).toMatchObject({
start: '2023-12-11T19:05:00.000Z',
stop: '2023-12-11T20:55:00.000Z',
title: 'The Last Witch Hunter',
description:
'A young man is all that stands between humanity and the most horrifying witches in history.',
image: 'https://bms.dmpcdn.com/uploads/pic/381f853da5f4a310bf248357fed21a57.jpg'
})
})
it('can parse Thai response', () => {
const result = parser({ date, channel: channelTh, content: data }).map(p => {
p.start = p.start.toJSON()
p.stop = p.stop.toJSON()
return p
})
expect(result[0]).toMatchObject({
start: '2023-12-11T19:05:00.000Z',
stop: '2023-12-11T20:55:00.000Z',
title: 'The Last Witch Hunter',
description:
'หนุ่มนักล่าแม่มดถูกสาปให้เป็นอมตะจนกระทั่งราชินีแม่มดได้ฟื้นคืนชีพขึ้นมาจึงมีเพียงเขาคนเดียวเท่านั้นที่จะสามารถกอบกู้มวลมนุษยชาติได้',
image: 'https://bms.dmpcdn.com/uploads/pic/381f853da5f4a310bf248357fed21a57.jpg'
})
})
it('can handle empty guide', () => {
const result = parser({ date, channel, content: '{}' })
expect(result).toMatchObject([])
})
const { parser, url } = require('./tv.trueid.net.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('2023-12-11').startOf('d')
const channel = {
lang: 'en',
site_id: 'true-movie-hits',
xmltv_id: 'TrueMovieHits.th'
}
const channelTh = Object.assign({}, channel, { lang: 'th' })
const data = fs.readFileSync(path.resolve(__dirname, '__data__/data.json'))
it('can generate valid url', () => {
const result = url({ channel, date })
expect(result).toBe(
'https://tv.trueid.net/_next/data/1380644e0f1fb6b14c82894a0c682d147e015c9d/th-en.json?channelSlug=true-movie-hits&path=true-movie-hits'
)
})
it('can parse English response', () => {
const result = parser({ date, channel, content: data }).map(p => {
p.start = p.start.toJSON()
p.stop = p.stop.toJSON()
return p
})
expect(result[0]).toMatchObject({
start: '2023-12-11T19:05:00.000Z',
stop: '2023-12-11T20:55:00.000Z',
title: 'The Last Witch Hunter',
description:
'A young man is all that stands between humanity and the most horrifying witches in history.',
image: 'https://bms.dmpcdn.com/uploads/pic/381f853da5f4a310bf248357fed21a57.jpg'
})
})
it('can parse Thai response', () => {
const result = parser({ date, channel: channelTh, content: data }).map(p => {
p.start = p.start.toJSON()
p.stop = p.stop.toJSON()
return p
})
expect(result[0]).toMatchObject({
start: '2023-12-11T19:05:00.000Z',
stop: '2023-12-11T20:55:00.000Z',
title: 'The Last Witch Hunter',
description:
'หนุ่มนักล่าแม่มดถูกสาปให้เป็นอมตะจนกระทั่งราชินีแม่มดได้ฟื้นคืนชีพขึ้นมาจึงมีเพียงเขาคนเดียวเท่านั้นที่จะสามารถกอบกู้มวลมนุษยชาติได้',
image: 'https://bms.dmpcdn.com/uploads/pic/381f853da5f4a310bf248357fed21a57.jpg'
})
})
it('can handle empty guide', () => {
const result = parser({ date, channel, content: '{}' })
expect(result).toMatchObject([])
})