mirror of
https://github.com/iptv-org/epg.git
synced 2025-05-09 08:30:06 -04:00
Update moji.id guide.
Change site language to id and fix test. Signed-off-by: Toha <tohenk@yahoo.com>
This commit is contained in:
parent
7610f7b9f5
commit
dd5e3aa18a
3 changed files with 39 additions and 61 deletions
|
@ -1,4 +1,4 @@
|
|||
<?xml version="1.0"?>
|
||||
<channels>
|
||||
<channel site="moji.id" lang="en" xmltv_id="Moji.id" site_id="0">Moji</channel>
|
||||
<channel site="moji.id" lang="id" xmltv_id="Moji.id" site_id="0">Moji</channel>
|
||||
</channels>
|
|
@ -9,33 +9,15 @@ dayjs.extend(timezone)
|
|||
dayjs.extend(customParseFormat)
|
||||
|
||||
const currentYear = new Date().getFullYear()
|
||||
const tz = 'Asia/Jakarta'
|
||||
|
||||
module.exports = {
|
||||
site: 'moji.id',
|
||||
days: 4,
|
||||
output: 'moji.id.guide.xml',
|
||||
channels: 'moji.id.channels.xml',
|
||||
lang: 'en',
|
||||
delay: 5000,
|
||||
|
||||
url: function () {
|
||||
return 'https://moji.id/schedule'
|
||||
},
|
||||
|
||||
request: {
|
||||
method: 'GET',
|
||||
timeout: 5000,
|
||||
cache: { ttl: 60 * 60 * 1000 },
|
||||
headers: {
|
||||
'User-Agent':
|
||||
'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/112.0.0.0 Safari/537.36'
|
||||
}
|
||||
},
|
||||
|
||||
days: 2,
|
||||
url: 'https://moji.id/schedule',
|
||||
logo: function (context) {
|
||||
return context.channel.logo
|
||||
},
|
||||
|
||||
parser: function (context) {
|
||||
const programs = []
|
||||
const items = parseItems(context)
|
||||
|
@ -60,15 +42,16 @@ function parseItems(context) {
|
|||
const monthDate = dayjs(context.date).format('MMM DD')
|
||||
const items = []
|
||||
|
||||
schDayMonths.forEach(function (schDayMonth, i) {
|
||||
schDayMonths.forEach((schDayMonth, i) => {
|
||||
if (monthDate == $(schDayMonth).text()) {
|
||||
let schDayPrograms = $(schPrograms[i]).find('.accordion').toArray()
|
||||
schDayPrograms.forEach(function (program, i) {
|
||||
let itemDay = {
|
||||
progStart: parseStart(schDayMonth, program),
|
||||
progStop: parseStop(schDayMonth, program, schDayPrograms[i + 1]),
|
||||
progTitle: parseTitle(program),
|
||||
progDesc: parseDescription(program)
|
||||
const schDayPrograms = $(schPrograms[i]).find('.accordion').toArray()
|
||||
schDayPrograms.forEach((program, i) => {
|
||||
const itemDay = {
|
||||
progStart: parseStart($(schDayMonth), $(program)),
|
||||
progStop: parseStop($(schDayMonth), schDayPrograms[i + 1] ?
|
||||
$(schDayPrograms[i + 1]) : null),
|
||||
progTitle: parseTitle($(program)),
|
||||
progDesc: parseDescription($(program))
|
||||
}
|
||||
items.push(itemDay)
|
||||
})
|
||||
|
@ -79,44 +62,38 @@ function parseItems(context) {
|
|||
}
|
||||
|
||||
function parseTitle(item) {
|
||||
return cheerio.load(item)('.name-prog').text()
|
||||
return item.find('.name-prog').text()
|
||||
}
|
||||
|
||||
function parseDescription(item) {
|
||||
return cheerio.load(item)('.content-acc span').text()
|
||||
return item.find('.content-acc span').text()
|
||||
}
|
||||
|
||||
function parseStart(schDayMonth, item) {
|
||||
let monthDate = cheerio.load(schDayMonth).text().split(' ')
|
||||
let startTime = cheerio.load(item)('.pkl').text()
|
||||
let progStart = dayjs.tz(
|
||||
currentYear + ' ' + monthDate[0] + ' ' + monthDate[1] + ' ' + startTime,
|
||||
'YYYY MMM DD HH:mm',
|
||||
'Asia/Jakarta'
|
||||
const monthDate = schDayMonth.text().split(' ')
|
||||
const startTime = item.find('.pkl').text()
|
||||
|
||||
return dayjs.tz(
|
||||
`${currentYear}-${monthDate[0]}-${monthDate[1]} ${startTime}`,
|
||||
'YYYY-MMM-DD HH:mm',
|
||||
tz
|
||||
)
|
||||
return progStart
|
||||
}
|
||||
|
||||
function parseStop(schDayMonth, itemCurrent, itemNext) {
|
||||
let monthDate = cheerio.load(schDayMonth).text().split(' ')
|
||||
|
||||
function parseStop(schDayMonth, itemNext) {
|
||||
const monthDate = schDayMonth.text().split(' ')
|
||||
if (itemNext) {
|
||||
let stopTime = cheerio.load(itemNext)('.pkl').text()
|
||||
const stopTime = itemNext.find('.pkl').text()
|
||||
return dayjs.tz(
|
||||
currentYear + ' ' + monthDate[0] + ' ' + monthDate[1] + ' ' + stopTime,
|
||||
'YYYY MMM DD HH:mm',
|
||||
'Asia/Jakarta'
|
||||
`${currentYear}-${monthDate[0]}-${monthDate[1]} ${stopTime}`,
|
||||
'YYYY-MMM-DD HH:mm',
|
||||
tz
|
||||
)
|
||||
} else {
|
||||
return dayjs.tz(
|
||||
currentYear +
|
||||
' ' +
|
||||
monthDate[0] +
|
||||
' ' +
|
||||
(parseInt(monthDate[1]) + 1).toString().padStart(2, '0') +
|
||||
' 00:00',
|
||||
'YYYY MMM DD HH:mm',
|
||||
'Asia/Jakarta'
|
||||
`${currentYear}-${monthDate[0]}-${(parseInt(monthDate[1]) + 1).toString().padStart(2, '0')} 00:00`,
|
||||
'YYYY-MMM-DD HH:mm',
|
||||
tz
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
File diff suppressed because one or more lines are too long
Loading…
Add table
Add a link
Reference in a new issue