From 43ebf91d62af98cba1d3969c082daa5378fbb7a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Isma=C3=ABl=20Moret?= <30985701+BellezaEmporium@users.noreply.github.com> Date: Sun, 26 Oct 2025 11:40:54 -0400 Subject: [PATCH 1/2] tvpassport.com : dynamic cookie handling --- sites/tvpassport.com/tvpassport.com.config.js | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/sites/tvpassport.com/tvpassport.com.config.js b/sites/tvpassport.com/tvpassport.com.config.js index 95491da2..b7f98d83 100644 --- a/sites/tvpassport.com/tvpassport.com.config.js +++ b/sites/tvpassport.com/tvpassport.com.config.js @@ -19,10 +19,12 @@ module.exports = { 'YYYY-MM-DD' )}` }, - request: { - timeout: 30000, - headers: { - Cookie: 'cisession=e49ff13191d6875887193cae9e324b44ef85768d;' + async request() { + return { + timeout: 30000, + headers: { + Cookie: await getCookie() + } } }, parser: function ({ content }) { @@ -106,6 +108,14 @@ module.exports = { } } +async function getCookie() { + const res = await axios.get('https://www.tvpassport.com/tv-listings') + const setCookie = res.headers['set-cookie'] + if (!setCookie || setCookie.length === 0) return '' + const cookies = setCookie.map(cookie => cookie.split(';')[0]) + return cookies.join('; ') +} + function parseDescription($item) { return $item('*').data('description') } From a5ab514077bb2b9111a58dd06b9c62e236ba6313 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Isma=C3=ABl=20Moret?= <30985701+BellezaEmporium@users.noreply.github.com> Date: Mon, 27 Oct 2025 04:28:47 -0400 Subject: [PATCH 2/2] remove cookie test --- sites/tvpassport.com/tvpassport.com.test.js | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/sites/tvpassport.com/tvpassport.com.test.js b/sites/tvpassport.com/tvpassport.com.test.js index 2bff8707..ca12019b 100644 --- a/sites/tvpassport.com/tvpassport.com.test.js +++ b/sites/tvpassport.com/tvpassport.com.test.js @@ -1,4 +1,4 @@ -const { parser, url, request } = require('./tvpassport.com.config.js') +const { parser, url } = require('./tvpassport.com.config.js') const fs = require('fs') const path = require('path') const dayjs = require('dayjs') @@ -19,12 +19,6 @@ it('can generate valid url', () => { ) }) -it('can generate valid request headers', () => { - expect(request.headers).toMatchObject({ - Cookie: 'cisession=e49ff13191d6875887193cae9e324b44ef85768d;' - }) -}) - it('can parse response', () => { const content = fs.readFileSync(path.resolve(__dirname, '__data__/content.html'))