Properly generate TV schedule URL when redirected.

On www.tvpassport.com when schedule redirected to new URL, the requested date
stripped from new URL so the fetched schedules only valid for current date.

If URL was redirected, simply use the new URL with requested date appended.

Signed-off-by: Toha <tohenk@yahoo.com>
This commit is contained in:
Toha
2026-05-30 11:30:35 +07:00
parent 4b5e2319cf
commit 5fe9a8eb17
2 changed files with 73 additions and 49 deletions
+10 -2
View File
@@ -1,20 +1,28 @@
const { parser, url } = require('./tvpassport.com.config.js')
const axios = require('axios')
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('2022-10-04', 'YYYY-MM-DD').startOf('d')
const channel = {
site_id: 'youtoo-america-network/5463',
xmltv_id: 'YTATV.us'
}
it('can generate valid url', () => {
expect(url({ channel, date })).toBe(
axios.head.mockImplementation(() => {
return Promise.resolve({})
})
it('can generate valid url', async () => {
expect(await url({ channel, date })).toBe(
'https://www.tvpassport.com/tv-listings/stations/youtoo-america-network/5463/2022-10-04'
)
})