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,88 +1,88 @@
const axios = require('axios')
const dayjs = require('dayjs')
const languages = { en: 'en_US', zh: 'zh' }
module.exports = {
site: 'starhubtvplus.com',
days: 2,
url({ date, channel }) {
return `https://waf-starhub-metadata-api-p001.ifs.vubiquity.com/v3.1/epg/schedules?locale=${
languages[channel.lang]
}&locale_default=${languages[channel.lang]}&device=1&in_channel_id=${
channel.site_id
}&gt_end=${date.unix()}&lt_start=${date.add(1, 'd').unix()}&limit=100&page=1`
},
async parser({ content, date, channel }) {
const programs = []
if (content) {
let res = JSON.parse(content)
while (res) {
if (res.resources) {
programs.push(...res.resources)
}
if (res.page && res.page.current < res.page.total) {
res = await axios
.get(
module.exports
.url({ date, channel })
.replace(/page=(\d+)/, `page=${res.page.current + 1}`)
)
.then(r => r.data)
.catch(console.error)
} else {
res = null
}
}
}
const season = s => {
if (s) {
const [, , n] = s.match(/(S|Season )(\d+)/) || [null, null, null]
if (n) {
return parseInt(n)
}
}
}
return programs.map(item => {
return {
title: item.title,
subTitle: item.serie_title,
description: item.description,
category: item.genres,
image: item.pictures?.map(img => img.url),
season: season(item.serie_title),
episode: item.episode_number,
rating: item.rating,
start: dayjs(item.start * 1000),
stop: dayjs(item.end * 1000)
}
})
},
async channels({ lang = 'en' }) {
const resources = []
let page = 1
while (true) {
const items = await axios
.get(
`https://waf-starhub-metadata-api-p001.ifs.vubiquity.com/v3.1/epg/channels?locale=${languages[lang]}&locale_default=${languages[lang]}&device=1&limit=50&page=${page}`
)
.then(r => r.data)
.catch(console.error)
if (items.resources) {
resources.push(...items.resources)
}
if (items.page && page < items.page.total) {
page++
} else {
break
}
}
return resources.map(ch => ({
lang,
site_id: ch.id,
name: ch.title
}))
}
}
const axios = require('axios')
const dayjs = require('dayjs')
const languages = { en: 'en_US', zh: 'zh' }
module.exports = {
site: 'starhubtvplus.com',
days: 2,
url({ date, channel }) {
return `https://waf-starhub-metadata-api-p001.ifs.vubiquity.com/v3.1/epg/schedules?locale=${
languages[channel.lang]
}&locale_default=${languages[channel.lang]}&device=1&in_channel_id=${
channel.site_id
}&gt_end=${date.unix()}&lt_start=${date.add(1, 'd').unix()}&limit=100&page=1`
},
async parser({ content, date, channel }) {
const programs = []
if (content) {
let res = JSON.parse(content)
while (res) {
if (res.resources) {
programs.push(...res.resources)
}
if (res.page && res.page.current < res.page.total) {
res = await axios
.get(
module.exports
.url({ date, channel })
.replace(/page=(\d+)/, `page=${res.page.current + 1}`)
)
.then(r => r.data)
.catch(console.error)
} else {
res = null
}
}
}
const season = s => {
if (s) {
const [, , n] = s.match(/(S|Season )(\d+)/) || [null, null, null]
if (n) {
return parseInt(n)
}
}
}
return programs.map(item => {
return {
title: item.title,
subTitle: item.serie_title,
description: item.description,
category: item.genres,
image: item.pictures?.map(img => img.url),
season: season(item.serie_title),
episode: item.episode_number,
rating: item.rating,
start: dayjs(item.start * 1000),
stop: dayjs(item.end * 1000)
}
})
},
async channels({ lang = 'en' }) {
const resources = []
let page = 1
while (true) {
const items = await axios
.get(
`https://waf-starhub-metadata-api-p001.ifs.vubiquity.com/v3.1/epg/channels?locale=${languages[lang]}&locale_default=${languages[lang]}&device=1&limit=50&page=${page}`
)
.then(r => r.data)
.catch(console.error)
if (items.resources) {
resources.push(...items.resources)
}
if (items.page && page < items.page.total) {
page++
} else {
break
}
}
return resources.map(ch => ({
lang,
site_id: ch.id,
name: ch.title
}))
}
}

View File

@@ -1,55 +1,55 @@
const { parser, url } = require('./starhubtvplus.com.config.js')
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-04', 'YYYY-MM-DD').startOf('d')
const channel = {
lang: 'en',
site_id: 'd258444e-b66b-4cbe-88db-e09f31ab8a1f',
xmltv_id: 'AXN.sg'
}
it('can generate valid url', () => {
expect(url({ channel, date })).toBe(
'https://waf-starhub-metadata-api-p001.ifs.vubiquity.com/v3.1/epg/schedules?locale=en_US&locale_default=en_US&device=1&in_channel_id=d258444e-b66b-4cbe-88db-e09f31ab8a1f&gt_end=1733270400&lt_start=1733356800&limit=100&page=1'
)
})
it('can parse response', async () => {
const fs = require('fs')
const path = require('path')
const content = fs.readFileSync(path.join(__dirname, '__data__', 'content.json'))
const result = (await parser({ content, date, channel })).map(p => {
p.start = p.start.toJSON()
p.stop = p.stop.toJSON()
return p
})
expect(result).toMatchObject([
{
start: '2024-12-03T17:25:00.000Z',
stop: '2024-12-03T18:20:00.000Z',
title: 'Northern Rexposure',
subTitle: 'Hudson & Rex (Season 5)',
description:
"When Jesse's sister contacts him for help, he, Sarah and Rex head to Northern Ontario and find themselves in the middle of a deadly situation.",
category: ['Drama'],
image: [
'https://poster.starhubgo.com/poster/ch511_hudson_rex5.jpg?w=960&h=540',
'https://poster.starhubgo.com/poster/ch511_hudson_rex5.jpg?w=341&h=192'
],
season: 5,
episode: 15,
rating: 'PG13'
}
])
})
it('can handle empty guide', async () => {
const result = await parser({ content: '' })
expect(result).toMatchObject([])
})
const { parser, url } = require('./starhubtvplus.com.config.js')
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-04', 'YYYY-MM-DD').startOf('d')
const channel = {
lang: 'en',
site_id: 'd258444e-b66b-4cbe-88db-e09f31ab8a1f',
xmltv_id: 'AXN.sg'
}
it('can generate valid url', () => {
expect(url({ channel, date })).toBe(
'https://waf-starhub-metadata-api-p001.ifs.vubiquity.com/v3.1/epg/schedules?locale=en_US&locale_default=en_US&device=1&in_channel_id=d258444e-b66b-4cbe-88db-e09f31ab8a1f&gt_end=1733270400&lt_start=1733356800&limit=100&page=1'
)
})
it('can parse response', async () => {
const fs = require('fs')
const path = require('path')
const content = fs.readFileSync(path.join(__dirname, '__data__', 'content.json'))
const result = (await parser({ content, date, channel })).map(p => {
p.start = p.start.toJSON()
p.stop = p.stop.toJSON()
return p
})
expect(result).toMatchObject([
{
start: '2024-12-03T17:25:00.000Z',
stop: '2024-12-03T18:20:00.000Z',
title: 'Northern Rexposure',
subTitle: 'Hudson & Rex (Season 5)',
description:
"When Jesse's sister contacts him for help, he, Sarah and Rex head to Northern Ontario and find themselves in the middle of a deadly situation.",
category: ['Drama'],
image: [
'https://poster.starhubgo.com/poster/ch511_hudson_rex5.jpg?w=960&h=540',
'https://poster.starhubgo.com/poster/ch511_hudson_rex5.jpg?w=341&h=192'
],
season: 5,
episode: 15,
rating: 'PG13'
}
])
})
it('can handle empty guide', async () => {
const result = await parser({ content: '' })
expect(result).toMatchObject([])
})