Merge pull request #3077 from iptv-org/update-foxtel.com.au

Update foxtel.com.au
This commit is contained in:
PopeyeTheSai10r
2026-04-18 14:56:13 -07:00
committed by GitHub
4 changed files with 4942 additions and 4883 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -14,10 +14,11 @@ module.exports = {
headers: { headers: {
'Accept-Language': 'en-US,en;', 'Accept-Language': 'en-US,en;',
Cookie: 'AAMC_foxtel_0=REGION|7', Cookie: 'AAMC_foxtel_0=REGION|7',
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36' 'User-Agent':
'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36'
} }
}, },
parser: function ({ content, date }) { async parser({ content, date }) {
let programs = [] let programs = []
const items = parseItems(content) const items = parseItems(content)
for (let item of items) { for (let item of items) {
@@ -32,9 +33,18 @@ module.exports = {
prev.stop = start prev.stop = start
} }
const stop = start.add(30, 'm') const stop = start.add(30, 'm')
const programId = parseProgramId($item)
const details = await loadProgramDetails(programId)
let description
if (details) {
description = parseDescription(details)
}
programs.push({ programs.push({
title: parseTitle($item), title: parseTitle($item),
sub_title: parseSubTitle($item), sub_title: parseSubTitle($item),
description,
image: parseImage($item), image: parseImage($item),
rating: parseRating($item), rating: parseRating($item),
season: parseSeason($item), season: parseSeason($item),
@@ -72,6 +82,34 @@ module.exports = {
} }
} }
function parseProgramId($item) {
const href = $item('*').attr('href')
return href.split('/')[1]
}
async function loadProgramDetails(programId) {
if (!programId) return {}
return await axios
.get(
`https://www.foxtel.com.au/webepg/ws/foxtel/event/${programId}?movieHeight=213&tvShowHeight=213&regionId=8336`,
{
headers: {
'sec-fetch-dest': 'empty',
'sec-fetch-site': 'same-origin',
'User-Agent': 'insomnia/2022.7.5'
}
}
)
.then(r => r.data)
.catch(console.log)
}
function parseDescription(details) {
return details?.event?.shortSynopsis
}
function parseSeason($item) { function parseSeason($item) {
let seasonString = $item('.epg-event-description > div > abbr:nth-child(1)').attr('title') let seasonString = $item('.epg-event-description > div > abbr:nth-child(1)').attr('title')
if (!seasonString) return null if (!seasonString) return null
@@ -118,9 +156,9 @@ function parseRating($item) {
return rating return rating
? { ? {
system: 'ACB', system: 'ACB',
value: rating value: rating
} }
: null : null
} }

View File

@@ -1,3 +1,4 @@
const axios = require('axios')
const { parser, url, request } = require('./foxtel.com.au.config.js') const { parser, url, request } = require('./foxtel.com.au.config.js')
const fs = require('fs') const fs = require('fs')
const path = require('path') const path = require('path')
@@ -7,6 +8,23 @@ const customParseFormat = require('dayjs/plugin/customParseFormat')
dayjs.extend(customParseFormat) dayjs.extend(customParseFormat)
dayjs.extend(utc) dayjs.extend(utc)
jest.mock('axios')
axios.get.mockImplementation(url => {
if (
url ===
'https://www.foxtel.com.au/webepg/ws/foxtel/event/174868153?movieHeight=213&tvShowHeight=213&regionId=8336'
) {
return Promise.resolve({
data: JSON.parse(fs.readFileSync(path.resolve(__dirname, '__data__/program_1.json')))
})
} else {
return Promise.resolve({
data: '{}'
})
}
})
const date = dayjs.utc('2022-11-08', 'YYYY-MM-DD').startOf('d') const date = dayjs.utc('2022-11-08', 'YYYY-MM-DD').startOf('d')
const channel = { const channel = {
site_id: 'Channel-9-Sydney/NIN', site_id: 'Channel-9-Sydney/NIN',
@@ -26,10 +44,10 @@ it('can generate valid request headers', () => {
}) })
}) })
it('can parse response', () => { it('can parse response', async () => {
const content = fs.readFileSync(path.resolve(__dirname, '__data__/content.html')) const content = fs.readFileSync(path.resolve(__dirname, '__data__/content.html'))
let results = parser({ content }) let results = await parser({ content })
results = results.map(p => { results = results.map(p => {
p.start = p.start.toJSON() p.start = p.start.toJSON()
p.stop = p.stop.toJSON() p.stop = p.stop.toJSON()
@@ -41,6 +59,8 @@ it('can parse response', () => {
stop: '2022-11-07T13:30:00.000Z', stop: '2022-11-07T13:30:00.000Z',
title: 'The Equalizer', title: 'The Equalizer',
sub_title: 'Glory', sub_title: 'Glory',
description:
"While Danny chaperones Grace's winter formal, terrorists seize the venue and hold everyone hostage in order to kidnap a diplomat's son.",
image: image:
'https://images1.resources.foxtel.com.au/store2/mount1/16/3/69e0v.jpg?maxheight=90&limit=91aa1c7a2c485aeeba0706941f79f111adb35830', 'https://images1.resources.foxtel.com.au/store2/mount1/16/3/69e0v.jpg?maxheight=90&limit=91aa1c7a2c485aeeba0706941f79f111adb35830',
rating: { rating: {
@@ -52,8 +72,8 @@ it('can parse response', () => {
}) })
}) })
it('can handle empty guide', () => { it('can handle empty guide', async () => {
const result = parser({ const result = await parser({
content: fs.readFileSync(path.resolve(__dirname, '__data__/no-content.html')) content: fs.readFileSync(path.resolve(__dirname, '__data__/no-content.html'))
}) })
expect(result).toMatchObject([]) expect(result).toMatchObject([])