mirror of
https://github.com/iptv-org/epg
synced 2026-03-21 19:30:52 -04:00
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:
@@ -29,10 +29,11 @@ module.exports = {
|
|||||||
},
|
},
|
||||||
parser: function ({ content }) {
|
parser: function ({ content }) {
|
||||||
let programs = []
|
let programs = []
|
||||||
|
const currentTimezone = parseCurrentTimezone(content)
|
||||||
const items = parseItems(content)
|
const items = parseItems(content)
|
||||||
for (let item of items) {
|
for (let item of items) {
|
||||||
const $item = cheerio.load(item)
|
const $item = cheerio.load(item)
|
||||||
const start = parseStart($item)
|
const start = parseStart($item, currentTimezone)
|
||||||
const duration = parseDuration($item)
|
const duration = parseDuration($item)
|
||||||
const stop = start.add(duration, 'm')
|
const stop = start.add(duration, 'm')
|
||||||
let title = parseTitle($item)
|
let title = parseTitle($item)
|
||||||
@@ -174,10 +175,10 @@ function parseRating($item) {
|
|||||||
: null
|
: null
|
||||||
}
|
}
|
||||||
|
|
||||||
function parseStart($item) {
|
function parseStart($item, currentTimezone) {
|
||||||
const time = $item('*').data('st')
|
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) {
|
function parseDuration($item) {
|
||||||
@@ -192,3 +193,10 @@ function parseItems(content) {
|
|||||||
|
|
||||||
return $('.station-listings .list-group-item').toArray()
|
return $('.station-listings .list-group-item').toArray()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function parseCurrentTimezone(content) {
|
||||||
|
if (!content) return 'America/New_York'
|
||||||
|
const $ = cheerio.load(content)
|
||||||
|
|
||||||
|
return $('#timezone_selector').val()
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user