mirror of
https://github.com/iptv-org/epg.git
synced 2025-05-10 00:50:09 -04:00
Merge pull request #1567 from RevGear/abc.net.au
Add guide for abc.net.au
This commit is contained in:
commit
2fb091a3b4
4 changed files with 182 additions and 0 deletions
17
.github/workflows/abc.net.au.yml
vendored
Normal file
17
.github/workflows/abc.net.au.yml
vendored
Normal file
|
@ -0,0 +1,17 @@
|
|||
name: abc.net.au
|
||||
on:
|
||||
schedule:
|
||||
- cron: '0 3 * * *'
|
||||
workflow_dispatch:
|
||||
workflow_run:
|
||||
workflows: [_trigger]
|
||||
types:
|
||||
- completed
|
||||
jobs:
|
||||
load:
|
||||
uses: ./.github/workflows/_load.yml
|
||||
with:
|
||||
site: ${{github.workflow}}
|
||||
secrets:
|
||||
APP_ID: ${{ secrets.APP_ID }}
|
||||
APP_PRIVATE_KEY: ${{ secrets.APP_PRIVATE_KEY }}
|
74
sites/abc.net.au/abc.net.au.config.js
Normal file
74
sites/abc.net.au/abc.net.au.config.js
Normal file
|
@ -0,0 +1,74 @@
|
|||
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: 'abc.net.au',
|
||||
request: {
|
||||
cache: {
|
||||
ttl: 60 * 60 * 1000 // 1 hour
|
||||
}
|
||||
},
|
||||
url({ date }) {
|
||||
return `https://epg.abctv.net.au/processed/Sydney_${date.format('YYYY-MM-DD')}.json`
|
||||
},
|
||||
parser({ content, channel }) {
|
||||
let programs = []
|
||||
const items = parseItems(content, channel)
|
||||
items.forEach(item => {
|
||||
programs.push({
|
||||
title: item.title,
|
||||
sub_title: item.episode_title,
|
||||
category: item.genres,
|
||||
description: item.description,
|
||||
season: parseSeason(item),
|
||||
episode: parseEpisode(item),
|
||||
rating: parseRating(item),
|
||||
icon: parseIcon(item),
|
||||
start: parseTime(item.start_time),
|
||||
stop: parseTime(item.end_time)
|
||||
})
|
||||
})
|
||||
|
||||
return programs
|
||||
}
|
||||
}
|
||||
|
||||
function parseItems(content, channel) {
|
||||
try {
|
||||
const data = JSON.parse(content)
|
||||
if (!data) return []
|
||||
if (!Array.isArray(data.schedule)) return []
|
||||
|
||||
const channelData = data.schedule.find(i => i.channel == channel.site_id)
|
||||
return channelData.listing && Array.isArray(channelData.listing) ? channelData.listing : []
|
||||
} catch (err) {
|
||||
return []
|
||||
}
|
||||
}
|
||||
|
||||
function parseSeason(item) {
|
||||
return item.series_num || null
|
||||
}
|
||||
function parseEpisode(item) {
|
||||
return item.episode_num || null
|
||||
}
|
||||
function parseTime(time) {
|
||||
return dayjs.tz(time, 'YYYY-MM-DD HH:mm', 'Australia/Sydney')
|
||||
}
|
||||
function parseIcon(item) {
|
||||
return item.image_file ? `https://www.abc.net.au/tv/common/images/publicity/${item.image_file}` : null
|
||||
}
|
||||
function parseRating(item) {
|
||||
return item.rating
|
||||
? {
|
||||
system: 'ACB',
|
||||
value: item.rating
|
||||
}
|
||||
: null
|
||||
}
|
54
sites/abc.net.au/abc.net.au.test.js
Normal file
54
sites/abc.net.au/abc.net.au.test.js
Normal file
|
@ -0,0 +1,54 @@
|
|||
// npx epg-grabber --config=sites/abc.net.au/abc.net.au.config.js --channels=sites/abc.net.au/abc.net.au_au.channels.xml --output=guide.xml --days=2
|
||||
|
||||
const { parser, url } = require('./abc.net.au.config.js')
|
||||
const dayjs = require('dayjs')
|
||||
const utc = require('dayjs/plugin/utc')
|
||||
dayjs.extend(utc)
|
||||
|
||||
const date = dayjs.utc('2022-12-22', 'YYYY-MM-DD').startOf('d')
|
||||
const channel = {
|
||||
site_id: 'ABC1',
|
||||
xmltv_id: 'ABCTV.au'
|
||||
}
|
||||
it('can generate valid url', () => {
|
||||
expect(url({ date })).toBe(
|
||||
'https://epg.abctv.net.au/processed/Sydney_2022-12-22.json'
|
||||
)
|
||||
})
|
||||
|
||||
it('can parse response', () => {
|
||||
const content = `{"date":"2022-12-22","region":"Sydney","schedule":[{"channel":"ABC1","listing":[{"consumer_advice":"Adult Themes, Drug Use, Violence","rating":"M","show_id":912747,"repeat":true,"description":"When tragedy strikes close to home, it puts head teacher Noah Taylor on a collision course with the criminals responsible. Can the Lyell team help him stop the cycle of violence?","title":"Silent Witness","crid":"ZW2178A004S00","start_time":"2022-12-22T00:46:00","series-crid":"ZW2178A","live":false,"captioning":true,"show_type":"Episode","series_num":22,"episode_title":"Lift Up Your Hearts (part Two)","length":58,"onair_title":"Silent Witness","end_time":"2022-12-22T01:44:00","genres":["Entertainment"],"image_file":"ZW2178A004S00_460.jpg","prog_slug":"silent-witness","episode_num":4}]}]}`
|
||||
|
||||
const result = parser({ content, channel }).map(p => {
|
||||
p.start = p.start.toJSON()
|
||||
p.stop = p.stop.toJSON()
|
||||
return p
|
||||
})
|
||||
|
||||
expect(result).toMatchObject([
|
||||
{
|
||||
title: 'Silent Witness',
|
||||
sub_title: 'Lift Up Your Hearts (part Two)',
|
||||
description: `When tragedy strikes close to home, it puts head teacher Noah Taylor on a collision course with the criminals responsible. Can the Lyell team help him stop the cycle of violence?`,
|
||||
category: ['Entertainment'],
|
||||
rating: {
|
||||
system: 'ACB',
|
||||
value: 'M'},
|
||||
season: 22,
|
||||
episode: 4,
|
||||
icon: 'https://www.abc.net.au/tv/common/images/publicity/ZW2178A004S00_460.jpg',
|
||||
start: '2022-12-21T13:46:00.000Z',
|
||||
stop: '2022-12-21T14:44:00.000Z'
|
||||
}
|
||||
])
|
||||
})
|
||||
|
||||
it('can handle empty guide', () => {
|
||||
const result = parser(
|
||||
{
|
||||
content: `<Error><Code>NoSuchKey</Code><Message>The specified key does not exist.</Message><Key>processed/Sydney_2023-01-17.json</Key><RequestId>6MRHX5TJ12X39B3Y</RequestId><HostId>59rH6XRMrmkFywg8Kv58iqpI6O1fuOCuEbKa1HRRYa4buByXMBTvAhz8zuAK7X5D+ZN9ZuWxyGs=</HostId></Error>`
|
||||
},
|
||||
channel
|
||||
)
|
||||
expect(result).toMatchObject([])
|
||||
})
|
37
sites/abc.net.au/abc.net.au_au.channels.xml
Normal file
37
sites/abc.net.au/abc.net.au_au.channels.xml
Normal file
|
@ -0,0 +1,37 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<site site="abc.net.au">
|
||||
<channels>
|
||||
<channel lang="en" xmltv_id="10Bold.au" site_id="ONE">10 Bold</channel>
|
||||
<channel lang="en" xmltv_id="10Peach.au" site_id="11">10 Peach</channel>
|
||||
<channel lang="en" xmltv_id="10Shake.au" site_id="SHAKE">10 Shake</channel>
|
||||
<channel lang="en" xmltv_id="7flix.au" site_id="7flix">7flix</channel>
|
||||
<channel lang="en" xmltv_id="7mate.au" site_id="7MATE">7mate</channel>
|
||||
<channel lang="en" xmltv_id="7two.au" site_id="7TWO">7two</channel>
|
||||
<channel lang="en" xmltv_id="9Gem.au" site_id="GEM">9 Gem</channel>
|
||||
<channel lang="en" xmltv_id="9Go.au" site_id="GO">9 Go!</channel>
|
||||
<channel lang="en" xmltv_id="9Life.au" site_id="9Life">9 Life</channel>
|
||||
<channel lang="en" xmltv_id="9Rush.au" site_id="9Rush">9 Rush</channel>
|
||||
<channel lang="en" xmltv_id="ABCKids.au" site_id="ABC4KIDS">ABC Kids</channel>
|
||||
<channel lang="en" xmltv_id="ABCMe.au" site_id="ABC3">ABC ME</channel>
|
||||
<channel lang="en" xmltv_id="ABCNewsAustralia.au" site_id="ABCN">ABC News</channel>
|
||||
<channel lang="en" xmltv_id="ABCTV.au" site_id="ABC1">ABC TV</channel>
|
||||
<channel lang="en" xmltv_id="ABCTVPlus.au" site_id="ABC2">ABC TV Plus</channel>
|
||||
<channel lang="en" xmltv_id="Channel10.au" site_id="10">Channel 10</channel>
|
||||
<channel lang="en" xmltv_id="Channel7.au" site_id="7">Channel 7</channel>
|
||||
<channel lang="en" xmltv_id="Channel9.au" site_id="9">Channel 9</channel>
|
||||
<channel lang="en" xmltv_id="NITV.au" site_id="NITV">NITV</channel>
|
||||
<channel lang="en" xmltv_id="Racingcom.au" site_id="RTV">Racing.com</channel>
|
||||
<channel lang="en" xmltv_id="SBS.au" site_id="SBS">SBS One</channel>
|
||||
<channel lang="en" xmltv_id="SBSFood.au" site_id="SBS3">SBS Food</channel>
|
||||
<channel lang="en" xmltv_id="SBSViceland.au" site_id="VICHD">SBS Viceland</channel>
|
||||
<channel lang="en" xmltv_id="SBSWorldMovies.au" site_id="SBS2">SBS World Movies</channel>
|
||||
<channel lang="en" xmltv_id="SBSWorldWatch.au" site_id="SBSWW">SBS World Watch</channel>
|
||||
<channel lang="en" xmltv_id="SpreeTV.au" site_id="SPREE">Spree TV</channel>
|
||||
<channel lang="en" xmltv_id="TVSN.au" site_id="TVSN">TSVN</channel>
|
||||
<!-- <channel lang="en" xmltv_id="ABCTV.au" site_id="ABCHD">ABC TV HD</channel> -->
|
||||
<!-- <channel lang="en" xmltv_id="Channel10.au" site_id="TENHD">Channel 10 HD</channel> -->
|
||||
<!-- <channel lang="en" xmltv_id="Channel7.au" site_id="7HD">Channel 7 HD</channel> -->
|
||||
<!-- <channel lang="en" xmltv_id="Channel9.au" site_id="9HD">Channel 9 HD</channel> -->
|
||||
<!-- <channel lang="en" xmltv_id="SBS.au" site_id="SBSHD">SBS HD</channel> -->
|
||||
</channels>
|
||||
</site>
|
Loading…
Add table
Add a link
Reference in a new issue