Merge pull request #1744 from iptv-org/add-flixed.io

Add guide from flixed.io
This commit is contained in:
Aleksandr Statciuk 2023-01-23 03:18:08 +03:00 committed by GitHub
commit 1830d073f9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 118 additions and 0 deletions

17
.github/workflows/flixed.io.yml vendored Normal file
View file

@ -0,0 +1,17 @@
name: flixed.io
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 }}

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<site site="flixed.io">
<channels>
<channel lang="en" xmltv_id="VSiN.us" site_id="108970">Vegas Sports &amp; Information Network (VSIN)</channel>
</channels>
</site>

View file

@ -0,0 +1,45 @@
const dayjs = require('dayjs')
module.exports = {
site: 'flixed.io',
days: 1, // NOTE: changing the date in a request does not change the response
url: function ({ date, channel }) {
return `https://tv-guide.vercel.app/api/stationAirings?stationId=${
channel.site_id
}&startDateTime=${date.toJSON()}`
},
parser({ content }) {
let programs = []
let items = parseItems(content)
items.forEach(item => {
programs.push({
title: item.program.title,
description: item.program.longDescription,
category: item.program.subType,
icon: parseIcon(item),
start: parseStart(item),
stop: parseStop(item)
})
})
return programs
}
}
function parseIcon(item) {
const uri = item.program.preferredImage.uri
return uri ? `https://adma.tmsimg.com/assets/${uri}` : null
}
function parseStart(item) {
return dayjs(item.startTime)
}
function parseStop(item) {
return dayjs(item.endTime)
}
function parseItems(content, channel) {
return JSON.parse(content)
}

View file

@ -0,0 +1,49 @@
// npx epg-grabber --config=sites/flixed.io/flixed.io.config.js --channels=sites/flixed.io/flixed.io.channels.xml --output=guide.xml --days=1
const { parser, url } = require('./flixed.io.config.js')
const fs = require('fs')
const path = require('path')
const dayjs = require('dayjs')
const utc = require('dayjs/plugin/utc')
const customParseFormat = require('dayjs/plugin/customParseFormat')
dayjs.extend(customParseFormat)
dayjs.extend(utc)
const date = dayjs.utc('2023-01-19', 'YYYY-MM-DD').startOf('d')
const channel = {
site_id: '108970',
xmltv_id: 'VSiN.us'
}
it('can generate valid url', () => {
expect(url({ date, channel })).toBe(
`https://tv-guide.vercel.app/api/stationAirings?stationId=108970&startDateTime=2023-01-19T00:00:00.000Z`
)
})
it('can parse response', () => {
const content = fs.readFileSync(path.resolve(__dirname, '__data__/content.json'))
let results = parser({ content, channel, date })
results = results.map(p => {
p.start = p.start.toJSON()
p.stop = p.stop.toJSON()
return p
})
expect(results[0]).toMatchObject({
start: '2023-01-19T05:00:00.000Z',
stop: '2023-01-19T06:00:00.000Z',
title: 'The Greg Peterson Experience',
category: 'Sports non-event',
icon: 'https://adma.tmsimg.com/assets/assets/p20628892_b_v13_aa.jpg?w=270&h=360',
description: 'A different kind of sports betting.'
})
})
it('can handle empty guide', () => {
const results = parser({
content: `[]`
})
expect(results).toMatchObject([])
})