mirror of
https://github.com/iptv-org/epg.git
synced 2025-05-09 08:30:06 -04:00
Set fetch days to 2 days.
In case of the date is behind current time zone, setting days to 1 day only yield previous day guide so it becomes expired. Signed-off-by: Toha <tohenk@yahoo.com>
This commit is contained in:
parent
2d03b36bb3
commit
1f8d82e869
1 changed files with 11 additions and 9 deletions
|
@ -8,18 +8,20 @@ dayjs.extend(utc)
|
|||
dayjs.extend(timezone)
|
||||
dayjs.extend(customParseFormat)
|
||||
|
||||
const tz = 'Asia/Jakarta'
|
||||
|
||||
module.exports = {
|
||||
site: 'indihometv.com',
|
||||
days: 1,
|
||||
days: 2,
|
||||
url({ channel }) {
|
||||
return `https://www.indihometv.com/livetv/${channel.site_id}`
|
||||
},
|
||||
parser({ content, date }) {
|
||||
const programs = []
|
||||
const items = parseItems(content, date)
|
||||
const [$, items] = parseItems(content, date)
|
||||
items.forEach(item => {
|
||||
const prev = programs[programs.length - 1]
|
||||
const $item = cheerio.load(item)
|
||||
const $item = $(item)
|
||||
let start = parseStart($item, date)
|
||||
if (prev && start.isBefore(prev.start)) {
|
||||
start = start.add(1, 'd')
|
||||
|
@ -64,27 +66,27 @@ module.exports = {
|
|||
}
|
||||
|
||||
function parseStart($item, date) {
|
||||
const timeString = $item('p').text()
|
||||
const timeString = $item.find('p').text()
|
||||
const [, start] = timeString.match(/(\d{2}:\d{2}) -/) || [null, null]
|
||||
const dateString = `${date.format('YYYY-MM-DD')} ${start}`
|
||||
|
||||
return dayjs.tz(dateString, 'YYYY-MM-DD HH:mm', 'Asia/Jakarta')
|
||||
return dayjs.tz(dateString, 'YYYY-MM-DD HH:mm', tz)
|
||||
}
|
||||
|
||||
function parseStop($item, date) {
|
||||
const timeString = $item('p').text()
|
||||
const timeString = $item.find('p').text()
|
||||
const [, stop] = timeString.match(/- (\d{2}:\d{2})/) || [null, null]
|
||||
const dateString = `${date.format('YYYY-MM-DD')} ${stop}`
|
||||
|
||||
return dayjs.tz(dateString, 'YYYY-MM-DD HH:mm', 'Asia/Jakarta')
|
||||
return dayjs.tz(dateString, 'YYYY-MM-DD HH:mm', tz)
|
||||
}
|
||||
|
||||
function parseTitle($item) {
|
||||
return $item('b').text()
|
||||
return $item.find('b').text()
|
||||
}
|
||||
|
||||
function parseItems(content, date) {
|
||||
const $ = cheerio.load(content)
|
||||
|
||||
return $(`#pills-${date.format('YYYY-MM-DD')} .schedule-item`).toArray()
|
||||
return [$, $(`#pills-${date.format('YYYY-MM-DD')} .schedule-item`).toArray()]
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue