Fix tvpassport.com timezone to be dynamic from the content

Uses the timezone from the selected timezone of the dropdown on the page, instead of always hardcoding America/New_York. This fixes an offset I was having from pulling the guide from an IP address in the central timezone.
This commit is contained in:
dblake10
2026-02-24 16:09:43 -06:00
committed by GitHub
parent e4f92bb2a2
commit 163634dee3

View File

@@ -29,10 +29,11 @@ module.exports = {
},
parser: function ({ content }) {
let programs = []
const currentTimezone = parseCurrentTimezone(content)
const items = parseItems(content)
for (let item of items) {
const $item = cheerio.load(item)
const start = parseStart($item)
const start = parseStart($item, currentTimezone)
const duration = parseDuration($item)
const stop = start.add(duration, 'm')
let title = parseTitle($item)
@@ -174,10 +175,10 @@ function parseRating($item) {
: null
}
function parseStart($item) {
function parseStart($item, currentTimezone) {
const time = $item('*').data('st')
return dayjs.tz(time, 'YYYY-MM-DD HH:mm:ss', 'America/New_York')
return dayjs.tz(time, 'YYYY-MM-DD HH:mm:ss', currentTimezone)
}
function parseDuration($item) {
@@ -192,3 +193,10 @@ function parseItems(content) {
return $('.station-listings .list-group-item').toArray()
}
function parseCurrentTimezone(content) {
if (!content) return 'America/New_York'
const $ = cheerio.load(content)
return $('#timezone_selector').val()
}