mirror of
https://github.com/iptv-org/epg
synced 2026-04-25 20:17:01 -04:00
Create gigatv.3bbtv.co.th.config.js
This commit is contained in:
65
sites/gigatv.3bbtv.co.th/gigatv.3bbtv.co.th.config.js
Normal file
65
sites/gigatv.3bbtv.co.th/gigatv.3bbtv.co.th.config.js
Normal file
@@ -0,0 +1,65 @@
|
|||||||
|
const axios = require('axios')
|
||||||
|
const dayjs = require('dayjs')
|
||||||
|
const utc = require('dayjs/plugin/utc')
|
||||||
|
const timezone = require('dayjs/plugin/timezone')
|
||||||
|
const customParseFormat = require('dayjs/plugin/customParseFormat')
|
||||||
|
|
||||||
|
dayjs.extend(utc)
|
||||||
|
dayjs.extend(timezone)
|
||||||
|
dayjs.extend(customParseFormat)
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
site: 'gigatv.3bbtv.co.th',
|
||||||
|
days: 1,
|
||||||
|
url({ channel }) {
|
||||||
|
return `https://gigatv.3bbtv.co.th/wp-content/themes/changwattana/epg/${channel.site_id}.json`
|
||||||
|
},
|
||||||
|
parser: function ({ content, date }) {
|
||||||
|
let programs = []
|
||||||
|
const items = parseItems(content, date)
|
||||||
|
items.forEach(item => {
|
||||||
|
programs.push({
|
||||||
|
title: item.programName,
|
||||||
|
start: parseTime(item.startTime),
|
||||||
|
stop: parseTime(item.endTime)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
return programs
|
||||||
|
},
|
||||||
|
async channels() {
|
||||||
|
const data = await axios
|
||||||
|
.get('https://gigatv.3bbtv.co.th/wp-content/themes/changwattana/epg/channel.json')
|
||||||
|
.then(r => r.data)
|
||||||
|
.catch(console.log)
|
||||||
|
|
||||||
|
const channels = []
|
||||||
|
data.forEach(group => {
|
||||||
|
group.channel_list.forEach(channel => {
|
||||||
|
channels.push({
|
||||||
|
lang: 'th',
|
||||||
|
site_id: channel.channel_id,
|
||||||
|
name: channel.channel_name
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
return channels
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function parseTime(string) {
|
||||||
|
return dayjs.tz(string, 'YYYY-MM-DD HH:mm:ss', 'Asia/Bangkok')
|
||||||
|
}
|
||||||
|
|
||||||
|
function parseItems(content, date) {
|
||||||
|
try {
|
||||||
|
let data = JSON.parse(content)
|
||||||
|
if (!Array.isArray(data)) return []
|
||||||
|
data = data.filter(p => date.isSame(parseTime(p.startTime), 'day'))
|
||||||
|
|
||||||
|
return data
|
||||||
|
} catch {
|
||||||
|
return []
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user